我在哪里可以扩展ASP.NET current(5.0)Identity功能,以轻松解决与声明相关的整数用户ID和安全权限?这应该在我的所有Web应用程序浏览器服务访问点(提供cookie或JWT的所有位置)中可用,包括SignalR hub,MVC控制器和WebAPI控制器 . 它应该与OWIN身份验证一起使用 .

如果我在这里错过了答案,请道歉 . 我知道有很多关于它的帖子,但我没有看到任何似乎回答当前的问题 . 以下是我见过的三个最相关的解决方案,以及它们不起作用的原因:

通过global.asax Application_PostAuthenticateRequest 在每次调用中设置 HttpContext.Current.User . 我've seen older (MVC 4) functionality that obsoletes this. I know global.asax is generally not the way to go today. I'也在使用OWIN;这可能根本不起作用 .

使用配置 <system.identityModel><identityConfiguration><claimsAuthenticationManager type = "CustomClaimsAuthenticatonManager" /> 覆盖 ClaimsPrincipal ClaimsAuthenticationManager.Authenticate() 但是, ClaimsAuthenticationManager 来自 System.Identity ,它甚至不在我的ASP.NET 5.0项目的引用中,并且 ClaimsAuthentication 处于活动状态 . 相反,我从当前的NuGet包中引用了我的项目中的 Microsoft.AspNet.Identity.Core 个东西 . 看来这种方法不适用于ASP.NET应用程序,或者至少不适用于当前的应用程序?

UserManager.ClaimsIdentityFactory 设置为自定义 ClaimsIdentityFactory ,并覆盖 CreateAsync . 这看起来可能有用,但我没有看到任何方法将其移植到当前的ASP.NET默认行为上 . 看这里:How to set a custom ClaimsPrincipal in MVC 5?