token

package
v0.0.0-...-681f5a7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessTokenType  = "access_token"
	RefreshTokenType = "refresh_token"
)

Variables

This section is empty.

Functions

func GetEdDSAPrivateKey

func GetEdDSAPrivateKey(data []byte) ed25519.PrivateKey

func GetKeyBytes

func GetKeyBytes(key string) []byte

func GetRSAPrivateKey

func GetRSAPrivateKey(data []byte) *rsa.PrivateKey

Types

type JwtToken

type JwtToken interface {
	GenerateAccessToken(payload map[string]any) (string, error)
	GenerateRefreshToken(payload map[string]any) (string, error)
	ParseRefreshToken(refreshToken string) (map[string]any, error)
	VerifyTokenMiddleware() gin.HandlerFunc
}

func NewToken

func NewToken(
	algorithm,
	signingKey,
	verifyingKey string,
	accessTokenTimeout,
	refreshTokenTimeout time.Duration) JwtToken

type Token

type Token struct {
	Algorithm           string
	SigningKey          any
	VerifyingKey        string
	AccessTokenTimeout  time.Duration
	RefreshTokenTimeout time.Duration
}

func (*Token) GenerateAccessToken

func (t *Token) GenerateAccessToken(payload map[string]any) (string, error)

func (*Token) GenerateRefreshToken

func (t *Token) GenerateRefreshToken(payload map[string]any) (string, error)

func (*Token) ParseRefreshToken

func (t *Token) ParseRefreshToken(refreshToken string) (map[string]any, error)

func (*Token) VerifyToken

func (t *Token) VerifyToken(accessToken string) (map[string]any, error)

func (*Token) VerifyTokenMiddleware

func (t *Token) VerifyTokenMiddleware() gin.HandlerFunc

Jump to

Keyboard shortcuts

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