You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
664 B

  1. using Microsoft.AspNetCore.Http;
  2. using System.Security.Claims;
  3. using System.Threading.Tasks;
  4. namespace Ordering.FunctionalTests.Base
  5. {
  6. class AutoAuthorizeMiddleware
  7. {
  8. private readonly RequestDelegate _next;
  9. public AutoAuthorizeMiddleware(RequestDelegate rd)
  10. {
  11. _next = rd;
  12. }
  13. public async Task Invoke(HttpContext httpContext)
  14. {
  15. var identity = new ClaimsIdentity("cookies");
  16. identity.AddClaim(new Claim("sub", "9e3163b9-1ae6-4652-9dc6-7898ab7b7a00"));
  17. httpContext.User.AddIdentity(identity);
  18. await _next.Invoke(httpContext);
  19. }
  20. }
  21. }