Documentation
¶
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
}
func NewSigner ¶
func NewSigner( audience string, duration time.Duration, issuer string, privateKey *crypto.Signer, kid string, mapper *dmapper.Mapper, ) (*Signer, error)
NewSigner creates a new signer.
func (*Signer) Duration ¶ added in v0.2.78
Duration returns the lifetime each signed token is valid for. Cache implementations should subtract a skew from this to ensure a cached token always has meaningful remaining life on hit.
func (*Signer) Project ¶ added in v0.2.78
Project derives the deterministic claim set that will be signed for a given signingContext. iat/exp/jti are deliberately omitted: they identify the token, not the identity, and putting them in the projection defeats the caller's ability to use the projection as a cache key.
The signer's audience is the AUTHORITATIVE outbound aud: Project is always called to re-issue a token for a SPECIFIC downstream target (the per-function FAT path in proxy.go), and re-using the inbound aud would make the issued token transferable to a different audience than the signer was configured for. Concretely: a user logs in at the host (aud=["https://<host>"]) and then calls a function; proxy.go builds a signer with audience=fn.Status.URL, but the previous logic reused the inbound host aud, so the function rejected the FAT with "token has invalid audience". Always use s.audience.
func (*Signer) Sign ¶
Sign is a convenience wrapper that runs Project then SignProjected. Direct callers that want to cache should call the two steps separately so the cache key reflects the deterministic projection rather than the raw inbound context (which routinely includes per-request headers like Traceparent that defeat the cache).
func (*Signer) SignProjected ¶ added in v0.2.78
SignProjected attaches the per-token identifiers (iat/exp/jti) to an already-projected claim set and signs it. Use this in tandem with Project when caching to skip the projection step on a cache hit.
The projection has the LAST WORD on every field — including iat/exp/jti. The original Sign emitted mapper output last via maps.Copy, and several call sites depend on that semantic (e.g. dev-mode tests that inject exp=-1 via a ClaimMappings rule to synthesize an expired token). Default iat/exp/jti are written first, then maps.Copy(outboundClaims, projected) overrides anything the projection already carries.