token

package
v0.0.0-...-91bc0ee Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package token generates and validates tokens

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSecretKeyEmpty is the error returned when the secret key is empty
	ErrSecretKeyEmpty = errors.New("secret key cannot be empty")
)

Functions

func New

func New(opts ...Option) (string, error)

New generates and returns a new signed token

Types

type Option

type Option func(t *Token)

Option is a functional configuration option

func WithAlgorithm

func WithAlgorithm(a jose.SignatureAlgorithm) Option

WithAlgorithm sets the algorithm used for signing

func WithExpire

func WithExpire(d time.Time) Option

WithExpire sets the jwt exp

func WithKey

func WithKey(k string) Option

WithKey sets the secret key used for signing

func WithNotBefore

func WithNotBefore(d time.Time) Option

WithNotBefore sets the jwt nbf

func WithPrivate

func WithPrivate(c interface{}) Option

WithPrivate sets private claims

func WithSubject

func WithSubject(s string) Option

WithSubject sets the jwt subject

type Token

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

Token is an authentication token

Jump to

Keyboard shortcuts

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