Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Can't perform custom error handling using OpenIdConnect OnAuthenticationFailed event  #884

@dstrockis

Description

@dstrockis

I couldn’t figure out how to get the OnAuthenticationFailed event to work how I wanted it to. My goal was to catch any exceptions that occurred during the auth pipeline & redirect to my own custom error page with information about the exception – the code is here: https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect-aspnetcore/blob/master/WebApp-OpenIDConnect-DotNet/Startup.cs#L78-83

When I call HandleResponse() in this event, the OIDC handler still tries to succeed the authentication flow, and subsequently throws an exception when it discovers the auth ticket is null (because some exception occurred during token validation). It succeeds because of the call on this line: https://github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication.OpenIdConnect/OpenIdConnectHandler.cs#L637

I believe if the OnAuthenticationFailed event is invoked, the auth flow should not succeed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions