我刚刚把我的网站在蔚蓝和我有一些麻烦的用户声明。
我想创建用户的特殊访问权限,他们来自我的azure active目录中的一个特殊组,当我在localhost上对我的网站进行编码时,我这样做:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseKentorOwinCookieSaver();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
CookieSecure = CookieSecureOption.Always,
ExpireTimeSpan = System.TimeSpan.FromMinutes(15),
SlidingExpiration = true,
CookieHttpOnly = true
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthorizationCodeReceived = context =>
{
if(context.AuthenticationTicket.Identity.Claims.Any(x => x.Type == "groups" && x.Value == "587642-sff4-f4c0-8085-ssdfe45d87ed"))
{
context.AuthenticationTicket.Identity.AddClaim(new Claim("roles","Admin"));
}
else
{
context.AuthenticationTicket.Identity.AddClaim(new Claim("roles", "User"));
}
return Task.FromResult(0);
}
}
});
}
如果用户在组中,他会得到"Admin“的声明,如果不是,他就会得到”用户“。
在本地主机上,它工作得很好,但是现在我把它放到Azure上,它不再在"Admin“声明中了,只给用户声明.
谁能解释一下这个问题是从哪里来的?
提前谢谢!
编辑:我做了一些测试,看起来应用程序没有在context.AuthenticationTicket.Identity.Claims
中找到组或值(587642-sff4-f4c0-8085-ssdfe45d87ed)。
发布于 2016-05-20 13:17:54
尝试注销您的索赔,特别是在索赔中存在哪些组。否则:您是否可以访问多个AAD租户?也许你在云里的时候找错了房客。
https://stackoverflow.com/questions/37347517
复制相似问题