【发布时间】:2024-01-19 03:07:01
【问题描述】:
我正在尝试编写我的第一个启用 ADFS 的 ASP.Net Web 应用程序。该应用程序在我的本地计算机上托管时运行良好,但是当我将其发布到位于 SSL 代理后面的 IIS 时,我的应用程序最终会将经过身份验证的用户重定向到应用程序的 http 地址,而不是 https 地址。我该如何解决这个问题?
为了阐明流程在哪里发生故障,以下是正在发生的事情:
- 未经身份验证的用户浏览到应用主页并被重定向到 Idp [good]
- 用户在 Idp 进行身份验证,令牌通过 https POST 发送回我的应用 [good]
- 我的应用程序分配了一个 cookie,并将用户重定向到 http 主页 [糟糕]
在我的 Startup.Auth.cs 中,我只是使用样板代码:
public partial class Startup
{
private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
private static string adfsMetadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = realm,
MetadataAddress = adfsMetadata
});
}
}
我已经阅读了几篇关于 ssl 代理背后的身份/身份验证的类似问题的帖子,而对 assign a custom CookieAuthenticationProvider 的建议对我没有任何影响。我猜是因为重定向是由 ws-fed 中间件而不是 cookie 提供者执行的。
【问题讨论】:
-
您的代理是否终止 SSL?
-
第一页用户踩到https了吗?
-
是的,代理终止 SSL 并在代理和应用服务器之间使用纯 HTTP。所有页面(包括第一页)都通过 HTTPS 提供给用户。
标签: asp.net owin adfs ws-federation