dotnet / dotnet/aspnetcore

OpenIdConnectHandler - Design for override

Open
#10,564 6 comments 0 reactions 0 assignees View on GitHub
area-auth
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is your feature request related to a problem? Please describe.
I'm trying to augment the standard OpenId/Connect handler to configure additional information in the OIDC challenge and expose additional events for specific Auth failure reasons.

I want to subclass the existing OpenIdConnect handler but I'm have issues with getting access to some private variables, getting hooks for configuring the OpenIdConnect protocol message prior to raising events, and the hardcoding of the Options type into the base RemoteAuthenticationHandler class.

### Describe the solution you'd like
Create an open generic OpenIdConnectHandler that has an OpenIdConnectOptions type constraint.
Refactor the current OpenIdConnectHandler to close the new generic over the existing OpenIdConnectOptions.

Expose the OpenIdConnectConfiguration private variable to protected scope

Add virtual methods to allow configuring/creation of the OpenIdConnect protocol messages BEFORE invoking the RedirectToIdentityProvider event

Allow setting of the JSON parsing settings ( JObject or JsonDocument ) instead of calling the overload of Parse without settings

Allow a way of Removing default claim actions added in the OpenIdConnectOptions constructor, we have to clear and duplicate the actions just because I want some of the OpenId claims ( specifically AMR ) to be available to the OpenId client's system.

### Describe alternatives you've considered
I created a new set of classes inheriting from RemoteAuthenticationHandler, but creating an internal OpenIdConnect handler and routing the HandleChallengeAsync, HandleRemoteAuthenticateAsync, and SignOutAsync from the outer handler to the inner OpenIdConnect handler.
I'm getting significant friction with the way the Events property is created (InitializeEventsAsync) to coordinate the Events instance between the 2 handlers

### Additional context
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.