【问题标题】:SSO logout from Microsoft Account ever where, is it possible to logout only for specific Azure AD Enterprise application?从 Microsoft 帐户的 SSO 注销,是否可以仅注销特定的 Azure AD Enterprise 应用程序?
【发布时间】: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


    【解决方案1】:

    据我所知,Azure Enterprise 应用程序中的 SAML 2.0 注销会导致单次注销,包括注销所有内容。恐怕我只注销了一个应用程序并没有成功。

    【讨论】:

      【解决方案2】:

      我遇到了这个, Log a user out of a SP but not IDP 和 @Anders Revsgaard 回答说 SAML 2.0 不支持仅从特定应用程序注销,另一种方法是强制 IDP 重新验证,

      一旦用户从我们的应用程序中注销,删除将使用户会话无效的用户会话,现在当用户下次尝试访问他必须重新输入 SSO 凭据的页面时,我们从注销方法中删除了binding.Bind(saml2LogoutRequest).ToActionResult();

      `[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) {
                      ForceAuthn = true,
                  }).ToActionResult();
      }`
      
      [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 Redirect("~/Logout");
      }    
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-18
        • 2020-06-05
        • 1970-01-01
        • 2022-01-09
        • 1970-01-01
        • 1970-01-01
        • 2021-01-02
        • 1970-01-01
        相关资源
        最近更新 更多