auth

package module
v0.0.0-...-9b48ba9 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 12 Imported by: 1

README

auth

Opinionated token based authentication

Documentation

Overview

Provides symmetric authenticated encryption using 256-bit AES-GCM with a random nonce.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpired  = errors.New("authentication expired")
	ErrModified = errors.New("payload or signature was modified")
)

Functions

func NewEncryptionKey

func NewEncryptionKey() *[32]byte

NewEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt(). It panics if the source of randomness fails.

Types

type Authenticator

type Authenticator[A any] struct {
	// Required
	Public  ed25519.PublicKey
	Private ed25519.PrivateKey

	// Optional
	EncryptionKey *[32]byte
}

func (*Authenticator[A]) Decode

func (this *Authenticator[A]) Decode(token []byte, ttl int64) (*A, error)

func (*Authenticator[A]) Generate

func (this *Authenticator[A]) Generate(src *A) ([]byte, error)

func (*Authenticator[A]) GenerateStr

func (this *Authenticator[A]) GenerateStr(src *A) (string, error)

func (*Authenticator[A]) Parse

func (this *Authenticator[A]) Parse(token []byte, dst *A, ttl int64) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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