Skip to content

Instantly share code, notes, and snippets.

@RGBKnights
Last active January 6, 2020 14:47
Show Gist options
  • Save RGBKnights/2bd3a411c63766fdbdac3abd3b58071f to your computer and use it in GitHub Desktop.
Save RGBKnights/2bd3a411c63766fdbdac3abd3b58071f to your computer and use it in GitHub Desktop.
//nuget: System.IdentityModel.Tokens.Jwt
var handler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
var header = AuthenticationHeaderValue.Parse(req.Headers["Authorization"]);
var token = handler.ReadJwtToken(header.Parameter);
var identity = new ClaimsIdentity(token.Claims, header.Scheme);
req.HttpContext.User = new ClaimsPrincipal(identity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment