feat(api): add refresh endpoint and update global usings

This commit is contained in:
Stevan Freeborn
2026-02-03 21:04:25 -06:00
parent e12fa0111a
commit 92b3c8e9c4
2 changed files with 31 additions and 6 deletions
+27 -5
View File
@@ -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();
+4 -1
View File
@@ -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;