public Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { string parameter; if (!GetAuthParameter(context, out parameter)) { return(Task.FromResult(0)); } var data = _container.Get(parameter); if (data == null) { context.ErrorResult = new AuthFailedResult("Unauthorized access", context.Request); return(Task.FromResult(0)); } var claims = new List <Claim>() { new Claim(ClaimTypes.Name, data.Item1.FirstName), new Claim("Permission", data.Item2.Permissions.ToString()) }; var id = new ClaimsIdentity(claims, "Token"); var principal = new ClaimsPrincipal(new[] { id }); context.Principal = principal; return(Task.FromResult(0)); }
public UserDTO GetUser(string token) { return(_authContainer.Get(token).Item1); }