userauth

package
v0.0.0-...-435fad9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL