Skip to content

Commit db960d1

Browse files
committed
Fix openid discovery docs with external jwt signer.
If the external jwt signer is enabled, publishing OIDC discovery docs and keys fails because the PublicKeysGetter is not wired correctly. Set the public keys getter on startup so public key discovery works in that case as well.
1 parent 1869f6f commit db960d1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
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

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)