-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add a feature for accessing the AuthenticateResult #33408
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
Conversation
src/Security/Authorization/Policy/src/Internal/AuthenticationFeatures.cs
Outdated
Show resolved
Hide resolved
src/Security/Authorization/Policy/src/Internal/AuthenticationFeatures.cs
Outdated
Show resolved
Hide resolved
src/Security/Authorization/Policy/src/Internal/AuthenticationFeatures.cs
Outdated
Show resolved
Hide resolved
src/Security/Authorization/Policy/src/AuthorizationMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Security/Authorization/Policy/src/Internal/AuthenticationFeatures.cs
Outdated
Show resolved
Hide resolved
src/Security/Authorization/Policy/src/Internal/AuthenticationFeatures.cs
Outdated
Show resolved
Hide resolved
src/Security/Authorization/Policy/src/Internal/AuthenticationFeatures.cs
Outdated
Show resolved
Hide resolved
You've got a workable setup, time for some tests. |
Should this feature also set here : aspnetcore/src/Security/Authentication/Core/src/AuthenticationMiddleware.cs Lines 66 to 74 in 52eff90
|
@BrennanConroy we talked about this didn't we? Why didn't we do it? It would be nice to have. |
We might have but I don't remember what was said. Main issue is we'll need to write some ugly code in Authorization middleware to check if the |
Authorization can ignore and replace whatever the Authentication did. Authentication only applies to the default auth scheme. |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
@@ -71,6 +72,12 @@ public async Task Invoke(HttpContext context) | |||
{ | |||
context.User = result.Principal; | |||
} | |||
if (result?.Succeeded ?? false) | |||
{ | |||
var authFeatures = new AuthenticationFeatures(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allocations!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't look at the rest of the Auth middleware stuff then 😢
IAuthenticateResult
featureUser
andAuthenticateResult
consistentExpiresUtc
value to ticket properties (easiest property to reason about with multiple schemes)TODO: Add testsFixes #20847