【问题标题】:ASP.Net Owin Authentication.SignOut not redirecting user via RedirectUri on sign outASP.Net Owin Authentication.SignOut 在注销时不通过 RedirectUri 重定向用户
【发布时间】:2020-09-25 10:01:45
【问题描述】:

-- 下面进行了编辑 - 修改后的问题在底部:

我有一个多租户应用程序,它使用 Azure AD 对用户进行身份验证。

退出时,应用程序似乎忽略了退出过程生命周期中的.RedirectUri 属性。最初退出时,我可以看到应用程序最初在此处正确重定向:

https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri={REDIRECTURI}(以及尾随的 QueryString 变量)。

此过程完成后,应用程序会重定向到以下位置,并且不会重定向回来: https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession

这为用户提供了标准的“用户已注销,最好关闭所有浏览器窗口”。

如何防止最后一次重定向,并确保注销重定向回应用程序?

Dim callbackUrl As String = Request.Url.GetLeftPart(UriPartial.Authority) & Response.ApplyAppPathModifier("~/aservices/logout_response.aspx")
    HttpContext.Current.GetOwinContext().Authentication.SignOut(
        New AuthenticationProperties() With {.RedirectUri = callbackUrl},
        OpenIdConnectAuthenticationDefaults.AuthenticationType,
        CookieAuthenticationDefaults.AuthenticationType)

编辑:这似乎可以通过使用带有LogoutAction="Redirect" 属性集的<asp:LoginStatus> 控件来实现。如何在代码隐藏中复制此行为?

【问题讨论】:

  • 你试过Session.Abandon()这个LoginStatus控件吗?请参考here

标签: asp.net vb.net webforms azure-active-directory owin


【解决方案1】:

来自 cmets 的移动答案,

您需要在这个LoginStatus 控件中尝试Session.Abandon()。请参考here

【讨论】:

    猜你喜欢
    • 2015-05-08
    • 1970-01-01
    • 2018-12-22
    • 2014-11-28
    • 2010-12-26
    • 2015-12-12
    • 1970-01-01
    • 1970-01-01
    • 2022-10-19
    相关资源
    最近更新 更多