【发布时间】: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