Add new event to OpenIdConnectEvents to handle specific error scenario
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
## Background and Motivation
In reference to https://github.com/dotnet/aspnetcore/issues/59462, there is a new scenario during OIDC PAR login flow where a configuration would result in an error. The optimal solution would be to add a new OIDC event to the API to make it easier to handle this error.
## Proposed API
In reference to https://github.com/dotnet/aspnetcore/pull/61947, add new event to `OpenIdConnectEvents` class. Event name would be `OnPushAuthorizationFailed`.
## Usage Examples
Example originally documented in https://github.com/dotnet/aspnetcore/pull/61947
```csharp
builder.Services.AddAuthentication(...)
.AddOpenIdConnect("oidc", options =>
{
...
options.Events.OnPushAuthorizationFailed = (ctx) => {
var logger = ctx.HttpContext.RequestServices.GetRequiredService>();
logger.LogError(ctx.Exception, "Received error while sending PAR request.");
ctx.Response.Redirect("FriendlyErrorPage");
ctx.Handled = true;
return Task.CompletedTask;
};
});
```
## Alternative Designs
No. I attempted to follow the existing API event design.
## Risks
No exceptional risks identified.
Contributor guide
Assessment
This issue has not been assessed yet.