Authentification
JWT · Custom User · RBAC · Rôles coopérative
Essentiel
v2.0
Production Ready
1. Présentation
Ce module implémente une stratégie JWT « cookie-first » : le token d'accès est posé dans un cookie HttpOnly au login, invisible au JavaScript. Le refresh token tourne automatiquement à chaque requête (rotation + blacklist). Les rôles coopérative contrôlent l'accès aux fonctionnalités.
2. Installation
# authentication est un module local — déjà inclus # Vérifier INSTALLED_APPS dans config/settings/base.py "authentication",
3. Configuration
# config/settings/base.py
AUTH_USER_MODEL = "customers.User"
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=60),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,
}
4. Modèles de données
User
ClientProfile
CompteClient
SavingsProduct
Note opérateur : La stratégie « cookie HttpOnly » protège contre les attaques XSS. Le token n'est jamais exposé à window.localStorage.
5. Endpoints API
Authentification
6 endpoints| Méthode | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/login/ | Connexion |
| POST | /api/v1/auth/logout/ | Déconnexion |
| POST | /api/v1/auth/register/ | Inscription |
| GET | /api/v1/auth/users/me/ | Profil courant |
| POST | /api/v1/token/ | Obtenir JWT |
| POST | /api/v1/token/refresh/ | Rafraîchir JWT |
Métadonnées
| Mainteneur | COOP-CA AMIFOND |
| Version | v2.0 |
| Statut | Production Ready |
| Endpoints | 6 |
| Compatibilité | Django 4.2 LTS / Python 3.10 |