Skip to content

Instantly share code, notes, and snippets.

@StephanyBatista
Last active November 4, 2017 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanyBatista/d1dde004224f0bf8ba1093a021e2b3d7 to your computer and use it in GitHub Desktop.
Save StephanyBatista/d1dde004224f0bf8ba1093a021e2b3d7 to your computer and use it in GitHub Desktop.
[Route("api/[controller]")]
public class TokenController : Controller
{
[HttpPost]
public IActionResult Post([FromBody]LoginModel loginModel)
{
if (loginModel.Username != "stephany" && loginModel.Password != "batista")
return Unauthorized();
var token = new JwtTokenBuilder()
.AddSecurityKey(JwtSecurityKey.Create("a-password-very-big-to-be-good"))
.AddSubject("Stehany Batista")
.AddIssuer("stephanybatista.com")
.AddAudience("stephanybatista.com")
.AddNameId("salmeidabatista@gmail.com")
.AddClaim("employeer", "31")
.AddExpiry(1)
.Build();
return Ok(token);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment