Created
July 1, 2020 19:19
-
-
Save srkirkland/431d2480b53d7ab7153cd71fdfabf052 to your computer and use it in GitHub Desktop.
return 403 instead of redirect for API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.AddCookie(cookies => | |
{ | |
cookies.Events.OnRedirectToAccessDenied = ctx => | |
{ | |
if (ctx.Request.Path.StartsWithSegments("/api")) | |
{ | |
ctx.Response.StatusCode = (int)HttpStatusCode.Forbidden; | |
return Task.CompletedTask; | |
} | |
return cookies.Events.OnRedirectToAccessDenied(ctx); | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment