-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] AccessDenied Routing #117
Comments
as a work around you could specify your page yourself doing the following: public void ConfigureServices(IServiceCollection services)
} |
SpecWhy?See issue above What?When using .AddMicrosoftIdentityUI, we should override the AccessDeniedPath to be "/MicrosoftIdentity/Account/AccessDenied" |
services.AddSignIn(Configuration, "AzureAd"); |
Yes, seems like specifying Specifying the path on services.Configure<CookieAuthenticationOptions>(CookieAuthenticationDefaults.AuthenticationScheme, options => {
options.AccessDeniedPath = new PathString("/MicrosoftIdentity/Account/AccessDenied");
}); The scheme has to be the same as what is passed into microsoft-identity-web/src/Microsoft.Identity.Web/WebAppAuthenticationBuilderExtensions.cs Line 82 in 4458dbf
From logging we can see that when the user is unauthorized and the code above is not used, cookie and OIDC handlers fail and redirect to When the above fix is used, after the handlers fail to authorize, the redirect is made to a correct page. I looked through the ASP.NET Core repo and really the only references to The default path value is in CookieAuthenticationDefaults. If the custom path is not specified, it is set to default in PostConfigureCookieAuthenticationOptions PostConfigure.
|
Thanks for investigating, @pmaytak |
So by default CookieAuthenticationHandler will be called anyway even though if one does not use cookieauthentication scheme explicitly within asp.net core? |
Well the microsoft-identity-web/src/Microsoft.Identity.Web/WebAppAuthenticationBuilderExtensions.cs Line 85 in 35a76fd
I reckon cookie handler will only be called if cookie scheme is enabled. |
Which Version of Microsoft Identity Web are you using ?
Microsoft.Identity.Web - v0.1.0 Preview
Microsoft.Identity.Web.UI - v0.1.0 Preview
Where is the issue?
Is this a new or existing app?
c. This is a new app or experiment
Repro
Clone and run the below sample project.
https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-2-Groups
Log in with an unauthorized account.
Expected behavior
Unauthorized account should be redirected to /MicrosoftIdentity/Account/AccessDenied.
Actual behavior
Unauthorized account is redirected to /Account/AccessDenied which doesn't exist.
Possible Solution
The Microsoft.Identity.Web.UI AccountController exists in the MicrosoftIdentity area but there doesn't seem to be a way to provide the AccessDenied response with this route info.
I'd expect this to be configurable using something like the AccessDenied property like this but it doesn't seem to work.
Possibly this is a redirect URL that should be set in the portal but it's not obvious where this is.
A workaround is to create an account controller with the required view but this goes against the point of Microsoft.Identity.Web.UI.
The text was updated successfully, but these errors were encountered: