middleware

package
v0.0.0-...-d0c559a Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(userID, username string, roles []string, config JWTConfig) (string, error)

func JWTMiddleware

func JWTMiddleware(config JWTConfig) gin.HandlerFunc

Types

type Claims

type Claims struct {
	UserID    string   `json:"user_id"`
	Username  string   `json:"username"`
	Roles     []string `json:"roles"`
	IssuedAt  int64    `json:"iat"`
	ExpiresAt int64    `json:"exp"`
}

func (Claims) GetAudience

func (c Claims) GetAudience() (jwt.ClaimStrings, error)

func (Claims) GetExpirationTime

func (c Claims) GetExpirationTime() (*jwt.NumericDate, error)

func (Claims) GetIssuedAt

func (c Claims) GetIssuedAt() (*jwt.NumericDate, error)

func (Claims) GetIssuer

func (c Claims) GetIssuer() (string, error)

func (Claims) GetNotBefore

func (c Claims) GetNotBefore() (*jwt.NumericDate, error)

func (Claims) GetSubject

func (c Claims) GetSubject() (string, error)

type JWTConfig

type JWTConfig struct {
	SecretKey     string
	TokenDuration time.Duration
}

Jump to

Keyboard shortcuts

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