token

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 7 Imported by: 0 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

Overview

Package token signs and verifies the caller tokens of ward.

Index

Constants

This section is empty.

Variables

View Source
var ErrToken = errors.New("token: not accepted")

ErrToken is the one error of a rejected token. It never says why.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Kid     string `json:"kid"`
	Scope   Scope  `json:"scope"`
	Repo    string `json:"repo,omitempty"`
	Subject string `json:"subject,omitempty"`
	Exp     int64  `json:"exp"`
}

Claims name what a bearer may do. Subject is for logs and traces and grants nothing.

type Key

type Key struct {
	Kid    string
	Public ed25519.PublicKey
	Scopes []Scope
}

Key is a public key and the scopes that it may sign.

type Scope

type Scope string
const (
	ScopeRead     Scope = "read"
	ScopeOperator Scope = "operator"
	ScopeLand     Scope = "land"
	ScopeCheck    Scope = "check"
)

type Signer

type Signer struct {
	Kid string
	Key ed25519.PrivateKey
}

Signer mints tokens with an Ed25519 private key.

func (Signer) Mint

func (s Signer) Mint(c Claims) (string, error)

Mint signs c under the kid of the signer.

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier accepts tokens that one of its keys signed.

func NewVerifier

func NewVerifier(keys ...Key) *Verifier

func (*Verifier) Verify

func (v *Verifier) Verify(tok string, now time.Time) (Claims, error)

Verify returns the claims of tok when a known key signed it, the key may sign the scope, the claims are complete and now is before Exp.

Jump to

Keyboard shortcuts

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