diff --git a/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs b/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs index 16c4ac594..d14a54f20 100644 --- a/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs +++ b/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs @@ -126,6 +126,7 @@ public static IIdentityServerBuilder AddDefaultEndpoints(this IIdentityServerBui builder.AddEndpointResultGenerator(); builder.AddEndpointResultGenerator(); builder.AddEndpointResultGenerator(); + builder.AddEndpointResultGenerator(); return builder; } diff --git a/src/IdentityServer/Endpoints/Results/BackchannelAuthenticationResult.cs b/src/IdentityServer/Endpoints/Results/BackchannelAuthenticationResult.cs index 05dce73f0..f44255b0a 100644 --- a/src/IdentityServer/Endpoints/Results/BackchannelAuthenticationResult.cs +++ b/src/IdentityServer/Endpoints/Results/BackchannelAuthenticationResult.cs @@ -12,7 +12,7 @@ namespace Duende.IdentityServer.Endpoints.Results; -internal class BackchannelAuthenticationResult : IEndpointResult +internal class BackchannelAuthenticationResult : EndpointResult { public BackchannelAuthenticationResponse Response { get; set; } @@ -20,14 +20,17 @@ public BackchannelAuthenticationResult(BackchannelAuthenticationResponse respons { Response = response ?? throw new ArgumentNullException(nameof(response)); } +} - public async Task ExecuteAsync(HttpContext context) +internal class BackchannelAuthenticationResultGenerator : IEndpointResultGenerator +{ + public async Task ExecuteAsync(BackchannelAuthenticationResult result, HttpContext context) { context.Response.SetNoCache(); - if (Response.IsError) + if (result.Response.IsError) { - switch (Response.Error) + switch (result.Response.Error) { case OidcConstants.BackchannelAuthenticationRequestErrors.InvalidClient: context.Response.StatusCode = 401; @@ -40,9 +43,10 @@ public async Task ExecuteAsync(HttpContext context) break; } - await context.Response.WriteJsonAsync(new ErrorResultDto { - error = Response.Error, - error_description = Response.ErrorDescription + await context.Response.WriteJsonAsync(new ErrorResultDto + { + error = result.Response.Error, + error_description = result.Response.ErrorDescription }); } else @@ -50,9 +54,9 @@ await context.Response.WriteJsonAsync(new ErrorResultDto { context.Response.StatusCode = 200; await context.Response.WriteJsonAsync(new SuccessResultDto { - auth_req_id = Response.AuthenticationRequestId, - expires_in = Response.ExpiresIn, - interval = Response.Interval + auth_req_id = result.Response.AuthenticationRequestId, + expires_in = result.Response.ExpiresIn, + interval = result.Response.Interval }); } }