From c48490bf13e654f92f5fd503ec8f5f72cc1c03e4 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Mon, 5 Aug 2024 11:11:56 +0200 Subject: [PATCH] OpenIddict needs to process the /.well-known/openid-configuration url to be able to return the data. (#16845) --- .../ProcessRequestContextHandler.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Cms.Api.Common/DependencyInjection/ProcessRequestContextHandler.cs b/src/Umbraco.Cms.Api.Common/DependencyInjection/ProcessRequestContextHandler.cs index c680ab6b34..21776b740f 100644 --- a/src/Umbraco.Cms.Api.Common/DependencyInjection/ProcessRequestContextHandler.cs +++ b/src/Umbraco.Cms.Api.Common/DependencyInjection/ProcessRequestContextHandler.cs @@ -10,14 +10,15 @@ public class ProcessRequestContextHandler : IOpenIddictServerHandler, IOpenIddictValidationHandler { private readonly IHttpContextAccessor _httpContextAccessor; - private readonly string _backOfficePathSegment; + private readonly string[] _pathsToHandle; public ProcessRequestContextHandler(IHttpContextAccessor httpContextAccessor) { _httpContextAccessor = httpContextAccessor; - _backOfficePathSegment = Constants.System.DefaultUmbracoPath.TrimStart(Constants.CharArrays.Tilde) + var backOfficePathSegment = Constants.System.DefaultUmbracoPath.TrimStart(Constants.CharArrays.Tilde) .EnsureStartsWith('/') .EnsureEndsWith('/'); + _pathsToHandle = [backOfficePathSegment, "/.well-known/openid-configuration"]; } public ValueTask HandleAsync(OpenIddictServerEvents.ProcessRequestContext context) @@ -48,6 +49,14 @@ public class ProcessRequestContextHandler return false; } - return requestPath.StartsWith(_backOfficePathSegment) is false; + foreach (var path in _pathsToHandle) + { + if (requestPath.StartsWith(path)) + { + return false; + } + } + + return true; } }