public bool IsUserAuthorized(HttpActionContext actionContext) { var authHeader = FetchFromHeader(actionContext); //fetch authorization token from header if (authHeader != null) { var auth = new AuthenticationModule(); JwtSecurityToken userPayloadToken = auth.GenerateUserClaimFromJWT(authHeader); if (userPayloadToken != null) { var identity = auth.PopulateUserIdentity(userPayloadToken); string[] roles = { "All" }; var genericPrincipal = new GenericPrincipal(identity, roles); Thread.CurrentPrincipal = genericPrincipal; var authenticationIdentity = Thread.CurrentPrincipal.Identity as JWTAuthenticationIdentity; if (authenticationIdentity != null && !String.IsNullOrEmpty(authenticationIdentity.UserName)) { authenticationIdentity.UserId = identity.UserId; authenticationIdentity.UserName = identity.UserName; } return(true); } } return(false); }