Allow customizing AccessDeniedPath through IdentityServerOptions #293
-
I would like to be able to configure It could be a In my scenario I have custom pages that require specific user permissions and therefore users can be redirected to the access denied page by trying to access these pages without sufficient permissions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @alexax578 ! The call to the You could implement a custom // Register ConfigureIdentityServerCookieOptions
builder.Services.AddSingleton<IConfigureOptions<CookieAuthenticationOptions>, ConfigureIdentityServerCookieOptions>();
// ConfigureIdentityServerCookieOptions
public class ConfigureIdentityServerCookieOptions : IConfigureNamedOptions<CookieAuthenticationOptions>
{
public void Configure(CookieAuthenticationOptions options)
{
}
public void Configure(string name, CookieAuthenticationOptions options)
{
// Note: When using Duende IdentityServer *without* ASP.NET Identity,
// use IdentityServerConstants.DefaultCookieAuthenticationScheme here
//
// When using ASP.NET Identity, use IdentityConstants.ApplicationScheme
if (name == ...)
{
options.AccessDeniedPath = "/Custom/AccessDenied";
}
}
} |
Beta Was this translation helpful? Give feedback.
Hi @alexax578 ! The call to the
builder.Services.AddIdentityServer()
extension method configuresCookieAuthenticationOptions
, but you could useIConfigureOptions
to update the configuration.You could implement a custom
IConfigureNamedOptions
to update configuration for this scheme: