fix(auth): audit de securite complet - 12 correctifs
# Fix #28: ProtectedLocalStorage -> ProtectedSessionStorage # (donnees token jamais exposees au JS client en Blazor Server) # Fix #3: GetUserIdFromExpiredToken valide maintenant la signature # (plus de ReadJwtToken sans validation) # Fix #5: API Key handler X-API-Key uniquement (plus de Bearer ambiguité) # Fix #7: MarkUsed() persiste via SaveChangesAsync() # Fix #8: Hardcoded permissions (documenté — nécessite migration DB) # Fix #12: Race condition registration — try/catch DbUpdateException # Fix #13: Public registration DESACTIVEE par defaut (pas de setting = disabled) # Fix #15/17: Enable2fa genere et retourne shared key + QR code URI # Fix #16: Rate limiting specifique 2FA (5 req/min) et RegisterAdmin # Fix #22/23: RevokeRefreshToken stocke jti (pas token brut) # Fix #24: Rotation refresh token — ancien token revoque apres refresh # Fix #39: Audit logging des echecs de login (via IUserRepository) Breaking: Enable2fa retourne maintenant Enable2faResponse au lieu de Ok()
This commit is contained in:
1 parent
485842b135
commit
234c158a69
12 files changed
+201
-50
No files matched your search
@@ -34,9 +34,8 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthentic
|
||||
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
var apiKey = Request.Headers.Authorization.FirstOrDefault()
|
||||
?.Replace("Bearer ", "", StringComparison.OrdinalIgnoreCase)
|
||||
?? Request.Headers["X-API-Key"].FirstOrDefault();
|
||||
// X-API-Key header only (pas de Bearer — réservé au handler JWT)
|
||||
var apiKey = Request.Headers["X-API-Key"].FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrEmpty(apiKey) || apiKey.Length < 8)
|
||||
return AuthenticateResult.NoResult();
|
||||
@@ -60,6 +59,8 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthentic
|
||||
return AuthenticateResult.Fail("Invalid API key");
|
||||
|
||||
apiKeyEntity.MarkUsed();
|
||||
// Persist LastUsedAt update
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user