token

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAccessToken

func ParseAccessToken(tokenValue []byte, claims jwt.Claims) (*jwt.Token, []string, error)

func ParseRSAPrivateKey

func ParseRSAPrivateKey(pemData string) (*rsa.PrivateKey, error)

func ParseRSAPublicKey

func ParseRSAPublicKey(pemData string) (*rsa.PublicKey, error)

func ParseUnverified

func ParseUnverified(tokenString string, claims jwt.Claims) (*jwt.Token, []string, error)

Types

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

func NewJWT

func NewJWT(opts ...OptionJWT) (*JWT, error)

NewJWT function get private key and options and return a new JWT instance.

Default expiration function is time.Now().Add(time.Hour).Unix().

func (*JWT) Alg

func (t *JWT) Alg() string

func (*JWT) Generate

func (t *JWT) Generate(mapClaims map[string]interface{}, expDate int64) (string, error)

Generate function get custom values and add 'exp' as expires at with expDate argument with unix format.

func (*JWT) Parse

func (t *JWT) Parse(tokenStr string, claims jwt.Claims) (*jwt.Token, error)

Parse is validating and getting claims.

func (*JWT) Renew

func (t *JWT) Renew(tokenStr string, expDate int64) (string, error)

Renew token with not changing claims.

type OptionJWT

type OptionJWT func(options *optionJWT)

func WithECDSAPrivateKey

func WithECDSAPrivateKey(secret *ecdsa.PrivateKey) OptionJWT

func WithECDSAPublicKey

func WithECDSAPublicKey(secret *ecdsa.PublicKey) OptionJWT

func WithED25519PrivateKey

func WithED25519PrivateKey(secret ed25519.PrivateKey) OptionJWT

func WithED25519PublicKey

func WithED25519PublicKey(secret ed25519.PublicKey) OptionJWT

func WithHMAC

func WithHMAC(secret []byte) OptionJWT

func WithKID

func WithKID(kid string) OptionJWT

WithKID sets the key ID for the JWT.

func WithMethod

func WithMethod(method jwt.SigningMethod) OptionJWT

WithMethod sets the signing method for the JWT.

func WithRSAPrivateKey

func WithRSAPrivateKey(secret *rsa.PrivateKey) OptionJWT

func WithRSAPublicKey

func WithRSAPublicKey(secret *rsa.PublicKey) OptionJWT

Jump to

Keyboard shortcuts

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