Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ClaimSet helper #372

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions src/D2L.Security.OAuth2/Provisioning/ClaimSet.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using D2L.CodeStyle.Annotations;
using D2L.Security.OAuth2.Keys;
using D2L.Security.OAuth2.Scopes;
using D2L.Services;

namespace D2L.Security.OAuth2.Provisioning.Default {

Expand All @@ -23,15 +22,6 @@ IAuthServiceClient authServiceClient
m_client = authServiceClient;
}

[GenerateSync]
Task<IAccessToken> INonCachingAccessTokenProvider.ProvisionAccessTokenAsync(
ClaimSet claimSet,
IEnumerable<Scope> scopes
) {
var @this = this as INonCachingAccessTokenProvider;
return @this.ProvisionAccessTokenAsync( claimSet.ToClaims(), scopes );
}

[GenerateSync]
async Task<IAccessToken> INonCachingAccessTokenProvider.ProvisionAccessTokenAsync(
IEnumerable<Claim> claimSet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Tasks;
using D2L.Security.OAuth2.Caching;
using D2L.Security.OAuth2.Scopes;
using D2L.Services;
using D2L.CodeStyle.Annotations;

#if DNXCORE50
Expand All @@ -33,16 +32,6 @@ TimeSpan tokenRefreshGracePeriod
m_tokenHandler = new JwtSecurityTokenHandler();
}

[GenerateSync]
async Task<IAccessToken> IAccessTokenProvider.ProvisionAccessTokenAsync(
ClaimSet claimSet,
IEnumerable<Scope> scopes,
ICache cache
) {
var @this = this as IAccessTokenProvider;
return await @this.ProvisionAccessTokenAsync( claimSet.ToClaims(), scopes, cache ).ConfigureAwait( false );
}

[GenerateSync]
async Task<IAccessToken> IAccessTokenProvider.ProvisionAccessTokenAsync(
IEnumerable<Claim> claims,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
using D2L.Security.OAuth2.Scopes;

namespace D2L.Security.OAuth2.Provisioning.Default {

internal partial interface INonCachingAccessTokenProvider {

[GenerateSync]
Task<IAccessToken> ProvisionAccessTokenAsync(
ClaimSet claimSet,
IEnumerable<Scope> scopes
);

[GenerateSync]
Task<IAccessToken> ProvisionAccessTokenAsync(
IEnumerable<Claim> claims,
Expand Down
18 changes: 0 additions & 18 deletions src/D2L.Security.OAuth2/Provisioning/IAccessTokenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,11 @@
using D2L.Security.OAuth2.Scopes;

namespace D2L.Security.OAuth2.Provisioning {

/// <summary>
/// Provisions access tokens from the auth service
/// </summary>
/// <remarks>This type is disposable</remarks>
public partial interface IAccessTokenProvider {

/// <summary>
/// Provisions an access token containing the provided claims and scopes.
/// </summary>
/// <param name="claimSet">The set of claims to be included in the token.</param>
/// <param name="scopes">The set of scopes to be included in the token.</param>
/// <param name="cache">The provided <see cref="ICache"/> does not need to
/// check for token expiration or grace period because the
/// <see cref="IAccessTokenProvider"/> will handle it internally.</param>
/// <returns>An access token containing an expiry and the provided claims and scopes.</returns>
[GenerateSync]
Task<IAccessToken> ProvisionAccessTokenAsync(
ClaimSet claimSet,
IEnumerable<Scope> scopes,
ICache cache = null
);

/// <summary>
/// Provisions an access token containing the provided claims and scopes.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Net.Http;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading.Tasks;
using D2L.Security.OAuth2.Provisioning;
Expand All @@ -15,7 +16,12 @@ internal sealed class TestAccessTokenProviderTests {
private const string DEV_AUTH_JWKS_URL = "https://dev-auth.brightspace.com/core/.well-known/jwks";
private const string DEV_AUTH_JWK_URL = "https://dev-auth.brightspace.com/core/jwk/";

private readonly ClaimSet testClaimSet = new ClaimSet( "ExpandoClient", Guid.NewGuid() );
private readonly Claim[] testClaimSet = new[] {
new Claim( Constants.Claims.ISSUER, "ExpandoClient" ),
new Claim( Constants.Claims.TENANT_ID, Guid.NewGuid().ToString() )
};


private readonly Scope[] testScopes = {
new Scope( "*", "*", "*" )
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public async Task ProvisionAccessTokenAsync_CallPassThroughOverload_CallsOtherOv
m_serviceTokenCacheMock.Setup( x => x.GetAsync( key ) )
.Returns( Task.FromResult( new CacheResponse( true, BuildTestToken() ) ) );

ClaimSet claimSet = new ClaimSet( "TheIssuer" );
var claimSet = new[] {
new Claim( Constants.Claims.ISSUER, "TheIssuer" )
};

IAccessTokenProvider cachedAccessTokenProvider = GetCachedAccessTokenProvider();
IAccessToken token =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ await m_accessTokenProvider

[Test]
public async Task ProvisionAccessTokenAsync_LegacyClaimSetOverload_DoesRightThing() {
var claimSet = new ClaimSet(
issuer: TestData.ISSUER,
tenantId: TestData.TENANT_ID,
user: TestData.USER
);
var claimSet = new[] {
new Claim( Constants.Claims.ISSUER, TestData.ISSUER ),
new Claim( Constants.Claims.TENANT_ID, TestData.TENANT_ID.ToString() ),
new Claim(Constants.Claims.USER_ID, TestData.USER )
};

await m_accessTokenProvider
.ProvisionAccessTokenAsync( claimSet, new Scope[] { } )
Expand Down
Loading