gpt4 book ai didi

c# - Owin 使用外部表单例份验证 cookie

转载 作者:行者123 更新时间:2023-11-30 14:54:47 26 4
gpt4 key购买 nike

所以我认为我的问题是我有一个使用标准表单例份验证的 MVC 网站和一个更适合 ASP.NET Identity 的 MVC。

我想做的是配置我的 Owin 身份验证以读取并接受由标准 MVC 表单例份验证站点生成的身份验证 cookie。一切都配置如下,但我似乎无法让 Owin 接受 cookie。

app.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ExternalCookie);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
AuthenticationMode = AuthenticationMode.Active,
LoginPath = new PathString("/Account/Login"),
CookieHttpOnly = true,
CookieName = "myAuthCookie",
CookieDomain = ".mydomain.com",
CookiePath = "/",
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});

最佳答案

你想要完成的事情是不可能的。 Cookie 身份验证中间件是基于声明的,它将所有与身份关联的声明序列化到 cookie 中的身份验证票证中。表单例份验证存储用户名和一些附加数据,但它对声明一无所知。基本上,放置在 cookie 中的身份验证票在这两种情况下是完全不同的,您将无法让 cookie 身份验证中间件读取 FAM 创建的票,反之亦然。

关于c# - Owin 使用外部表单例份验证 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26903856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com