Veikedo

Untitled

Feb 15th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. internal class WsFederationAuthCleanupMiddleware
  2. {
  3.     private readonly RequestDelegate _next;
  4.  
  5.     public WsFederationAuthCleanupMiddleware(RequestDelegate next)
  6.     {
  7.         _next = next ?? throw new ArgumentNullException(nameof(next));
  8.     }
  9.  
  10.     public Task Invoke(HttpContext context, IAuthorizationService authorizationService)
  11.     {
  12.         var request = context.Request;
  13.         // could look for a specific path as well...
  14.         if (request.Query.TryGetValue("wa", out var wa) && wa == "wsignoutcleanup1.0")
  15.         {
  16.             // Your signin scheme probably cookies
  17.             request.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
  18.             return Task.CompletedTask;
  19.         }
  20.  
  21.         return _next(context);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment