authtoken

package
v0.45.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "rill"

Prefix is prepended to every auth token.

Variables

View Source
var ErrMalformed = errors.New("malformed auth token")

ErrMalformed is used when attempting to parse an invalid token string.

Functions

This section is empty.

Types

type Token

type Token struct {
	Type   Type
	ID     uuid.UUID
	Secret [24]byte
}

Token is a parsed authentication token with a type, UUID ID, and 24-byte secret. Tokens can be (de)serialized as strings. Example string representation of a user token: rill_usr_2Dws32dc2FxTThgCQjHerGM1rx9pJLCPQh5QbWjUiwpkZNkCCRrlrK.

func FromString

func FromString(s string) (*Token, error)

FromString re-creates a token from it's string representation (acquired by calling String()). The things I do for pretty tokens.

func NewRandom

func NewRandom(t Type) *Token

NewRandom generates a securely random token.

func (*Token) SecretHash

func (t *Token) SecretHash() []byte

SecretHash returns a SHA256 hash of the token secret.

func (*Token) String

func (t *Token) String() string

String canonically encodes the token as string.

type Type

type Type string

Type is part of the token prefix in the string representation.

const (
	TypeUser       Type = "usr"
	TypeService    Type = "svc"
	TypeDeployment Type = "dpl"
)

func (Type) Validate

func (t Type) Validate() bool

Validate checks that the type is a known enum value.

Jump to

Keyboard shortcuts

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