asp.net OwinContext 身份验证

asp.net OwinContext Authentication

OwinContext 有一个 属性 调用类型为 IAuthenticationManager 的身份验证,如何使用我实现的 class 而不是默认实现来设置此 属性。 我进行了搜索和搜索,但没有找到任何可以帮助我的信息…… 谢谢

希望这就是您正在寻找的使用 OwinContext 的自定义身份验证。

https://www.jamessturtevant.com/posts/ASPNET-Identity-Custom-Database-and-OWIN/

只是一个想法,尚未得到证实 - Ypu 可以在 Startup.Auth.cs:

中编辑 Owin 管道配置
public void Configure(IAppBuilder app)
 {
     _container = new Container();
     _container.Register<IAuthenticationManager>(customAuthMgrInstance ); 
 }

我假设它将替换 OwinContext 的 AuthenticationManager 依赖项。请尝试让我知道,如果可以的话。无法自己尝试,因为我面前没有足够的资源。

经过大量测试,我找出了问题所在。在 owin 身份验证启动时,我有以下代码 app.UseCookieAuthentication(新的 CookieAuthenticationOptions { ..... CookieSecure = CookieSecureOption.Always ..... }

因为所有请求都在 http 而不是 https 中,所以 cookie 在登录后不会保留。 将枚举更改为 SameAsRequest,解决了问题。