Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldgray committed Jan 19, 2024
1 parent fe04215 commit b89e9e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Uri GetAuthLoginUrl(OidcConfiguration oidcConfiguration, AccessService ac
var additionalScopes = oidcConfiguration.Scopes?.Split(",", StringSplitOptions.RemoveEmptyEntries) ??
Array.Empty<string>();

/* don't use .WithRedirectUrl(Uri uri) ond instead pass string. The former uses .OriginalString and will always
/* don't use .WithRedirectUrl(Uri uri) and instead pass string. The former uses .OriginalString and will always
* include the port number (so https://dlcs.digirati.io/ => https://dlcs.digirati.io:443/). This differs from
* how the redirect URI is build for code exchange and causes 403 error */
var authBuilder = new AuthorizationUrlBuilder(oidcConfiguration.Domain)
Expand All @@ -73,7 +73,7 @@ public Uri GetAuthLoginUrl(OidcConfiguration oidcConfiguration, AccessService ac
}

/// <summary>
/// Exchange authentication code for access tokens for logged in user
/// Exchange authentication code for access token for logged in user
/// </summary>
public async Task<IReadOnlyCollection<string>> GetDlcsRolesForCode(OidcConfiguration oidcConfiguration,
AccessService accessService, string code, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace IIIFAuth2.API.Infrastructure.Auth.RoleProvisioning.Oidc;
public interface IJwtTokenHandler
{
/// <summary>
/// Validate JWT token and return <see cref="ClaimsPrincipal"/> if successfully parsed.
/// Validate JWT token and return <see cref="ClaimsPrincipal"/> if successful
/// </summary>
/// <param name="jwtToken">JWT id token string</param>
/// <param name="jwksUri">Path where jwks can be found</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public OidcRoleProviderHandler(
this.logger = logger;
}

/// <summary>
/// Generate redirect link to send user to idp
/// </summary>
public async Task<HandleRoleProvisionResponse> InitiateLoginRequest(int customerId, Uri requestOrigin,
AccessService accessService, IProviderConfiguration providerConfiguration,
CancellationToken cancellationToken = default)
Expand All @@ -46,8 +49,11 @@ public async Task<HandleRoleProvisionResponse> InitiateLoginRequest(int customer
return HandleRoleProvisionResponse.Redirect(loginUrl);
}

public async Task<HandleRoleProvisionResponse> HandleLoginCallback(int customerId, string roleProvisionToken, string authCode,
AccessService accessService, IProviderConfiguration providerConfiguration,
/// <summary>
/// Handle callback from idp, validate roleProvisionToken, exchange authCode for jwt + calculate DLCS roles
/// </summary>
public async Task<HandleRoleProvisionResponse> HandleLoginCallback(int customerId, string roleProvisionToken,
string authCode, AccessService accessService, IProviderConfiguration providerConfiguration,
CancellationToken cancellationToken = default)
{
var configuration = providerConfiguration.SafelyGetTypedConfig<OidcConfiguration>();
Expand All @@ -66,12 +72,12 @@ public async Task<HandleRoleProvisionResponse> HandleLoginCallback(int customerI
}

var requestUri = new Uri(validateTokenResult.Value!.Origin);

// Get DLCS roles from authcode
var roles = await auth0Client.GetDlcsRolesForCode(configuration, accessService, authCode, cancellationToken);

if (roles.IsNullOrEmpty()) return HandleRoleProvisionResponse.Error("Unable to get DLCS roles for user");

return await roleProvisionGranter.CompleteRequest(customerId, requestUri, providerConfiguration,
() => Task.FromResult(roles), cancellationToken);
}
Expand Down

0 comments on commit b89e9e2

Please sign in to comment.