ProdLaunch
This commit is contained in:
@@ -80,13 +80,18 @@ def create_refresh_token(subject: str | UUID, tenant_id: str | UUID) -> str:
|
||||
"""
|
||||
Crea un JWT refresh token con scadenza lunga (30 giorni default).
|
||||
Non contiene il ruolo – viene rivalutato a ogni refresh.
|
||||
|
||||
Include un jti (JWT ID) UUID per garantire unicita' anche se due token
|
||||
vengono creati nello stesso secondo per lo stesso utente.
|
||||
"""
|
||||
import uuid as _uuid
|
||||
now = datetime.now(UTC)
|
||||
expire = now + timedelta(days=settings.refresh_token_expire_days)
|
||||
|
||||
payload: dict[str, Any] = {
|
||||
"sub": str(subject),
|
||||
"tid": str(tenant_id),
|
||||
"jti": str(_uuid.uuid4()), # JWT ID unico per evitare hash duplicati in DB
|
||||
"iat": now,
|
||||
"exp": expire,
|
||||
"type": "refresh",
|
||||
|
||||
Reference in New Issue
Block a user