Versions in this module Expand all Collapse all v0 v0.1.1 Nov 12, 2026 v0.1.0 Oct 14, 2026 Changes in this version + const CurveEd25519 + const CurveP256 + const CurveP384 + const CurveP521 + const DefaultAlgorithm + const DefaultJWKSPath + const DefaultLeeway + const DefaultRemoteTimeout + const DefaultTTL + const EndpointJWKS + const EndpointTemplate + const EndpointToken + const HS256 + const KeyTypeEC + const KeyTypeOKP + const KeyTypeRSA + const KeyUseSignature + const MaxAudienceValues + const MaxTTL + const MinHMACSecret + const MinRSABits + const MinRotationInterval + const PluginName + const RemoteMaxAge + const RemoteMinRefresh + const RotationSeedSize + const SessionCacheAudience + const SessionCacheType + const SetJWTHeader + var AlgValues = []Alg + var ErrAlgorithmKeys = errors.New("jwt: AlgorithmKeys holds valid keys, each once and none the signing key") + var ErrBadType = errors.New(...) + var ErrCacheNotWired = errors.New("jwt: NewSessionCache's plugin is not in auth.WithPlugins") + var ErrEmptySubject = errors.New("jwt: Subject returned an empty subject") + var ErrHMACSecret = errors.New("jwt: an HMAC template secret is at least 32 bytes") + var ErrInvalid = errors.New("jwt: token is not valid") + var ErrJWKSPath = errors.New(...) + var ErrNoAlgorithmKey = errors.New("jwt: no signing key for this algorithm; add one with jwt.AlgorithmKeys") + var ErrNoIssuer = errors.New("jwt: needs auth.WithBaseURL or jwt.Issuer") + var ErrNoKey = errors.New(...) + var ErrNoSigningKey = errors.New("jwt: no signing key with this key id") + var ErrRemoteJWKS = errors.New("jwt: RemoteJWKS needs an absolute https URL (http only for a loopback host)") + var ErrRemoteKeys = errors.New("jwt: remote key set could not be read") + var ErrReservedClaim = errors.New("jwt: Claims may not set a registered claim") + var ErrRotationGrace = errors.New("jwt: Rotating grace period is at least the token TTL") + var ErrRotationInterval = errors.New("jwt: Rotating interval is at least an hour") + var ErrRotationSeed = errors.New("jwt: Rotating needs a 32-byte seed") + var ErrSignature = errors.New("jwt: the Signer's signature does not verify with its published key") + var ErrSignerKey = errors.New("jwt: Signer has no published key to sign with") + var ErrTemplateKey = errors.New("jwt: the template's key cannot sign for it") + var ErrTemplateName = errors.New(...) + var ErrUnknownTemplate = auth.NewError("jwt.unknown_template", http.StatusNotFound, ...) + var ErrUnsupportedKey = errors.New(...) + func GenerateKey(alg Alg) (crypto.Signer, error) + func HashOf(alg Alg) crypto.Hash + func KeyID(pub crypto.PublicKey) string + func KeysFromJWKS(set JWKS) map[string]crypto.PublicKey + func NewSessionCache(p *Plugin) auth.SessionCache + func PublicKeyForAlg(k JWK, alg Alg) (crypto.PublicKey, bool) + func PublicKeyOfJWK(k JWK) (crypto.PublicKey, bool) + func RSAKey(k crypto.Signer, alg Alg) (crypto.Signer, error) + func SessionJWT(ctx context.Context) (string, bool) + func Thumbprint(k JWK) (string, error) + func VerifyHS256(token string, secret []byte, types ...string) ([]byte, error) + func VerifySignature(token string, pub crypto.PublicKey, types ...string) (header, payload []byte, err error) + type Alg string + const ES256 + const ES384 + const ES512 + const EdDSA + const PS256 + const PS384 + const PS512 + const RS256 + const RS384 + const RS512 + func AlgOf(pub crypto.PublicKey) (Alg, error) + type ClaimsFunc func(ctx context.Context, u auth.User, s auth.Session) (map[string]any, error) + func UserClaim(name string, ...) ClaimsFunc + type JWK struct + Alg string + Curve string + E string + KeyID string + KeyType string + N string + Use string + X string + Y string + type JWKS struct + Keys []JWK + type Option func(*Plugin) + func AlgorithmKeys(keys ...crypto.Signer) Option + func Audience(aud ...string) Option + func ClaimSource(fn ClaimsFunc) Option + func Claims(fn func(ctx context.Context, u auth.User) map[string]any) Option + func IssueOnSession() Option + func Issuer(iss string) Option + func JWKSPath(path string) Option + func Payload(fn PayloadFunc) Option + func PreviousKeys(keys ...crypto.PublicKey) Option + func RemoteJWKS(rawURL string) Option + func Subject(fn SubjectFunc) Option + func WithSigner(s Signer) Option + func WithSigningKey(k crypto.Signer) Option + func WithTTL(d time.Duration) Option + func WithTemplate(name string, t Template) Option + type PayloadFunc func(ctx context.Context, u auth.User, s auth.Session) map[string]any + type Plugin struct + func New(opts ...Option) *Plugin + func (p *Plugin) Init(a *auth.Auth) error + func (p *Plugin) JWKSRoute() string + func (p *Plugin) JWKSURL() string + func (p *Plugin) Name() string + func (p *Plugin) OperationHooks() []auth.OperationHook + func (p *Plugin) Operations() []auth.Operation + func (p *Plugin) OptionErr() error + func (p *Plugin) PublicKeys() JWKS + func (p *Plugin) Sign(ctx context.Context, in SignRequest) (TokenResult, error) + func (p *Plugin) TemplateNames() []string + func (p *Plugin) TemplateToken(ctx context.Context, name string) (TokenResult, error) + func (p *Plugin) Token(ctx context.Context) (TokenResult, error) + func (p *Plugin) Validate(c *auth.Config) error + type RSAPublicKey struct + Alg Alg + Key *rsa.PublicKey + type RemoteKeys struct + Now func() time.Time + func NewRemoteKeys(url string, hc *http.Client) *RemoteKeys + func (r *RemoteKeys) LastError() error + func (r *RemoteKeys) Lookup(kid string) (crypto.PublicKey, bool) + type SignRequest struct + Alg Alg + Audience []string + Claims map[string]any + KeyID string + SessionID string + Subject string + TTL time.Duration + Type string + type Signer interface + PublicKeys func() []crypto.PublicKey + Sign func(ctx context.Context, key crypto.PublicKey, signingInput []byte) ([]byte, error) + func Rotating(seed []byte, interval, grace time.Duration) Signer + type SubjectFunc func(ctx context.Context, u auth.User, s auth.Session) string + type Template struct + Algs []string + Audience []string + Claims ClaimsFunc + Issuer string + Key TemplateKey + Subject SubjectFunc + TTL time.Duration + Type string + type TemplateKey interface + func HMACKey(secret []byte) TemplateKey + func PrivateKey(k crypto.Signer, kid string) TemplateKey + func PublishedKey(alg Alg, kid string) TemplateKey + type TemplateRequest struct + Template string + type TokenResult struct + ExpiresAt time.Time + Token string + type Verified struct + Actor string + ExpiresAt time.Time + Extra map[string]json.RawMessage + SessionID string + Subject string + type Verifier struct + Audience string + Issuer string + Keys map[string]crypto.PublicKey + Leeway time.Duration + Lookup func(kid string) (crypto.PublicKey, bool) + Now func() time.Time + Types []string + func (v Verifier) Verify(token string) (Verified, error)