[Fixes #1583] Add authorization to the default Identity UI
This commit is contained in:
parent
d968fdd31f
commit
5079f708e1
|
|
@ -3,7 +3,7 @@
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:28248/",
|
"applicationUrl": "http://localhost:51567/",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.AspNetCore.StaticFiles;
|
using Microsoft.AspNetCore.StaticFiles;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,8 @@ namespace Microsoft.AspNetCore.Identity.UI
|
||||||
IPostConfigureOptions<StaticFileOptions>,
|
IPostConfigureOptions<StaticFileOptions>,
|
||||||
IPostConfigureOptions<CookieAuthenticationOptions>
|
IPostConfigureOptions<CookieAuthenticationOptions>
|
||||||
{
|
{
|
||||||
|
private const string IdentityUIDefaultAreaName = "Identity";
|
||||||
|
|
||||||
public IdentityDefaultUIConfigureOptions(IHostingEnvironment environment)
|
public IdentityDefaultUIConfigureOptions(IHostingEnvironment environment)
|
||||||
{
|
{
|
||||||
Environment = environment;
|
Environment = environment;
|
||||||
|
|
@ -30,6 +33,8 @@ namespace Microsoft.AspNetCore.Identity.UI
|
||||||
options = options ?? throw new ArgumentNullException(nameof(options));
|
options = options ?? throw new ArgumentNullException(nameof(options));
|
||||||
|
|
||||||
options.AllowAreas = true;
|
options.AllowAreas = true;
|
||||||
|
options.Conventions.AuthorizeAreaFolder(IdentityUIDefaultAreaName, "/Account/Manage");
|
||||||
|
options.Conventions.AuthorizeAreaPage(IdentityUIDefaultAreaName, "/Account/Logout");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostConfigure(string name, StaticFileOptions options)
|
public void PostConfigure(string name, StaticFileOptions options)
|
||||||
|
|
@ -58,9 +63,9 @@ namespace Microsoft.AspNetCore.Identity.UI
|
||||||
|
|
||||||
if (string.Equals(IdentityConstants.ApplicationScheme, name, StringComparison.Ordinal))
|
if (string.Equals(IdentityConstants.ApplicationScheme, name, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
options.LoginPath = "/Identity/Account/Login";
|
options.LoginPath = $"/{IdentityUIDefaultAreaName}/Account/Login";
|
||||||
options.LogoutPath = "/Identity/Account/Logout";
|
options.LogoutPath = $"/{IdentityUIDefaultAreaName}/Account/Logout";
|
||||||
options.AccessDeniedPath = "/Identity/Account/AccessDenied";
|
options.AccessDeniedPath = $"/{IdentityUIDefaultAreaName}/Account/AccessDenied";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue