authtoken

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SignFunc

type SignFunc func(payload []byte) (signature []byte, err error)

A SignFunc will return a signature for the given payload.

type Token

type Token struct {
	Version   int
	Type      Type
	ID        uuid.UUID
	CreatedAt time.Time
}

Token represents an authentication token.

func Parse

func Parse(s string, verifyFn VerifyFunc) (*Token, bool, error)

Parse will parse a token string, optionally verifying it's signature. If verifyFn is nil, the signature is ignored.

func (Token) Encode

func (t Token) Encode(signFn SignFunc) (string, error)

Encode will return a signed, URL-safe string representation of the token. If signFn is nil, the signature will be omitted.

type Type

type Type byte

Type represents the type of an authentication token.

const (
	TypeUnknown Type = iota // always make the zero-value Unknown
	TypeSession
	TypeCalSub
)

Available valid token types.

type VerifyFunc

type VerifyFunc func(t Type, payload, signature []byte) (isValid, isOldKey bool)

A VerifyFunc will verify that the signature is valid for the given type and payload. Additionally, if supported, it indicates if an old-but-still-valid key (since been rotated) was used to generate the signature.

Jump to

Keyboard shortcuts

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