Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fapitest/key_rendering_guard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var keyHolders = map[string]keyHolder{
covers: []string{
"federation.HistoricalKeysIssueDependencies.Signer", "federation.ResolveIssueDependencies.Signer",
"federation.SelfIssueDependencies.Signer", "federation.SubordinateIssueDependencies.Signer",
"federation.jwksDependencyFields.signer",
"federation.TrustMarkIssueDependencies.Signer",
},
build: func(t *testing.T) (any, []string) {
Expand Down
19 changes: 15 additions & 4 deletions federation/dependencies_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,19 @@ func formatDependencies(f fmt.State, verb rune, signer crypto.Signer, alg fapi.S
redact.Format(f, verb, sh, "federation.issueDependenciesShadow", typeName)
}

func formatJWKSDependencies(f fmt.State, verb rune, signer crypto.Signer, alg fapi.SignatureAlgorithm, kid string, jwks json.RawMessage, clock Clock, typeName string) {
sh := jwksIssueDependenciesShadow{Signer: signerMask(signer), Algorithm: alg, KeyID: kid, JWKS: jwks, Clock: clock}
// jwksDependencyFields are the fields HistoricalKeysIssueDependencies
// and SelfIssueDependencies share, for formatJWKSDependencies.
type jwksDependencyFields struct {
signer crypto.Signer
alg fapi.SignatureAlgorithm
kid string
jwks json.RawMessage
clock Clock
}

func formatJWKSDependencies(f fmt.State, verb rune, fields jwksDependencyFields, typeName string) {
signer := fields.signer
sh := jwksIssueDependenciesShadow{Signer: signerMask(signer), Algorithm: fields.alg, KeyID: fields.kid, JWKS: fields.jwks, Clock: fields.clock}
redact.Format(f, verb, sh, "federation.jwksIssueDependenciesShadow", typeName)
}

Expand All @@ -80,7 +91,7 @@ func dependenciesLogValue(signer crypto.Signer, alg fapi.SignatureAlgorithm, kid
// Format implements fmt.Formatter: d prints its fields, with only
// [REDACTED] for Signer, under every verb and flag.
func (d HistoricalKeysIssueDependencies) Format(f fmt.State, verb rune) {
formatJWKSDependencies(f, verb, d.Signer, d.Algorithm, d.KeyID, d.JWKS, d.Clock, "federation.HistoricalKeysIssueDependencies")
formatJWKSDependencies(f, verb, jwksDependencyFields{signer: d.Signer, alg: d.Algorithm, kid: d.KeyID, jwks: d.JWKS, clock: d.Clock}, "federation.HistoricalKeysIssueDependencies")
}

// LogValue implements slog.LogValuer: d's fields, with only
Expand Down Expand Up @@ -128,7 +139,7 @@ func (ResolveIssueDependencies) MarshalJSON() ([]byte, error) {
// Format implements fmt.Formatter: d prints its fields, with only
// [REDACTED] for Signer, under every verb and flag.
func (d SelfIssueDependencies) Format(f fmt.State, verb rune) {
formatJWKSDependencies(f, verb, d.Signer, d.Algorithm, d.KeyID, d.JWKS, d.Clock, "federation.SelfIssueDependencies")
formatJWKSDependencies(f, verb, jwksDependencyFields{signer: d.Signer, alg: d.Algorithm, kid: d.KeyID, jwks: d.JWKS, clock: d.Clock}, "federation.SelfIssueDependencies")
}

// LogValue implements slog.LogValuer: d's fields, with only
Expand Down
Loading