【发布时间】:2018-10-03 16:14:27
【问题描述】:
场景:Azure 应用程序网关后面的 ASP.net MVC 应用程序
当未经授权的用户尝试访问控制器方法受 Authorize 属性保护的页面时,用户将被重定向到 Azure AD 登录页面。登录后,用户将被重定向到无法访问的应用程序 URL(给出 403),而不是正确的应用程序网关 URL。
当我们使用时登录正常:
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectAuthenticationDefaults.AuthenticationType);
所以问题是:有没有一种好方法可以覆盖 Authorize 属性正在使用的主机名,以便重定向到应用设置中指定的应用网关 URL?
在 startup.auth.cs 内部,我们使用 OpenId Connect 并将重定向 URI 设置为正确的应用程序网关 URL,该 URL 可用于成功进行身份验证,但在用户通过身份验证后仍会重定向到错误的 URL。
Notifications = new OpenIdConnectAuthenticationNotifications()
{
RedirectToIdentityProvider = (context) =>
{
string appBaseUrl = _siteUrl;
context.ProtocolMessage.RedirectUri = appBaseUrl;
【问题讨论】:
标签: c# asp.net asp.net-mvc azure-application-gateway