From 44ead834ebe0b1534f53d5ae89296faf06435f06 Mon Sep 17 00:00:00 2001 From: huseyinalan <74354599+huseyinalan@users.noreply.github.com> Date: Wed, 5 Jul 2023 21:00:54 +0300 Subject: [PATCH 1/2] Invoke configure options method after initialized abp options in AddAbpOpenIdConnect --- .../DependencyInjection/AbpOpenIdConnectExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs index 2a2d0a712d..984b3cf3a4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs +++ b/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); @@ -63,6 +61,8 @@ public static class AbpOpenIdConnectExtensions logger?.LogException(ex); } }; + + configureOptions?.Invoke(options); }); } From b6c194ecdd24a15402d70465bd2f1cd0610862fb Mon Sep 17 00:00:00 2001 From: huseyinalan <74354599+huseyinalan@users.noreply.github.com> Date: Wed, 5 Jul 2023 21:03:05 +0300 Subject: [PATCH 2/2] Refactored the access_denied in AddAbpOpenIdConnect. --- .../DependencyInjection/AbpOpenIdConnectExtensions.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs index 984b3cf3a4..7d2c1fe6d6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Microsoft/Extensions/DependencyInjection/AbpOpenIdConnectExtensions.cs @@ -37,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) => {