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

Default authentication scheme is excuted when AuthenticationSchemes is set to non-default scheme #27025

Closed
luoxlgh opened this issue Oct 19, 2020 · 4 comments
Labels
area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered.

Comments

@luoxlgh
Copy link

luoxlgh commented Oct 19, 2020

Describe the bug

We have two authentication shemes named "custom1" and "custom2". The code is:

var authBuilder = services.AddAuthentication("custom1");
authBuilder.AddJwtBearer("custom1", options =>
{
    options.EventsType = typeof(Custom1AuthJwtBearerEvents);
});
authBuilder.AddJwtBearer("custom2", );

The controller code is:
[Authorize(AuthenticationSchemes = "custom2")]

The above authentication scheme would run into Custom1AuthJwtBearerEvents, and the authentication result is failed. But the result doesn't affect custom2's authentication result.

To Reproduce

Exceptions (if any)

Further technical details

@blowdart blowdart added the area-auth Includes: Authn, Authz, OAuth, OIDC, Bearer label Oct 19, 2020
@blowdart
Copy link
Contributor

Which version of asp.net are you running?

@blowdart blowdart added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Oct 19, 2020
@luoxlgh
Copy link
Author

luoxlgh commented Oct 20, 2020

Which version of asp.net are you running?

aspnet core 3.1

The authentication result is always correct, but we fount it run into Custom1AuthJwtBearerEvents when debug.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Oct 20, 2020
@blowdart
Copy link
Contributor

This makes sense. The default authentication scheme always runs. The authorization attribute runs other schemes, on top of the default.

You can either not have a default at all, or move the default authentication into the default authorization policy.

@blowdart blowdart added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Oct 22, 2020
@ghost ghost added the Status: Resolved label Oct 22, 2020
@blowdart blowdart removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. Status: Resolved labels Oct 22, 2020
@ghost
Copy link

ghost commented Oct 23, 2020

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Oct 23, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Nov 22, 2020
This issue was closed.
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 ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered.
Projects
None yet
Development

No branches or pull requests

2 participants