package jwt

import "git.sr.ht/~pingoo/stdx/jwt"

Index

Variables

var (
	ErrTokenIsNotValid     = errors.New("The token is not valid")
	ErrSignatureIsNotValid = errors.New("Signature is not valid")
	ErrTokenHasExpired     = errors.New("The token has expired")
	ErrAlgorithmIsNotValid = fmt.Errorf("Algorithm is not valid. Valid algorithms values are: [%s, %s]", AlgorithmHS256, AlgorithmHS512)
)

Types

type Algorithm

type Algorithm string
const (
	AlgorithmHS256 Algorithm = "HS256"
	AlgorithmHS512 Algorithm = "HAS512"
)

type NewProviderOptions

type NewProviderOptions struct {
	VerifyingKeys [][]byte
}

type Provider

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

func NewProvider

func NewProvider(signingSecretKey []byte, algorithm Algorithm, options *NewProviderOptions) (provider *Provider, err error)

func (*Provider) IssueToken

func (provider *Provider) IssueToken(data any, options *TokenOptions) (token string, err error)

func (*Provider) VerifyToken

func (provider *Provider) VerifyToken(token string, data any) (err error)

type TokenOptions

type TokenOptions struct {
	ExpirationTime *time.Time
	NotBefore      *time.Time
}

type Type

type Type string
const (
	TypeJWT Type = "JWT"
)

Source Files

hmac.go jwt.go

Version
v0.0.0-20240218134121-094174641f6e (latest)
Published
Feb 18, 2024
Platform
linux/amd64
Imports
12 packages
Last checked
4 months ago

Tools for package owners.