【发布时间】:2022-11-03 01:35:17
【问题描述】:
我们使用 .Net Core 6、ITfoxtec 框架 (https://www.itfoxtec.com/identitysaml2) 和 Azure AD Enterprise 应用程序实现了 SSO。一切都按预期工作,注销时我们使用以下代码,从 Microsoft 帐户注销用户,结果用户也从其他应用程序注销,我们可以仅注销特定 Azure AD 企业应用程序的用户吗?
[HttpPost("Logout")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout()
{
if (!User.Identity.IsAuthenticated)
{
return Redirect(Url.Content("~/"));
}
var binding = new Saml2PostBinding();
var saml2LogoutRequest = await new Saml2LogoutRequest(config, User).DeleteSession(HttpContext);
return **binding.Bind(saml2LogoutRequest).ToActionResult();** /* logged out from Microsoft application */
}
var saml2LogoutRequest = 等待新的 Saml2LogoutRequest(config, User).DeleteSession(HttpContext); 按预期删除 cookie,我们的应用程序没有自定义登录页面,只要用户点击网页,它就会将用户重定向到登录,并且由于 Azure AD 会话仍然处于活动状态,它会在主页上登陆用户。我们想要的是,一旦用户从应用程序注销并再次点击网页,它应该要求选择 Microsoft 帐户登录。
[Route("Login")]
public IActionResult Login(string returnUrl = null)
{
var binding = new Saml2RedirectBinding();
binding.SetRelayStateQuery(new Dictionary<string, string>
{ { relayStateReturnUrl, returnUrl ?? Url.Content("~/") } });
return binding.Bind(new Saml2AuthnRequest(config)).ToActionResult();
}
以下是 Azure AD Enterprise 应用程序 SAML 配置
【问题讨论】:
标签: c# asp.net-mvc itfoxtec-identity-saml2