我对天蓝色,记号之类的东西都很陌生.我“挖掘”了微软的文档,谷歌和堆栈溢出,但仍然没有得到充分的理解。
因此,我使用openId和Owin库连接到web应用程序中的azure (VS2013 .net 4.5.1)。我还有下一个代码要做:
public void Configuration(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(
CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
MetadataAddress = String.Format(aadInstance, tenant, policy),
AuthenticationType = policy,
ClientId = clientId,
RedirectUri = redirectUri,
PostLogoutRedirectUri = redirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = AuthenticationFailed
,SecurityTokenValidated = OnSecurityTokenValidated
,AuthorizationCodeReceived = OnAuthorizationCodeReceived
,SecurityTokenReceived = OnSecurityTokenReceived
},
Scope = "openid profile",
ResponseType = "id_token"
};
);
}
private Task OnSecurityTokenValidated(SecurityTokenValidatedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
{
var identity = notification.AuthenticationTicket.Identity;
var claims = notification.OwinContext.Authentication.User.Claims;
ClaimsPrincipal.Current.AddIdentity(identity);
return Task.FromResult(0);
}这是可行的,但在微软文档中,我发现下一条指令“目前,ID令牌被签名,但没有加密。当应用程序接收到ID令牌时,它必须验证签名以证明令牌的真实性,并验证令牌中的一些声明,以证明其有效性。应用程序验证的声明根据场景要求而有所不同,但应用程序必须在每个场景中执行一些常见的索赔验证。”
但是还有SecurityTokenValidated,它有AuthenticationTicket。那么,我仍然需要以某种方式验证令牌/标记,还是现在它被自动处理了(我在军队中很强硬,没有自动发生的事情,但仍然是这样)?
发布于 2017-08-18 08:35:25
您正在使用的库为您处理验证。
它将检查签名是否应该是基于Azure AD提供的密钥。
因此,除了应用程序的特定检查之外,您不需要进行手动检查。例如,应用程序可能只允许某个组的成员访问应用程序。如果是这样的话,你需要做那个检查。
https://stackoverflow.com/questions/45749838
复制相似问题