tokens

package
v0.0.0-...-a92fb97 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tokens generates typed authenticated tokens that allow untrusted third parties to safely carry state between applictions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKey = errors.New("key is not 32 bytes")
	ErrEmptyToken = errors.New("provided token is empty")
	ErrTooNew     = errors.New("secure message is too new")
	ErrTooOld     = errors.New("secure message is too old")
)

Functions

func Decrypt

func Decrypt(token string, key []byte) (*types.SecureToken, error)

Decrypt returns the decrypted SecureToken. It's only intended to be used from debugging utilities.

func New

func New(msg proto.Message, key []byte) (string, error)

New generates a token from the provided protocol message, encrypting and signing it with the provided 32-byte symmetric key.

func VerifyAndUnmarshal

func VerifyAndUnmarshal(dst proto.Message, token string, maxAge time.Duration, key []byte) error

VerifyAndUnmarshal unmarshals a token created by NewToken into the provided protocol message. An error is returned if the token is too new, too old, cryptographically invalid, or if the type of the destination message and contained message do not match.

Types

type GeneratorConfig

type GeneratorConfig struct {
	Key []byte // A key with which to sign and encrypt tokens.  Must be exactly 32 bytes.
}

func (*GeneratorConfig) SetKey

func (c *GeneratorConfig) SetKey(key []byte) error

Jump to

Keyboard shortcuts

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