feat(api): add refresh endpoint and update global usings
This commit is contained in:
@@ -1,19 +1,41 @@
|
||||
using FiscalOS.Infra.Authentication;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddValidation();
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddInfrastructure();
|
||||
|
||||
builder.Services.AddAuthentication(static o =>
|
||||
{
|
||||
o.DefaultAuthenticateScheme = Schemes.Default;
|
||||
o.DefaultChallengeScheme = Schemes.Default;
|
||||
})
|
||||
.AddJwtBearer(Schemes.Default)
|
||||
.AddJwtBearer(Schemes.AllowExpiredTokens);
|
||||
|
||||
builder.Services.AddAuthorizationBuilder()
|
||||
.AddPolicy(Schemes.Default, static policy =>
|
||||
{
|
||||
policy.AuthenticationSchemes = [Schemes.Default];
|
||||
policy.RequireAuthenticatedUser();
|
||||
})
|
||||
.AddPolicy(Schemes.AllowExpiredTokens, static policy =>
|
||||
{
|
||||
policy.AuthenticationSchemes = [Schemes.AllowExpiredTokens];
|
||||
policy.RequireAuthenticatedUser();
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapLoginEndpoint();
|
||||
|
||||
app.MapRefreshEndpoint()
|
||||
.RequireAuthorization(Schemes.AllowExpiredTokens);
|
||||
|
||||
app.Run();
|
||||
@@ -1,10 +1,13 @@
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
global using System.Security.Claims;
|
||||
global using System.Text.Json.Serialization;
|
||||
|
||||
global using FiscalOS.API.Http;
|
||||
global using FiscalOS.API.Login;
|
||||
global using FiscalOS.API.Refresh;
|
||||
global using FiscalOS.Core.Authentication;
|
||||
global using FiscalOS.Infra.Data;
|
||||
global using FiscalOS.Infra.DependencyInjection;
|
||||
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
global using Microsoft.EntityFrameworkCore;
|
||||
global using Microsoft.EntityFrameworkCore;
|
||||
|
||||
Reference in New Issue
Block a user