authn

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Overview

Package authn validates `devbox-request-token`, the JWT the gateway attaches to every Daemon call, against the JWKS delivered in Initialize. Only RS256 and ES256 are accepted; the JWS is verified with the standard library.

Index

Constants

View Source
const Leeway = 2 * time.Minute

Leeway tolerates clock skew between the gateway and the sandbox (a restored box's clock may lag briefly).

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Issuer   string `json:"iss"`
	Subject  string `json:"sub"`
	Audience any    `json:"aud"`
	Expiry   int64  `json:"exp"`
	NotBef   int64  `json:"nbf"`
	Instance string `json:"instance"`
}

Claims are the validated token claims.

func (*Claims) HasAudience

func (c *Claims) HasAudience(s string) bool

HasAudience reports whether aud contains s.

type Verifier

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

Verifier holds the trusted keys.

func NewVerifier

func NewVerifier(now func() time.Time) *Verifier

NewVerifier returns an empty verifier (it accepts nothing until keys are set).

func (*Verifier) Configured

func (v *Verifier) Configured() bool

Configured reports whether keys are loaded.

func (*Verifier) SetJWKS

func (v *Verifier) SetJWKS(raw []byte, instance string) error

SetJWKS loads a JWKS document and the instance the tokens must name.

func (*Verifier) Verify

func (v *Verifier) Verify(token string) (*Claims, error)

Verify checks a compact JWS and its time claims.

Jump to

Keyboard shortcuts

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