feat: Connexion utilisateur avec sécurité renforcée
Implémente la Story 1.4 du système d'authentification avec plusieurs couches de protection contre les attaques par force brute. Sécurité backend : - Authentification JWT avec access token (15min) + refresh token (7j) - Rotation automatique des refresh tokens avec détection de replay - Rate limiting progressif par IP (délai Fibonacci après échecs) - Intégration Cloudflare Turnstile CAPTCHA après 5 tentatives - Alerte email à l'utilisateur après blocage temporaire - Isolation multi-tenant (un utilisateur ne peut se connecter que sur son établissement) Frontend : - Page de connexion avec feedback visuel des délais et erreurs - Composant TurnstileCaptcha réutilisable - Gestion d'état auth avec stockage sécurisé des tokens - Tests E2E Playwright pour login, tenant isolation, et activation Infrastructure : - Configuration Symfony Security avec json_login + jwt - Cache pools séparés (filesystem en test, Redis en prod) - NullLoginRateLimiter pour environnement de test (évite blocage CI) - Génération des clés JWT en CI après démarrage du backend
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Administration\Domain\Model\User\Email;
|
||||
use App\Administration\Domain\Model\User\User;
|
||||
use App\Administration\Domain\Model\User\UserId;
|
||||
use App\Administration\Domain\Repository\UserRepository;
|
||||
use App\Shared\Domain\Tenant\TenantId;
|
||||
use Override;
|
||||
|
||||
final class InMemoryUserRepository implements UserRepository
|
||||
@@ -16,14 +17,14 @@ final class InMemoryUserRepository implements UserRepository
|
||||
/** @var array<string, User> Indexed by ID */
|
||||
private array $byId = [];
|
||||
|
||||
/** @var array<string, User> Indexed by email (lowercase) */
|
||||
private array $byEmail = [];
|
||||
/** @var array<string, User> Indexed by tenant:email (lowercase) */
|
||||
private array $byTenantEmail = [];
|
||||
|
||||
#[Override]
|
||||
public function save(User $user): void
|
||||
{
|
||||
$this->byId[(string) $user->id] = $user;
|
||||
$this->byEmail[strtolower((string) $user->email)] = $user;
|
||||
$this->byTenantEmail[$this->emailKey($user->email, $user->tenantId)] = $user;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
@@ -39,8 +40,13 @@ final class InMemoryUserRepository implements UserRepository
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function findByEmail(Email $email): ?User
|
||||
public function findByEmail(Email $email, TenantId $tenantId): ?User
|
||||
{
|
||||
return $this->byEmail[strtolower((string) $email)] ?? null;
|
||||
return $this->byTenantEmail[$this->emailKey($email, $tenantId)] ?? null;
|
||||
}
|
||||
|
||||
private function emailKey(Email $email, TenantId $tenantId): string
|
||||
{
|
||||
return $tenantId . ':' . strtolower((string) $email);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user