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);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Services.AddValidation();
|
builder.Services.AddValidation();
|
||||||
builder.Services.AddOpenApi();
|
|
||||||
|
|
||||||
builder.Services.AddInfrastructure();
|
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();
|
var app = builder.Build();
|
||||||
|
|
||||||
if (app.Environment.IsDevelopment())
|
app.UseAuthentication();
|
||||||
{
|
app.UseAuthorization();
|
||||||
app.MapOpenApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.MapLoginEndpoint();
|
app.MapLoginEndpoint();
|
||||||
|
|
||||||
|
app.MapRefreshEndpoint()
|
||||||
|
.RequireAuthorization(Schemes.AllowExpiredTokens);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
global using System.ComponentModel.DataAnnotations;
|
global using System.ComponentModel.DataAnnotations;
|
||||||
|
global using System.Security.Claims;
|
||||||
global using System.Text.Json.Serialization;
|
global using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
global using FiscalOS.API.Http;
|
||||||
global using FiscalOS.API.Login;
|
global using FiscalOS.API.Login;
|
||||||
|
global using FiscalOS.API.Refresh;
|
||||||
global using FiscalOS.Core.Authentication;
|
global using FiscalOS.Core.Authentication;
|
||||||
global using FiscalOS.Infra.Data;
|
global using FiscalOS.Infra.Data;
|
||||||
global using FiscalOS.Infra.DependencyInjection;
|
global using FiscalOS.Infra.DependencyInjection;
|
||||||
|
|||||||
Reference in New Issue
Block a user