token

package
v0.0.0-...-2af415a Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package token implements methods to manage PASETO tokens.

Index

Constants

View Source
const (
	// RoleAdmin has complete access to all the resources.
	RoleAdmin = "admin"
	// RoleDaemon runs on every target node and takes orders from the
	// control station.
	RoleDaemon = "daemon"
)

Variables

View Source
var (
	// DefaultExpiry is the default token expiration time if nothing is
	// provided.
	DefaultExpiry = time.Now().Add(time.Minute * 5)

	ErrInvalidNB        = errors.New("expiry cannot be shorter than NB")
	ErrMissingBody      = errors.New("missing body in params")
	ErrMissingSecretKey = errors.New("missing secret key in params")
)

Functions

func Decrypt

func Decrypt(enc, secret string, implicit []byte) (*token, error)

Decrypt decrypts the encrypted token

func New

func New(p Params) (*token, error)

New returns a new paseto token from the provided parameters.

Types

type Params

type Params struct {
	Expiry    time.Time
	NotBefore time.Time
	Issuer    string
	Audience  string
	Body      map[string]any
}

Params contains parameters to construct a paseto token.

Jump to

Keyboard shortcuts

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