Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom RemoteAuthenticationHandler Exceptions #46212

Closed
1 task done
nquandt opened this issue Jan 23, 2023 · 3 comments · Fixed by #47873
Closed
1 task done

Custom RemoteAuthenticationHandler Exceptions #46212

nquandt opened this issue Jan 23, 2023 · 3 comments · Fixed by #47873
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.

Comments

@nquandt
Copy link

nquandt commented Jan 23, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I would like to be able to handle exceptions thrown by AuthenticationHandlers, specifically RemoteAuthenticationHandlers. Generic example. Say something when wrong with authentication and I'd like to clear cookies.

=> Fail(new Exception(failureMessage));

throw new Exception("An error was encountered while handling the remote login.", errorContext.Failure);

Describe the solution you'd like

Either a custom exception type so that we can create middleware to catch

try {
    await next()
catch (AuthenticationHandlerException ex) {
    Do stuff
}

or some way of plugging into the handling of errors.

Additional context

No response

@javiercn javiercn added the area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer label Jan 23, 2023
@Tratcher
Copy link
Member

See here:

var errorContext = new RemoteFailureContext(Context, Scheme, Options, exception)
{
Properties = properties
};
await Events.RemoteFailure(errorContext);

public virtual Task RemoteFailure(RemoteFailureContext context) => OnRemoteFailure(context);

public new RemoteAuthenticationEvents Events

@Tratcher Tratcher added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jan 23, 2023
@ghost
Copy link

ghost commented Jan 23, 2023

Hi @nquandt. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@nquandt
Copy link
Author

nquandt commented Jan 23, 2023

Thanks @Tratcher! This was exactly what I was looking for, I totally missed that.

@nquandt nquandt closed this as completed Jan 23, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 22, 2023
@Tratcher Tratcher linked a pull request May 3, 2023 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants