我正在使用Adal与Azure Active Directory,需要通过自定义OwinMiddleware添加额外的声明。
当我向此主体添加声明时,我可以在当前请求中访问它们。但是在页面刷新后,该声明就会消失。
我认为Owin处理声明的序列化并将其放入cookie中,但事实并非如此。
我按以下方式添加声明:
var claimsIdentity = (ClaimsIdentity) ClaimsPrincipal.Current.Identity;
if (!claimsIdentity.IsAuthenticated) return;
var identity = new ClaimsIdentity(claimsIdentity);
var currentTenantClaim = GetTenantClaim();
if (currentTenantClaim != null)
claimsIdentity.RemoveClaim(currentTenantClaim);
claimsIdentity.AddClaim(new Claim(ClaimTypes.CurrentTenantId, id));
context.Authentication.AuthenticationResponseGrant = new AuthenticationResponseGrant
(new ClaimsPrincipal(identity), new AuthenticationProperties {IsPersistent = true});
任何有关如何将新的索赔记录到cookie中的想法?
context
对象是什么类型? - joym8