Documentation
¶
Overview ¶
Package oidcjwt verifies JWTs using OIDC discovery.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Claims ¶
type Claims struct {
// Claims from RFC7519
Issuer string
Subject string
Audiences []string
Expiration time.Time
NotBefore time.Time
IssuedAt time.Time
JTI string
KubernetesClaims
SubstrateClaims
}
Claims contains standard JWT claims and, when present, Kubernetes ServiceAccount claims and Substrate's own claims.
type KeySource ¶
KeySource supplies the public keys a Verifier checks signatures with. The Verifier calls Keys on first use, every jwksRefreshInterval, and once per jwksRefreshRetryInterval when a token names a key ID it does not have, so a source may read its backing store on every call.
func FileKeySource ¶
FileKeySource reads a JWK set from a file, for a verifier that is handed the issuer's public keys directly rather than fetching them over discovery. The file is re-read on every call, so a rotated set is picked up on the verifier's next refresh. For that to work the file must be replaced atomically, as a projected volume mounted without subPath is: an in-place rewrite can be read half-written, and a subPath mount never sees the rotation. The file holds public keys only.
type KubernetesClaims ¶
type KubernetesClaims struct {
Namespace string
ServiceAccountName string
ServiceAccountUID string
PodName string
PodUID string
SecretName string
SecretUID string
NodeName string
NodeUID string
WarnAfter time.Time
}
KubernetesClaims contains claims added to Kubernetes ServiceAccount tokens.
type Option ¶
type Option func(*Verifier)
Option configures a Verifier.
func WithSubstrateClaims ¶
func WithSubstrateClaims() Option
WithSubstrateClaims makes Verify decode Substrate's claims into Claims.SubstrateClaims and refuse a token that carries both or a malformed one. It is for the verifier of the actor-id JWT issuer, whose tokens are the only ones those claims mean anything on.
type SubstrateClaims ¶
type SubstrateClaims struct {
Kind actoridjwt.Kind
Substrate *actoridjwt.WireSubstrateClaims
}
SubstrateClaims are the claims the actor-id JWT issuer adds to the tokens it mints. Kind says which claim the token carried, KindActor for the actor's own token or KindWorkerForActor for a Substrate component acting on the actor's behalf, and Substrate holds it. A token carrying neither has KindUnspecified and a nil Substrate. A token carrying both is refused.
Only a Verifier built with WithSubstrateClaims fills these in. Any issuer can put the claim names in a token, so a verifier for another issuer leaves them alone, whatever they hold.
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier verifies JWTs from one trusted OIDC issuer and caches its signing keys. Keys are refreshed periodically and, at a bounded rate, when a token names an unknown key ID.
func NewVerifier ¶
NewVerifier returns a verifier for issuer. A token is accepted when at least one of its audiences matches audiences.