Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Fix: Kubernetes native auth
Daniel Hougaard023a0d99ab22
diff --git a/k8-operator/api/v1alpha1/infisicalsecret_types.go b/k8-operator/api/v1alpha1/infisicalsecret_types.goindex b0cc49a8f6..6ea7e4c7b3 100644--- a/k8-operator/api/v1alpha1/infisicalsecret_types.go+++ b/k8-operator/api/v1alpha1/infisicalsecret_types.go@@ -33,13 +33,20 @@ type UniversalAuthDetails struct {type KubernetesAuthDetails struct {// +kubebuilder:validation:RequiredIdentityID string `json:"identityId"`- // +kubebuilder:validation:Optional- ServiceAccountTokenPath string `json:"serviceAccountTokenPath"`+ // +kubebuilder:validation:Required+ ServiceAccountRef KubernetesServiceAccountRef `json:"serviceAccountRef"`// +kubebuilder:validation:RequiredSecretsScope MachineIdentityScopeInWorkspace `json:"secretsScope"`}+type KubernetesServiceAccountRef struct {+ // +kubebuilder:validation:Required+ Name string `json:"name"`+ // +kubebuilder:validation:Required+ Namespace string `json:"namespace"`+}+type AWSIamAuthDetails struct {// +kubebuilder:validation:RequiredIdentityID string `json:"identityId"`diff --git a/k8-operator/controllers/infisicalsecret_auth.go b/k8-operator/controllers/infisicalsecret_auth.goindex a2930b3303..44861df875 100644--- a/k8-operator/controllers/infisicalsecret_auth.go+++ b/k8-operator/controllers/infisicalsecret_auth.go@@ -6,6 +6,7 @@ import ("fmt""github.com/Infisical/infisical/k8-operator/api/v1alpha1"+ "github.com/Infisical/infisical/k8-operator/packages/util"infisicalSdk "github.com/infisical/go-sdk")@@ -31,6 +32,12 @@ var AuthStrategy = struct {GCP_IAM_MACHINE_IDENTITY: "GCP_IAM_MACHINE_IDENTITY",}+type AuthenticationDetails struct {+ authStrategy AuthStrategyType+ machineIdentityScope v1alpha1.MachineIdentityScopeInWorkspace // This will only be set if a machine identity auth method is used (e.g. UniversalAuth or KubernetesAuth, etc.)+ isMachineIdentityAuth bool+}+var ErrAuthNotApplicable = errors.New("authentication not applicable")func (r *InfisicalSecretReconciler) handleUniversalAuth(ctx context.Context, infisicalSecret v1alpha1.InfisicalSecret, infisicalClient infisicalSdk.InfisicalClientInterface) (AuthenticationDetails, error) {@@ -65,7 +72,12 @@ func (r *InfisicalSecretReconciler) handleKubernetesAuth(ctx context.Context, inreturn AuthenticationDetails{}, ErrAuthNotApplicable}- _, err := infisicalClient.Auth().KubernetesAuthLogin(kubernetesAuthSpec.IdentityID, kubernetesAuthSpec.ServiceAccountTokenPath)+ serviceAccountToken, err := util.GetServiceAccountToken(r.Client, kubernetesAuthSpec.ServiceAccountRef.Namespace, kubernetesAuthSpec.ServiceAccountRef.Name)+ if err != nil {+ return AuthenticationDetails{}, fmt.Errorf("unable to get service account token [err=%s]", err)+ }++ _, err = infisicalClient.Auth().KubernetesRawServiceAccountTokenLogin(kubernetesAuthSpec.IdentityID, serviceAccountToken)if err != nil {return AuthenticationDetails{}, fmt.Errorf("unable to login with Kubernetes native auth [err=%s]", err)}