Claims loading in ASP.NET Core + Windows Auth
Based on: https://philipm.at/2018/aspnetcore_claims_with_windowsauthentication.html
and https://philipm.at/2021/cached_claims.html.
- Run the app;
- Navigate to https://localhost:44323/Home/Yes ;
- The response should read "{YourDomain\YourUserName}: Has cheezeburger!".
Can always access https://localhost:44323/Home/No for a claim that is never set.
Also:
The claims transformation is performed on each page load.
- Put a breakpoint in
MyClaimsLoader
line 31 (if (await ...)
); - Reload https://localhost:44323/Home/Yes ;
- When the breakpoint hits, move the next line to the return (avoids setting the claim);
- The page should respond with status 403 (Forbidden).
The claims are loaded only once per browser "session" (not ASP.NET Core session).
- Change
MagicPowersInfoProvider
to returnfalse
; - Redeploy; close all browser windows or use a different browser;
- Access https://localhost:44323/Home/Yes ;
- The page should now respond with status 403 (Forbidden).