token

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 18 Imported by: 1 module, 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

View Source
var ErrTagMismatch = errors.New("tag mismatch")

Functions

func Delete

func Delete(token string, etag string) error

func Expire

func Expire() error

func ParseKey

func ParseKey(key map[string]any) (any, error)

func ParseKeys

func ParseKeys(keys []map[string]any, alg, kid string) ([]jwt.VerificationKey, error)

func SetStatefulFilename

func SetStatefulFilename(filename string)

Types

type JWT

type JWT jwt.Token

func (*JWT) Check

func (token *JWT) Check(host, group string) (string, []string, error)

func (*JWT) NeedsUsername

func (token *JWT) NeedsUsername() bool

type Stateful

type Stateful struct {
	Token            string     `json:"token"`
	Group            string     `json:"group"`
	IncludeSubgroups bool       `json:"includeSubgroups,omitempty"`
	Username         *string    `json:"username,omitempty"`
	Permissions      []string   `json:"permissions"`
	Expires          *time.Time `json:"expires,omitempty"`
	NotBefore        *time.Time `json:"not-before,omitempty"`
	IssuedAt         *time.Time `json:"issuedAt,omitempty"`
	IssuedBy         *string    `json:"issuedBy,omitempty"`
	// Link marks a per-client invite link that an operator hub minted for
	// one of its child rooms -- the links its dashboard lists.  It is set
	// by the server at mint time and never read from the client request,
	// so a token cannot claim to be a link.  Tokens minted inside a room
	// (a remembered device, an /invite) are not links, even though they
	// belong to the same group. (Sozvon)
	Link bool `json:"link,omitempty"`
}

A stateful token

func Get

func Get(token string) (*Stateful, string, error)

Get fetches a stateful token. It returns os.ErrNotExist if the token doesn't exist.

func List

func List(group string) ([]*Stateful, string, error)

func ListSubtree

func ListSubtree(group string) ([]*Stateful, string, error)

ListSubtree returns every token whose group is group or a subgroup of it (group/...). It backs the operator-room dashboard, which lists the hub's own tokens together with those of its per-client child rooms.

func Update

func Update(token *Stateful, etag string) (*Stateful, error)

func (*Stateful) Check

func (token *Stateful) Check(host, group string) (string, []string, error)

func (*Stateful) Clone

func (token *Stateful) Clone() *Stateful

func (*Stateful) NeedsUsername

func (token *Stateful) NeedsUsername() bool

type Token

type Token interface {
	Check(host, group string) (string, []string, error)
	NeedsUsername() bool
}

func Parse

func Parse(token string, keys []map[string]interface{}) (Token, error)

Jump to

Keyboard shortcuts

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