jwt

package
v1.0.66 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const AuthUserKey = "authUser"

Variables

View Source
var (
	ErrEmptyAuthHeader      = apperr.New("empty_auth_header")
	ErrInvalidAuthHeader    = apperr.New("invalid_auth_header")
	ErrEmptyToken           = apperr.New("empty_token")
	ErrInvalidToken         = apperr.New("invalid_token")
	ErrTokenParseError      = apperr.New("token_parse_error")
	ErrErrorToSigningString = apperr.New("error_to_signing_string")
)

Functions

func ParseAuthHeader

func ParseAuthHeader(c *gin.Context) (string, error)

Types

type JWT

type JWT struct {
	Key      []byte
	Duration time.Duration
	Algo     string
}

func NewJWT

func NewJWT(signingKey string, accessTokenTTL time.Duration, signingAlgorithm string) *JWT

func (*JWT) GenerateToken

func (j *JWT) GenerateToken(u Token) (string, float64, error)

func (*JWT) ParseToken

func (j *JWT) ParseToken(token string) (*Token, error)

type Token added in v1.0.59

type Token struct {
	Id    int    `json:"id"`
	Role  string `json:"role"`
	Login string `json:"login"`
}

type TokenClaims added in v1.0.42

type TokenClaims struct {
	Id    int    `json:"id"`
	Role  string `json:"role"`
	Login string `json:"login"`
	jwt.RegisteredClaims
}

type User added in v1.0.42

type User struct {
	Id           int    `json:"id"`
	Role         string `json:"role"`
	Login        string `json:"login"`
	DepartmentId *int   `json:"department_id"`
	DeviceId     string `json:"device_id"`
	PlatformId   int    `json:"platform_id"`
}

Jump to

Keyboard shortcuts

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