Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. var claims = new List<Claim>
  2. {
  3. new Claim(ClaimTypes.Name, "SomeUserName")
  4. // ... other stuffs
  5. };
  6.  
  7. var claimsIdentity = new ClaimsIdentity(
  8. claims, CookieAuthenticationDefaults.AuthenticationScheme);
  9.  
  10. var authProperties = new AuthenticationProperties();
  11.  
  12. var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
  13.  
  14. await HttpContext.SignInAsync(
  15. CookieAuthenticationDefaults.AuthenticationScheme,
  16. claimsPrincipal,
  17. authProperties);
  18.  
  19. services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
  20. .AddCookie(options =>
  21. {
  22. options.Cookie.SameSite = SameSiteMode.None;
  23. options.EventsType = typeof(CustomCookieAuthenticationEvents);
  24. });
  25.  
  26. // ...
  27. app.UseAuthentication();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement