Create minimal app
This commit is contained in:
parent
6b87902ca7
commit
27aaee6293
17 changed files with 346 additions and 52 deletions
|
@ -16,6 +16,20 @@ builder.Configuration
|
|||
.AddEnvironmentVariables()
|
||||
.AddKeyPerFile("/run/secrets", optional: true);
|
||||
|
||||
|
||||
builder.Services.AddAuthentication(Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddCookie(options =>
|
||||
{
|
||||
options.LoginPath = "/Auth";
|
||||
options.LogoutPath = "/Logout";
|
||||
options.AccessDeniedPath = "/AccessDenied";
|
||||
options.ExpireTimeSpan = TimeSpan.FromMinutes(5);
|
||||
options.SlidingExpiration = true;
|
||||
});
|
||||
builder.Services.AddAuthorizationBuilder()
|
||||
.AddPolicy("AdminOnly", policy => policy.RequireRole("Admin"))
|
||||
.AddPolicy("UserOrAdmin", policy => policy.RequireRole("User", "Admin"));
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
|
@ -73,6 +87,7 @@ app.UseStaticFiles();
|
|||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapRazorPages();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue