jwt

package
v0.0.0-...-c2c7e1c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ClaimType     = "typ"
	ClaimName     = "name"
	ClaimUsername = "username"
	ClaimSub      = "sub"
)

Variables

View Source
var (
	ErrTokenExpired     = errors.New("token expired")
	ErrInvalidTokenType = errors.New("invalid token type")
)

Functions

func Verify

func Verify(config *Config, token Token) error

If you need to parse token use only Parse function because it also verifies.

func VerifyWithAud

func VerifyWithAud(config *Config, token Token, aud string) error

If you need to parse token use only ParseWithAud function because it also verifies.

Types

type Claims

type Claims map[string]any

func Parse

func Parse(config *Config, token Token) (Claims, error)

Parse also verifies token

func ParseWithAud

func ParseWithAud(config *Config, token Token, aud string) (Claims, error)

In comparison with just Parse it also checks audience Parse also verifies token

type Config

type Config struct {
	SigningMethod string

	Lifetime time.Duration
	Issuer   string
	Audience []string

	Type string

	SymmetricKey []byte // Used for symmetric signing
	// contains filtered or unexported fields
}

func (*Config) RSAKeys

func (c *Config) RSAKeys(privateKey []byte) error

func (*Config) RSAPublicOnlyKey

func (c *Config) RSAPublicOnlyKey(key []byte) error

type InternalToken

type InternalToken string

type Pair

type Pair struct {
	Access  Token
	Refresh Token
}

type Token

type Token string

func Generate

func Generate(config *Config, claims Claims) (Token, error)

Jump to

Keyboard shortcuts

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