36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/golang-jwt/jwt/v5"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// CustomClaims représente les claims JWT pour l'application
|
|
// MIGRATION UUID: UserID migré vers uuid.UUID pour cohérence avec User.ID
|
|
type CustomClaims struct {
|
|
UserID uuid.UUID `json:"sub"`
|
|
Email string `json:"email"`
|
|
Username string `json:"username,omitempty"` // Requis par Rust Chat
|
|
Role string `json:"role"`
|
|
TokenVersion int `json:"token_version"`
|
|
IsRefresh bool `json:"is_refresh,omitempty"`
|
|
TokenType string `json:"token_type,omitempty"` // Requis par Rust Chat ("access" ou "refresh")
|
|
TokenFamily string `json:"token_family,omitempty"` // Requis par Rust Chat (Refresh rotation)
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
// TokenPair représente une paire de tokens
|
|
type TokenPair struct {
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresIn int `json:"expires_in"`
|
|
}
|
|
|
|
// JWTConfig contient la configuration JWT
|
|
type JWTConfig struct {
|
|
AccessTokenTTL time.Duration
|
|
RefreshTokenTTL time.Duration
|
|
RememberMeRefreshTokenTTL time.Duration // Ajouté
|
|
}
|