initial commit
This commit is contained in:
22
pkg/jwt/provider.go
Normal file
22
pkg/jwt/provider.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package jwt
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"base/config"
|
||||
)
|
||||
|
||||
// NewTokenService creates a new JWT TokenService from config
|
||||
func NewTokenService(cfg *config.AppConfig) TokenService {
|
||||
secret := cfg.Server.JWTSecret
|
||||
if secret == "" {
|
||||
// Default secret if not configured (should be set in production)
|
||||
secret = "default-secret-key-change-in-production"
|
||||
}
|
||||
|
||||
// Default token expiration times
|
||||
accessTokenExpiration := 24 * time.Hour
|
||||
refreshTokenExpiration := 7 * 24 * time.Hour
|
||||
|
||||
return New(secret, accessTokenExpiration, refreshTokenExpiration)
|
||||
}
|
||||
Reference in New Issue
Block a user