Created
January 3, 2018 21:52
-
-
Save BelRarr/de6789ba66c1b92690029ac4b4afc11b to your computer and use it in GitHub Desktop.
Ajout au fichier Startup.auth.cs pour gérer l'exception levée en cas d'authentification refusée
This file contains hidden or 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
app.UseOpenIdConnectAuthentication( | |
new OpenIdConnectAuthenticationOptions | |
{ | |
... | |
Notifications = new OpenIdConnectAuthenticationNotifications() | |
{ | |
// If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away. | |
AuthorizationCodeReceived = (context) => | |
{ | |
... | |
}, | |
AuthenticationFailed = (context) => | |
{ | |
// FR: on construit l'URL de redirection (https://secretplansmark48.azurewebsites.net/Access/Denied/) | |
// EN: we build the URL to redirect to (https://secretplansmark48.azurewebsites.net/Access/Denied/) | |
string url = context.Request.Scheme + "://" + context.Request.Host + "/Access/Denied/"; | |
context.ProtocolMessage.RedirectUri = url; | |
// FR: on force la redirection vers l'URL qu'on a construit | |
// EN: we force the redirect to the URL we've built | |
context.HandleResponse(); | |
context.Response.Redirect(context.ProtocolMessage.RedirectUri); | |
return Task.FromResult(0); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment