Skip to content

Commit a688664

Browse files
authored
Merge pull request kubernetes#131493 from hoskeri/externaljwt-oidc-discovery-fix
Externaljwt OIDC discovery fix
2 parents 0abee6b + db960d1 commit a688664

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

pkg/controlplane/apiserver/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func CreateConfig(
378378

379379
if len(opts.Authentication.ServiceAccounts.KeyFiles) > 0 {
380380
// Load and set the public keys.
381-
var pubKeys []interface{}
381+
var pubKeys []any
382382
for _, f := range opts.Authentication.ServiceAccounts.KeyFiles {
383383
keys, err := keyutil.PublicKeysFromFile(f)
384384
if err != nil {
@@ -391,7 +391,10 @@ func CreateConfig(
391391
return nil, nil, fmt.Errorf("failed to set up public service account keys: %w", err)
392392
}
393393
config.ServiceAccountPublicKeysGetter = keysGetter
394+
} else if opts.Authentication.ServiceAccounts.ExternalPublicKeysGetter != nil {
395+
config.ServiceAccountPublicKeysGetter = opts.Authentication.ServiceAccounts.ExternalPublicKeysGetter
394396
}
397+
395398
config.ServiceAccountIssuerURL = opts.Authentication.ServiceAccounts.Issuers[0]
396399
config.ServiceAccountJWKSURI = opts.Authentication.ServiceAccounts.JWKSURI
397400

pkg/controlplane/apiserver/options/validation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func TestValidateOptions(t *testing.T) {
237237
}
238238
}
239239

240-
func TestValidateServcieAccountTokenSigningConfig(t *testing.T) {
240+
func TestValidateServiceAccountTokenSigningConfig(t *testing.T) {
241241
tests := []struct {
242242
name string
243243
featureEnabled bool

test/integration/serviceaccount/external_jwt_signer_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ func TestExternalJWTSigningAndAuth(t *testing.T) {
7777
})
7878
defer tearDownFn()
7979

80+
// Validate that OIDC discovery doc and keys are available.
81+
for _, p := range []string{
82+
"/.well-known/openid-configuration",
83+
"/openid/v1/jwks",
84+
} {
85+
if _, err := client.CoreV1().RESTClient().Get().AbsPath(p).DoRaw(ctx); err != nil {
86+
t.Errorf("Validating OIDC discovery failed, error getting api path %q: %v", p, err)
87+
}
88+
}
89+
8090
// Create Namesapce (ns-1) to work with.
8191
if _, err := client.CoreV1().Namespaces().Create(ctx, &corev1.Namespace{
8292
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)