feat: Unterstützung für Token-Beschreibungen im JwtSignatureHandler hinzugefügt
- Methoden eingeführt, um Token-Beschreibungen im DI-Container zu konfigurieren und zu registrieren. - Überladungen zu `AddJwtSignatureHandler` hinzugefügt, um sowohl konfigurationsbasierte als auch Inline-Token-Beschreibungen zu unterstützen.
This commit is contained in:
parent
8850ac4ac9
commit
592b949f57
@ -61,8 +61,23 @@ namespace DigitalData.Core.Security
|
||||
return services.AddSingleton(sp => Options.Create(descriptor));
|
||||
}
|
||||
|
||||
public static IServiceCollection AddJwtSignatureHandler<TPrincipal>(this IServiceCollection services, Func<TPrincipal, IDictionary<string, object>>? claimsMapper = null, Func<TPrincipal, ClaimsIdentity>? subjectMapper = null) => services
|
||||
.AddClaimDescriptor(claimsMapper: claimsMapper, subjectMapper: subjectMapper)
|
||||
.AddSingleton<IJwtSignatureHandler<TPrincipal>, JwtSignatureHandler<TPrincipal>>();
|
||||
public static IServiceCollection AddTokenDescriptions(this IServiceCollection services, IConfiguration configuration)
|
||||
=> services.Configure<IEnumerable<TokenDescription>>(configuration);
|
||||
|
||||
public static IServiceCollection AddTokenDescriptions(this IServiceCollection services, params TokenDescription[] tokenDescriptions)
|
||||
=> services.AddSingleton<IOptions<IEnumerable<TokenDescription>>>(Options.Create(tokenDescriptions));
|
||||
|
||||
public static IServiceCollection AddJwtSignatureHandler<TPrincipal>(this IServiceCollection services, Func<TPrincipal, IDictionary<string, object>>? claimsMapper = null, Func<TPrincipal, ClaimsIdentity>? subjectMapper = null, IConfiguration? tokenDescriptionconfig = null, params TokenDescription[]? tokenDescriptions)
|
||||
{
|
||||
if (tokenDescriptionconfig is not null)
|
||||
services.AddTokenDescriptions(tokenDescriptionconfig);
|
||||
|
||||
if (tokenDescriptions is not null)
|
||||
services.AddTokenDescriptions(tokenDescriptions);
|
||||
|
||||
return services
|
||||
.AddClaimDescriptor(claimsMapper: claimsMapper, subjectMapper: subjectMapper)
|
||||
.AddSingleton<IJwtSignatureHandler<TPrincipal>, JwtSignatureHandler<TPrincipal>>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user