localjwtauthority

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package localjwtauthority implements a simple "CA" for JWTs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(pool *ConcretePool) ([]byte, error)

Marshal serializes a Pool to JSON.

Types

type Authority

type Authority struct {
	ID         string
	Algorithm  string
	SigningKey crypto.Signer
}

func GenerateECDSAP256Authority

func GenerateECDSAP256Authority(id string) (*Authority, error)

GenerateECDSAP256Authority generates an ECDSA P256 JWT signing key.

type ConcretePool added in v0.1.0

type ConcretePool struct {
	Authorities []*Authority
	// Which authority is active for signing?
	ActiveForSigning string
}

func Unmarshal

func Unmarshal(wireBytes []byte) (*ConcretePool, error)

Unmarshal loads a Pool from JSON.

func (*ConcretePool) SignJWT added in v0.1.0

func (p *ConcretePool) SignJWT(claims *actoridjwt.Claims) (string, error)

func (*ConcretePool) VerificationKeys added in v0.1.0

func (p *ConcretePool) VerificationKeys() ([]*VerificationKey, error)

type Pool

type Pool interface {
	// SignJWT signs a JWT with the given claims.
	SignJWT(*actoridjwt.Claims) (string, error)

	// VerificationKeys returns the verification key set of this pool, for
	// exporting via OpenID Connect Discovery.
	VerificationKeys() ([]*VerificationKey, error)
}

Pool is the interface for a JWT signing pool.

Logically, a Pool is a collection of multiple authorities. One or more are designated as active for signing. The rest are inactive, but are still trusted for verifying JWTs.

The active/inactive designation allows a Pool to be seamlessly rotated.

Normally, we let callers define their own compatibility interfaces. But in most cases you'll want to either use a RefreshingPool (for controllers and servers), or a ConcretePool (for CLIs and tests).

type RefreshingPool added in v0.1.0

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

RefreshingPool is a wrapper around ConcretePool that periodically reloads the state from disk. This allows JWT signing and verification to continue working seamlessly even as an administrator rotates the pool, without requiring any components to restart.

func NewRefreshingPool added in v0.1.0

func NewRefreshingPool(stateFile string) (*RefreshingPool, error)

func (*RefreshingPool) SignJWT added in v0.1.0

func (p *RefreshingPool) SignJWT(claims *actoridjwt.Claims) (string, error)

func (*RefreshingPool) VerificationKeys added in v0.1.0

func (p *RefreshingPool) VerificationKeys() ([]*VerificationKey, error)

type VerificationKey added in v0.1.0

type VerificationKey struct {
	KeyID     string
	PublicKey crypto.PublicKey
}

Jump to

Keyboard shortcuts

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