feat(api): аутентификация и авторизация. Кастомные ParrAuthenticationHandler и BaseSimpleRoleProvider.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using Elastic.CommonSchema.Serilog;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Server.HttpSys;
|
||||
using PARR.API.Authentication;
|
||||
using PARR.API.Installers;
|
||||
using PARR.API.RoleProvider;
|
||||
using PARR.BLL;
|
||||
using PARR.DAL;
|
||||
using Serilog;
|
||||
@@ -29,6 +32,12 @@ builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||
builder.Configuration.AddDalConfigurations(builder.Services);
|
||||
builder.Services.AddDallSettings(builder.Configuration);
|
||||
|
||||
// Auth
|
||||
builder.Services.AddAuthentication(ParrAuthenticationOptions.DefaultScheme)
|
||||
.AddScheme<ParrAuthenticationOptions, ParrAuthenticationHandler>(ParrAuthenticationOptions.DefaultScheme, opt => { });
|
||||
builder.Services.AddSimpleRoleAuthorization<BaseSimpleRoleProvider>();
|
||||
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
@@ -44,6 +53,7 @@ var app = builder.Build();
|
||||
// Configure the HTTP request pipeline.
|
||||
app.InstallSwagger();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
Reference in New Issue
Block a user