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 |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
In 2.2 were you using IIS in-proc or out-of-proc? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@Tratcher @HaoK Anything else I'm missing here? This is the last thing holding up our migration to 3.1 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
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.Identity
is aSystem.Security.Principal.WindowsIdentity
, with aName
for the user.In 3.1
context.User.Identity
is aSystem.Security.Claims.ClaimsIdentity
, and itsName
is null.What did we screw up in the migration?
Beta Was this translation helpful? Give feedback.
All reactions