Skip to content

Commit 21e09f9

Browse files
Always set service-account-jwks-uri to LB URL even with custom issuer
Signed-off-by: Shaza Aldawamneh <[email protected]>
1 parent 0bec046 commit 21e09f9

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

pkg/operator/configobservation/auth/auth_serviceaccountissuer.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,14 @@ func observedConfig(existingConfig map[string]interface{},
128128
// If the issuer is not set in KAS, we rely on the config-overrides.yaml to set both
129129
// the issuer and the api-audiences but configure the jwks-uri to point to
130130
// the LB so that it does not default to KAS IP which is not included in the serving certs
131-
if observedActiveIssuer == defaultServiceAccountIssuerValue {
132-
infrastructureConfig, err := getInfrastructureConfig("cluster")
133-
if err != nil {
134-
return existingConfig, append(errs, err)
135-
}
136-
if apiServerExternalURL := infrastructureConfig.Status.APIServerURL; len(apiServerExternalURL) == 0 {
137-
return existingConfig, append(errs, fmt.Errorf("APIServerURL missing from infrastructure/cluster"))
138-
} else {
139-
apiServerArguments["service-account-jwks-uri"] = []interface{}{apiServerExternalURL + "/openid/v1/jwks"}
140-
}
131+
infrastructureConfig, err := getInfrastructureConfig("cluster")
132+
if err != nil {
133+
return existingConfig, append(errs, err)
134+
}
135+
if apiServerExternalURL := infrastructureConfig.Status.APIServerURL; len(apiServerExternalURL) == 0 {
136+
return existingConfig, append(errs, fmt.Errorf("APIServerURL missing from infrastructure/cluster"))
137+
} else {
138+
apiServerArguments["service-account-jwks-uri"] = []interface{}{apiServerExternalURL + "/openid/v1/jwks"}
141139
}
142140

143141
return map[string]interface{}{"apiServerArguments": apiServerArguments}, errs

pkg/operator/configobservation/auth/auth_serviceaccountissuer_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestObservedConfig(t *testing.T) {
6767
expectedIssuer: "https://example.com",
6868
trustedIssuers: []string{defaultServiceAccountIssuerValue},
6969
expectedTrustedIssuers: []string{defaultServiceAccountIssuerValue},
70-
expectInternalJWKI: false, // this proves we remove the internal api LB when custom value is set
70+
expectInternalJWKI: true, // now jwks-uri should always point to LB URL
7171
expectedChange: true,
7272
},
7373
{
@@ -106,6 +106,14 @@ func TestObservedConfig(t *testing.T) {
106106
expectedIssuer: defaultServiceAccountIssuerValue,
107107
expectInternalJWKI: true,
108108
},
109+
{
110+
name: "custom issuer, no previous issuer",
111+
existingIssuer: "",
112+
issuer: "https://custom.com",
113+
expectedIssuer: "https://custom.com",
114+
expectInternalJWKI: true, // should always set jwks-uri
115+
expectedChange: true,
116+
},
109117
} {
110118
t.Run(tc.name, func(t *testing.T) {
111119
testRecorder := events.NewInMemoryRecorder("SAIssuerTest", clock.RealClock{})

0 commit comments

Comments
 (0)