我已经搜索了,但是找不到我的问题的答案。
我目前有多个使用OWIN OpenIdConnect身份验证的asp.net应用程序。这些应用程序使用的是较早版本的asp.net,因此必须使用Owin。初始登录正确重定向到Azure AD,并获得jwt令牌。我的问题是,当我的用户切换应用程序时,它们共享访问令牌,不需要再次登录。虽然我喜欢SSO的便利性,但我希望应用程序能够再次触发身份验证,以便可以在Azure日志中看到用户切换应用程序的情况。
我尝试将Cookie名称更改为其他名称。我还尝试验证了仅引发未经身份验证的异常并且不会转发进行重新身份验证的受众。
这是我的代码
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
CookieName = $"{tenantId}{clientId}"
})
.UseOpenIdConnectAuthentication(GetAuthenticationOptions(clientId, tenantId, clientSecret));
private static OpenIdConnectAuthenticationOptions GetAuthenticationOptions(string clientId, string tenantId, string clientSecret)
{
return new OpenIdConnectAuthenticationOptions
{
MetadataAddress = string.Format("https://login.microsoftonline.com/{0}/.well-known/openid-configuration", tenantId),
ClientId = clientId,
ClientSecret = clientSecret,
ResponseType = "id_token token",
Resource = "https://graph.microsoft.com",
UseTokenLifetime = true,
AuthenticationMode = AuthenticationMode.Active,
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = SecurityTokenValidated
},
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "mailNickName",
}
};
}
我希望每个应用程序都可以管理自己的身份验证会话。