UDT-003: Registro de Usuarios (admin-only) + fix JWT claim mapping #4

Merged
dmolinari merged 3 commits from feature/UDT-003 into main 2026-04-15 14:23:53 +00:00
Showing only changes of commit bce591e63c - Show all commits

View File

@@ -72,10 +72,13 @@ public static class DependencyInjection
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer();
// Post-configure JWT Bearer — wire RSA public key + validation params from resolved options
// Post-configure JWT Bearer — wire RSA public key + validation params from resolved options.
// MapInboundClaims=false: preserve JWT claim names as-is ("sub", "rol", etc.).
// Without this, the middleware maps "sub" → ClaimTypes.NameIdentifier and breaks User.FindFirst("sub").
services.AddOptions<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme)
.PostConfigure<RsaSecurityKey, JwtOptions>((jwtBearerOpts, rsaKey, jwtOpts) =>
{
jwtBearerOpts.MapInboundClaims = false;
jwtBearerOpts.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
@@ -86,7 +89,8 @@ public static class DependencyInjection
ValidAudience = jwtOpts.Audience,
ValidateLifetime = true,
ClockSkew = TimeSpan.Zero,
RoleClaimType = "rol"
RoleClaimType = "rol",
NameClaimType = "name"
};
});