- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 OWIN 中间件进行 cookie 身份验证和 openIdConnect。在我将 openIdConnect 身份验证添加到我的启动身份验证代码和 cookie 身份验证选项之前,LoginPath 被用作重定向未经身份验证的用户的目标。这非常有效,也是我想保留的功能。
但是,当我将 app.UseOpenIdConnectAuthentication 添加到我的项目时,它开始自动将未经身份验证的用户重定向到我的 OpenIdConnect 机构 ( https://login.windows.net/ )。
有没有办法可以禁用 OpenIdConnectAuthentication 为未经身份验证的用户设置重定向路径并依赖为 cookie 身份验证设置的 LoginPath?我当前的解决方法是在我的授权属性中手动设置重定向路径,但如果可能,我希望让 OWIN 中间件处理此问题。
谢谢。
代码:
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
var cookieOptions = new CookieAuthenticationOptions();
cookieOptions.AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie;
cookieOptions.LoginPath = new PathString("/Account/Login");
app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);
app.UseCookieAuthentication(cookieOptions);
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = FranchiseAuthType,
ClientId = franchiseClientId,
Authority = FranchiseAuthority,
PostLogoutRedirectUri = postLogoutRedirectUri,
});
}
最佳答案
我不确定你是否能够解决这个问题,但你想要做的是添加
AuthenticationMode = AuthenticationMode.Passive
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
var cookieOptions = new CookieAuthenticationOptions();
cookieOptions.AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie;
cookieOptions.LoginPath = new PathString("/Account/Login");
app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);
app.UseCookieAuthentication(cookieOptions);
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = FranchiseAuthType,
AuthenticationMode = AuthenticationMode.Passive,
ClientId = franchiseClientId,
Authority = FranchiseAuthority,
PostLogoutRedirectUri = postLogoutRedirectUri,
});
}
关于asp.net-mvc - CookieAuthenticationOptions.LoginPath 值在也使用 app.UseOpenIdConnectAuthentication 时不使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29685857/
我有以下代码: public void ConfigureAuth(IAppBuilder app) { app.UseCookieAuthentication(new
在我的应用程序的 Asp.Net Identity Auth 中间件设置中,我有 app.UseCookieAuthentication(new CookieAuthenticationOptions
我的 MVC 6 ASP.NET 5 项目中有以下设置: 配置方法中的Startup.cs: app.UseCookieAuthentication(options => { options.
我正在使用 1.0.1 版本的 asp.net core 并且在我的表单中使用身份验证。 我使用 UseCookieAuthentication 并给出错误 Cannot convert lambda
在 HttpContext.SignInAsync 和 Microsoft.AspNetCore.Authentication.Cookies 中传递给 Microsoft.AspNetCore.Au
我正在使用 OWIN 中间件进行 cookie 身份验证和 openIdConnect。在我将 openIdConnect 身份验证添加到我的启动身份验证代码和 cookie 身份验证选项之前,Log
在 ASP.NET Core 2.1 中,谁能解释一下 CookieAuthenticationOptions.LogoutPath 的作用?每the documentation它说: If the
我在 .NET MVC 4.5 设置中使用 OWIN 的 cookie 身份验证。我在 Startup.Auth.cs (下面的代码)中设置了 cookie 身份验证配置,并且我想访问我在 Contr
我是一名优秀的程序员,十分优秀!