Browse Source
Merge pull request #17045 from huseyinalan/dev
Move invoke code after setting OpenIdConnectOptions for override flexibility
pull/17052/head
maliming
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
3 additions and
12 deletions
-
framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs
|
|
|
@ -28,8 +28,6 @@ public static class AbpOpenIdConnectExtensions |
|
|
|
{ |
|
|
|
options.ClaimActions.MapAbpClaimTypes(); |
|
|
|
|
|
|
|
configureOptions?.Invoke(options); |
|
|
|
|
|
|
|
options.Events ??= new OpenIdConnectEvents(); |
|
|
|
var authorizationCodeReceived = options.Events.OnAuthorizationCodeReceived ?? (_ => Task.CompletedTask); |
|
|
|
|
|
|
|
@ -39,16 +37,7 @@ public static class AbpOpenIdConnectExtensions |
|
|
|
return authorizationCodeReceived.Invoke(receivedContext); |
|
|
|
}; |
|
|
|
|
|
|
|
options.Events.OnRemoteFailure = remoteFailureContext => |
|
|
|
{ |
|
|
|
if (remoteFailureContext.Failure is OpenIdConnectProtocolException && |
|
|
|
remoteFailureContext.Failure.Message.Contains("access_denied")) |
|
|
|
{ |
|
|
|
remoteFailureContext.HandleResponse(); |
|
|
|
remoteFailureContext.Response.Redirect($"{remoteFailureContext.Request.PathBase}/"); |
|
|
|
} |
|
|
|
return Task.CompletedTask; |
|
|
|
}; |
|
|
|
options.AccessDeniedPath = "/"; |
|
|
|
|
|
|
|
options.Events.OnTokenValidated = async (context) => |
|
|
|
{ |
|
|
|
@ -63,6 +52,8 @@ public static class AbpOpenIdConnectExtensions |
|
|
|
logger?.LogException(ex); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
configureOptions?.Invoke(options); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|