Расширил жизнь bearer токена
This commit is contained in:
parent
7d4edb6caa
commit
25fc0701e1
@ -3,6 +3,8 @@ using HackathonPreparing.ApiService.Features.AuthFeature.EfCore;
|
|||||||
using HackathonPreparing.ApiService.Features.DevFeature;
|
using HackathonPreparing.ApiService.Features.DevFeature;
|
||||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature;
|
using HackathonPreparing.ApiService.Features.WeatherForecastFeature;
|
||||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
using HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||||
|
using Microsoft.AspNetCore.Authentication.BearerToken;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
// using HackathonPreparing.ServiceDefaults;
|
// using HackathonPreparing.ServiceDefaults;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
@ -40,11 +42,14 @@ builder.Services.AddSwaggerGen(c =>
|
|||||||
|
|
||||||
builder.Services.AddAuthorization();
|
builder.Services.AddAuthorization();
|
||||||
builder.Services.AddAuthentication().AddBearerToken();
|
builder.Services.AddAuthentication().AddBearerToken();
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddIdentityApiEndpoints<User>()
|
.AddIdentityApiEndpoints<User>()
|
||||||
.AddEntityFrameworkStores<UserContext>();
|
.AddEntityFrameworkStores<UserContext>();
|
||||||
|
|
||||||
|
builder.Services.AddOptions<BearerTokenOptions>(IdentityConstants.BearerScheme).Configure(options => {
|
||||||
|
options.BearerTokenExpiration = TimeSpan.FromDays(2);
|
||||||
|
});
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddProblemDetails();
|
builder.Services.AddProblemDetails();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user