authmint

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package authmint signs JWTs and serves a matching JWKS document.

Used by:

  • cmd/control-plane — long-running issuer of per-tenant access tokens
  • cmd/issue-test-token — one-shot dev helper that exercises the auth middleware without spinning up the full control plane

Both binaries need to (a) produce signed JWTs and (b) expose the public half of the signing key as a JWKS so tenant backends can verify those tokens. The signer hides the cryptographic plumbing behind a tiny API.

For now the signing key is generated fresh on every call to NewSigner — fine for dev, but production deployments will need a persistent key (loaded from disk/secret manager) and key rotation. Both come in 2C.2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Signer

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

Signer holds an RSA signing key and the kid it advertises in JWKS docs and JWT headers. Use NewSigner to construct.

func NewSigner

func NewSigner() (*Signer, error)

NewSigner generates a fresh 2048-bit RSA key and assigns a stable kid that the signer will use in both JWT headers and the JWKS document.

func (*Signer) JWKS

func (s *Signer) JWKS() ([]byte, error)

JWKS returns a JWKS document (RFC 7517) containing the signer's public key. Tenant backends point their APEX_JWKS_URL at an HTTP endpoint that serves these bytes.

func (*Signer) JWKSHandler

func (s *Signer) JWKSHandler() http.HandlerFunc

JWKSHandler returns an http.HandlerFunc that serves the JWKS document. Convenience for control plane HTTP servers and dev helpers.

func (*Signer) KeyID

func (s *Signer) KeyID() string

KeyID returns the kid this signer uses in both JWT headers and the JWKS.

func (*Signer) Keyfunc

func (s *Signer) Keyfunc() jwt.Keyfunc

Keyfunc returns a jwt.Keyfunc that resolves to this signer's public key. Useful for verifying tokens that this same signer issued without taking a JWKS round-trip (e.g. the control plane verifying its own user/state tokens). Tenant backends use a JWKS-cached keyfunc instead because they don't have direct access to the signer.

func (*Signer) Sign

func (s *Signer) Sign(claims jwt.MapClaims) (string, error)

Sign returns a signed RS256 JWT with the given claims. The kid header is set so verifiers can pick the right key from the JWKS.

Jump to

Keyboard shortcuts

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