//[ProducesResponseType(typeof(string), Status200OK)] public IActionResult GenerateJwt() { var claims = new JwtPolicyClaims { UserName = "******", Roles = "administrator" }; var jwt = _jwtHandler.BuildToken(claims); return(Ok(jwt)); }
//[ProducesResponseType(typeof(string), Status200OK)] public IActionResult ValidJwt([FromBody] Req req) { string msg; if (!_jwtHandler.ValidToken(req.Token, out msg)) { return(BadRequest(msg)); } var handler = new JwtSecurityTokenHandler(); var jwtToken = handler.ReadToken(req.Token) as JwtSecurityToken; var claims = new JwtPolicyClaims { UserName = jwtToken.Claims.First(claim => claim.Type == "UserName").Value, Roles = jwtToken.Claims.First(claim => claim.Type == "Roles").Value }; return(Ok(claims)); }