ASP.NET身份验证现在基于OWIN中间件,可以在任何基于OWIN的主机上使用.ASP.NET Identity 对System.Web没有任何依赖性.
我有一个AuthorizeAttribute过滤器,我需要获取当前用户并添加一些属性以供操作控制器稍后检索.
问题是我必须使用属于System.Web的HttpContext.对于Owin有没有HttpContext的替代方案?
public class WebApiAuthorizeAttribute : AuthorizeAttribute
{
public override async Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
{
base.OnAuthorization(actionContext);
Guid userId = new Guid(HttpContext.Current.User.Identity.GetUserId());
ApplicationUserManager manager = new ApplicationUserManager(new ApplicationUserStore(new ApplicationDbContext())) { PasswordHasher = new CustomPasswordHasher() };
ApplicationUser user = await manager.FindByIdAsync(userId);
actionContext.Request.Properties.Add("userId", user.LegacyUserId);
}
}
Run Code Online (Sandbox Code Playgroud)
注意:我发现这个问题,似乎是重复的,但要求为NancyFx项目工作的解决方案,这对我来说无效.
我想知道,加密和解密OAuth2中使用的承载令牌和Asp.Net Identity中的代码的内部过程是什么.
一旦服务器收到令牌,它就能够检索UserId,Roles,Claims及其中的所有属性.那么,Bearer令牌如何解密?什么是加密算法和使用的代码?
encryption oauth-2.0 asp.net-web-api asp.net-identity bearer-token
在软件工程中,设计阶段有两个主要概念abstraction,decomposition但我无法得到它们之间的差异?
abstraction ×1
asp.net ×1
bearer-token ×1
c# ×1
encryption ×1
katana ×1
modeling ×1
oauth-2.0 ×1
owin ×1
uml ×1