Repository navigation
Undocumented breaking change 2.2 -> 3.1? How to get Windows user name in 3.1 (AuthorizationHandler)? #23752
Replies: 8 comments 21 replies
|
Never mind. The behavior change appears to be affected by We've had this set to |
|
Looking into this further, our API has both authenticated and anonymous endpoints. We apply In 3.1 it seems that if Did this behavior change deliberately? Is there a workaround? |
|
I was able to confirm the different behaviour in a pair of brand new projects, one for 2.2 and one for 3.1 Interestingly, I can replicate the 3.1 behaviour (no WindowsIdentity in the AuthorizationHandlerContext) in the 2.2 project by making the following change in becomes: I tried calling |
In 2.2 were you using IIS in-proc or out-of-proc? |
|
The only way I've been able to work around this is by implementing custom middleware to issue a Windows auth challenge explicitly if the route hit is not marked It's based on Alexei's answer here: But it involves basically enumerating all of the |
|
We took a look and we didn't see any behavior differences in 2.2 or 3.1, but we needed to add a fast fail for when the request wasn't authenticated at the top of the authorization handler: That made things work as we expected |
Uh oh!
There was an error while loading. Please reload this page.
We're migrating some 2.2 APIs to 3.1. We have an external service that provides user role information, and we're calling it from a custom
AuthorizationHandler, passing in the name of the Windows domain user, eg:In 2.2,
context.User.Identityis aSystem.Security.Principal.WindowsIdentity, with aNamefor the user.In 3.1
context.User.Identityis aSystem.Security.Claims.ClaimsIdentity, and itsNameis null.What did we screw up in the migration?
All reactions