You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
amr claim lost after ClaimPrincipal renewal #44666
amr claim type was added in #10636 and #5783 using the SignInWithClaimsAsync overload on the SignInManager. When the validation interval is hit UserClaimsPrincipalFactory.GenerateClaimsAsync gets called to refresh the ClaimPrincipal claims but the amr claim is lost. Is this by design? We were attempting to put a feature behind 2fa only and using this claim as authorization. If it is suggestions on some possible workarounds? We could add this claim again in our UserClaimsPrincipalFactory. implementation if the user has 2fa enabled with an assumption the user did actually authenticate with it?
Recreation steps
new razor app with indvidual identity
Shorten validation interval so you don't have to wait the default 30 minutes.
So this is somewhat odd. The amr claim is for the specific sign-in that took place. Once you're into GenerateClaimsAsync you're onto user claims, not claims for the login. I don't think you can know for sure at that point whether an amr claim or not is appropriate.
We acknowledge this sucks, and we'll think for 8.0 about if/how we could persist it.
Until a fix is released, can SecurityStampValidatorOptions.OnRefreshingPrincipal handler be used as a workaround? Handler will return lost claims to the game.
We implemented an ITicketStore for the Cookie authentication handler that added several important claims to the claims principal that we require for downstream feature and auditing functionality.
It was unexpected that the security stamp validator would replace the claims principal.
We ended up working from this comment to eventually finding this ticket. Now we have a custom OnRefreshingPrincipal handler that merges claims.
Activity
blowdart commentedon Oct 21, 2022
So this is somewhat odd. The amr claim is for the specific sign-in that took place. Once you're into GenerateClaimsAsync you're onto user claims, not claims for the login. I don't think you can know for sure at that point whether an amr claim or not is appropriate.
We acknowledge this sucks, and we'll think for 8.0 about if/how we could persist it.
reponemec commentedon Apr 3, 2023
Until a fix is released, can SecurityStampValidatorOptions.OnRefreshingPrincipal handler be used as a workaround? Handler will return lost claims to the game.
jherbert commentedon Nov 9, 2023
@reponemec Good suggestion here,
OnRefreshingPrincipalhas both aCurrentPrincipalandNewPrincipalproperty here.anthonymastreanvae commentedon May 27, 2025
We implemented an
ITicketStorefor the Cookie authentication handler that added several important claims to the claims principal that we require for downstream feature and auditing functionality.It was unexpected that the security stamp validator would replace the claims principal.
We ended up working from this comment to eventually finding this ticket. Now we have a custom
OnRefreshingPrincipalhandler that merges claims.https://github.com/dotnet/aspnetcore/blob/v8.0.16/src/Identity/Core/src/SecurityStampValidator.cs#L109