Created
February 21, 2021 10:19
-
-
Save fmshk97/775df494cf2f23b4564c0190282694fa to your computer and use it in GitHub Desktop.
Configuration for returning appropriate HTTP status codes if user unauthorized
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
services.AddAuthentication(defaultScheme: CookieAuthenticationDefaults.AuthenticationScheme) | |
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => | |
{ | |
options.Events.OnRedirectToAccessDenied = ReplaceRedirector(HttpStatusCode.Forbidden, options.Events.OnRedirectToAccessDenied); | |
options.Events.OnRedirectToLogin = ReplaceRedirector(HttpStatusCode.Unauthorized, options.Events.OnRedirectToLogin); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment