token

package
v1.102.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidKind for generation of tokens.
	ErrInvalidKind = errors.New("invalid kind")

	// ErrInvalidAlgorithm for service.
	ErrInvalidAlgorithm = errors.New("invalid algorithm")

	// ErrInvalidIssuer for service.
	ErrInvalidIssuer = errors.New("invalid issuer")

	// ErrInvalidAudience for service.
	ErrInvalidAudience = errors.New("invalid audience")

	// ErrInvalidTime for service.
	ErrInvalidTime = errors.New("invalid time")
)

Module for fx.

Functions

This section is empty.

Types

type JWT

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

JWT token.

func NewJWT

func NewJWT(kid KID, publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey) *JWT

NewJWT token.

func (*JWT) Generate

func (j *JWT) Generate(sub, aud, iss string, exp time.Duration) (string, error)

Generate JWT token.

func (*JWT) Verify

func (j *JWT) Verify(token, aud, iss string) (string, error)

Verify JWT token.

type KID

type KID string

KID is a key ID.

func NewKID

func NewKID() (KID, error)

NewKID for JWKSets.

type Paseto

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

Paseto token.

func NewPaseto

func NewPaseto(publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey) *Paseto

NewPaseto token.

func (*Paseto) Generate

func (p *Paseto) Generate(sub, aud, iss string, exp time.Duration) (string, error)

Generate Paseto token.

func (*Paseto) Verify

func (p *Paseto) Verify(token, aud, iss string) (string, error)

Verify Paseto token.

type Token

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

Token generator.

func NewToken

func NewToken(jwt *JWT, paseto *Paseto) *Token

NewToken generator.

func (*Token) Generate

func (t *Token) Generate(kind, sub, aud, iss string, exp time.Duration) (string, error)

Generate token based on kind.

func (*Token) Verify

func (t *Token) Verify(token, kind, aud, iss string) (string, error)

Verify token based on kind.

Jump to

Keyboard shortcuts

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