hen*_*gst 7 asp.net authentication webforms openid-connect identityserver4
我有一个旧的多租户 WebForms 应用程序,其中用户使用表单身份验证进行身份验证。我们正在将 auth 系统迁移到 IdentityServer4,但不能一次全部完成,因此我们希望逐步将其介绍给我们的租户。这意味着我们需要同时使用 Forms Auth 和新的 OpenIdConnect Auth 运行 WebForms 应用程序。
我的问题是,每当我运行时HttpContext.Current.GetOwinContext().Authentication.Challenge(),我都会被重定向到Login.aspx:
<authentication mode="Forms">
<forms name="AuthCookieName" loginUrl="~/Login.aspx" timeout="60" protection="All" requireSSL="true" enableCrossAppRedirects="true" />
</authentication>
Run Code Online (Sandbox Code Playgroud)
我想要的是,每当有人导航到 时/OIDC.aspx,挑战都会将用户重定向到使用 OWIN 配置的 IdentityServer。对于所有其他请求,现有的 Forms 身份验证配置可以处理身份验证。
这是可能吗?
我设法通过Response.SuppressFormsAuthenticationRedirect在调用身份验证质询时设置标志来防止不需要的重定向,例如:
HttpContext.Current.Response.SuppressFormsAuthenticationRedirect = true;
HttpContext.Current.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties { RedirectUri = "/Home.aspx" });
Run Code Online (Sandbox Code Playgroud)
HttpContext.Current.GetOwinContext().Authentication.Challenge()将针对默认安全方案进行身份验证质询 - 在本例中,您的是 Forms Auth。您可以传入一个字符串,表示在挑战中使用什么安全方案,如下所示HttpContext.Current.GetOwinContext().Authentication.Challenge(OpenIdConnectAuthenticationDefaults.AuthenticationType)
| 归档时间: |
|
| 查看次数: |
1942 次 |
| 最近记录: |