Skip to content

Instantly share code, notes, and snippets.

Last active Aug 3, 2017
What would you like to do?
public async Task<IActionResult> Login(string username, string password)
if (IsValidUser(username, password))
var claims = new List<Claim>(2);
claims.Add(new Claim(ClaimTypes.Name, username));
claims.Add(new Claim(ClaimTypes.Role, "GroupThatUserIsIn",
ClaimValueTypes.String, "IHaveIssuedThis"));
await HttpContext.SignInAsync(
new ClaimsPrincipal(new ClaimsIdentity(claims,
return RedirectToAction("Index");
return View();
private bool IsValidUser(string username, string password)
return username == "foo" && password == "bar";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment