authtoken

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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