Skip to content

Commit

Permalink
configobservation/auth: remove webhook token authenticator when auth …
Browse files Browse the repository at this point in the history
…type is OIDC
  • Loading branch information
liouk committed Nov 15, 2024
1 parent 41278f4 commit 5cdfb5e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/operator/configobservation/auth/webhook_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"

configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/library-go/pkg/operator/configobserver"
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
Expand Down Expand Up @@ -62,7 +63,7 @@ func ObserveWebhookTokenAuthenticator(genericListers configobserver.Listers, rec
}

observedWebhookConfigured := len(webhookSecretName) > 0
if observedWebhookConfigured {
if observedWebhookConfigured && auth.Spec.Type != configv1.AuthenticationTypeOIDC {
// retrieve the secret from config and validate it, don't proceed on failure
kubeconfigSecret, err := listers.ConfigSecretLister().Secrets("openshift-config").Get(webhookSecretName)
if err != nil {
Expand All @@ -87,6 +88,15 @@ func ObserveWebhookTokenAuthenticator(genericListers configobserver.Listers, rec
resourcesynccontroller.ResourceLocation{Namespace: operatorclient.GlobalUserSpecifiedConfigNamespace, Name: webhookSecretName},
)
} else {
if auth.Spec.Type == configv1.AuthenticationTypeOIDC {
if _, err := listers.ConfigmapLister_.ConfigMaps(operatorclient.TargetNamespace).Get(AuthConfigCMName); errors.IsNotFound(err) {
// auth-config does not exist in target namespace yet; do not remove webhook until it's there
return existingConfig, errs
} else if err != nil {
return existingConfig, append(errs, err)
}
}

// don't sync anything and remove whatever we synced
resourceSyncer.SyncSecret(
resourcesynccontroller.ResourceLocation{Namespace: operatorclient.TargetNamespace, Name: "webhook-authenticator"},
Expand Down

0 comments on commit 5cdfb5e

Please sign in to comment.