Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Define the default expiration times for tokens. DefaultAccessTokenDuration = 2 * time.Hour DefaultRefreshTokenDuration = 7 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomClaims ¶
type CustomClaims struct { UserID string `json:"userId"` FullName string `json:"fullName"` jwt.StandardClaims }
type JwtWrapper ¶
type JwtWrapper struct { SecretKey string // Key used for signing the JWT token Issuer string // Issuer of the JWT token AccessTokenExpiration time.Duration // Expiration time of the JWT token RefreshTokenExpiration time.Duration // Expiration time of the Refresh token }
func (*JwtWrapper) GenerateToken ¶
func (j *JwtWrapper) GenerateToken(userID, fullName string) (string, error)
GenerateToken generates a JWT token with custom claims.
func (*JwtWrapper) RefreshToken ¶
func (j *JwtWrapper) RefreshToken(userID, fullName string) (string, error)
RefreshToken generates a refresh JWT token with a longer lifespan.
func (*JwtWrapper) ValidateToken ¶
func (j *JwtWrapper) ValidateToken(signedToken string) (*CustomClaims, error)
ValidateToken validates the JWT token.
Click to show internal directories.
Click to hide internal directories.