Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ public class ProcessRequestContextHandler
: IOpenIddictServerHandler<OpenIddictServerEvents.ProcessRequestContext>, IOpenIddictValidationHandler<OpenIddictValidationEvents.ProcessRequestContext>
{
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"];
Copy link
Copy Markdown
Contributor Author

@Migaroez Migaroez Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like we need to store this string in a const/configuration as we should not need it outside of this class even though it feels like a magic string.

}

public ValueTask HandleAsync(OpenIddictServerEvents.ProcessRequestContext context)
Expand Down Expand Up @@ -48,6 +49,14 @@ private bool SkipOpenIddictHandlingForRequest()
return false;
}

return requestPath.StartsWith(_backOfficePathSegment) is false;
foreach (var path in _pathsToHandle)
{
if (requestPath.StartsWith(path))
{
return false;
}
}

return true;
}
}