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

OnAuthenticationFailed should be called when the OIDC authorization request returns an error #1178

Closed
danroth27 opened this issue Apr 13, 2017 · 8 comments

Comments

@danroth27
Copy link
Member

When I make an OIDC authorization request and the response is an error (ex. a post back with an error property) I expect the OnAuthenticationFailed event to be fired so that I can see the protocol message and potentially handle the event. Currently I have to handle this case using the OnRemoteFailure event, which only gives you the failure exception, and not the actual protocol message details.

I ran into this trying to port some Azure AD B2C sample code from Katana to ASP.NET Core. When you try to reset your password with Azure AD B2C you get back an error response with a particular error code in the error description that you need to handle. It's a bit ugly to do that with the OnRemoteFailure event.

@Eilon Eilon added this to the 2.0.0 milestone Jun 15, 2017
@Eilon
Copy link
Contributor

Eilon commented Jun 15, 2017

@Tratcher let's take a look at this for 2.0.0.

@brockallen
Copy link

IIRC there's another similar issue already open related to this // @Tratcher

@Tratcher
Copy link
Member

@brockallen #884 ?

@brockallen
Copy link

Actually, this is the one I was thinking of: #1188

@Tratcher
Copy link
Member

Tratcher commented Jul 6, 2017

Offline discussion: how can we flow information into OnRemoteFailure in a more structured way? #1188 asks for the auth properties. @danroth27 is asking for the structured failure response. Right now the failures are rendered as an exception message:

if (!StringValues.IsNullOrEmpty(error))

return new OpenIdConnectProtocolException(string.Format(

Note Twitter uses OAuth1a and doesn't even have this level of structure to its errors.

@brockallen
Copy link

There are several places where just throwing is not really helpful. One big one is in the JwtSecurityTokehNalder itself -- what a bad design. I don't know/recall if the OIDC MW suppresses that exception, but it'd be nice for it to.

So, then, how about an "ErrorPageUrl", akin to how the cookie MW has login and access denied path properties to redirect the user to? As for capturing the error info, another all purpose error event seems like an idea.... but yikes, that's a lot of events.

@Tratcher
Copy link
Member

Tratcher commented Jul 7, 2017

@brockallen Yes, OIDC and JWT middleware capture the JwtSecurityTokenHandler exceptions and raise them to the events. What happens from there still needs work as you suggest. The error page url is something I've considered, but it's not clear that we can flow any useful details there, nor is the page even likely to exist unless we add it to templates.

@Eilon
Copy link
Contributor

Eilon commented Feb 8, 2018

Closing because this hasn't come up a whole lot recently. There are some ways to handle these types of failures, though they're not ideal.

@Eilon Eilon closed this as completed Feb 8, 2018
@Eilon Eilon added the wontfix label Feb 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants