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
feat(kubernetes-auth): add wildcard and regex support for kube auth
Tre Dubrava2421cab86cbb
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.tsindex 9e5eebc100..00b603152d 100644--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts@@ -2,6 +2,7 @@ import { ForbiddenError, subject } from "@casl/ability";import { requestContext } from "@fastify/request-context";import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";import https from "https";+import picomatch from "picomatch";import RE2 from "re2";import {@@ -501,7 +502,7 @@ export const identityKubernetesAuthServiceFactory = ({const isNamespaceAllowed = identityKubernetesAuth.allowedNamespaces.split(",").map((namespace) => namespace.trim())- .some((namespace) => namespace === targetNamespace);+ .some((namespace) => namespace === targetNamespace || picomatch.isMatch(targetNamespace, namespace));if (!isNamespaceAllowed)throw new UnauthorizedError({@@ -515,7 +516,7 @@ export const identityKubernetesAuthServiceFactory = ({const isNameAllowed = identityKubernetesAuth.allowedNames.split(",").map((name) => name.trim())- .some((name) => name === targetName);+ .some((name) => name === targetName || picomatch.isMatch(targetName, name));if (!isNameAllowed)throw new UnauthorizedError({diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsxindex 4d13469c8b..4ce02dda78 100644--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx@@ -219,22 +219,14 @@ export const IdentityKubernetesAuthForm = ({});if (role.bound_service_account_names?.length > 0) {- // In Vault, "*" means allow all; in Infisical, empty field means allow any- const allowedNames = role.bound_service_account_names.includes("*")- ? ""- : role.bound_service_account_names.join(", ");- setValue("allowedNames", allowedNames, {+ setValue("allowedNames", role.bound_service_account_names.join(", "), {shouldDirty: true,shouldTouch: true});}if (role.bound_service_account_namespaces?.length > 0) {- // In Vault, "*" means allow all; in Infisical, empty field means allow any- const allowedNamespaces = role.bound_service_account_namespaces.includes("*")- ? ""- : role.bound_service_account_namespaces.join(", ");- setValue("allowedNamespaces", allowedNamespaces, {+ setValue("allowedNamespaces", role.bound_service_account_namespaces.join(", "), {shouldDirty: true,shouldTouch: true});@@ -575,11 +567,27 @@ export const IdentityKubernetesAuthForm = ({label="Allowed Namespaces"isError={Boolean(error)}errorText={error?.message}- tooltipText="A comma-separated list of trusted namespaces that service accounts must belong to authenticate with Infisical."+ tooltipText={+ <div className="flex flex-col gap-1">+ <p>+ A comma-separated list of trusted namespaces that service accounts must belong+ to authenticate with Infisical.+ </p>+ <p>+ Regex and Wildcard patterns are supported. Use{" "}+ <span className="font-mono">*</span> to explicitly allow all.+ </p>+ <p className="text-sm">+ Examples: <span className="font-mono">dev-*</span>,{" "}+ <span className="font-mono">staging-*</span>,{" "}+ <span className="font-mono">team-{"{a,b}"}</span>+ </p>+ </div>+ }><Input{...field}- placeholder="namespaceA, namespaceB"+ placeholder="namespaceA, namespaceB, dev-*"type="text"autoComplete="off"/>@@ -594,12 +602,29 @@ export const IdentityKubernetesAuthForm = ({<FormControllabel="Allowed Service Account Names"isError={Boolean(error)}- tooltipText="An optional comma-separated list of trusted service account names that are allowed to authenticate with Infisical. Leave empty to allow any service account."+ tooltipText={+ <div className="flex flex-col gap-1">+ <p>+ An optional comma-separated list of trusted service account names that are+ allowed to authenticate with Infisical. Leave empty to allow any service+ account.+ </p>+ <p>+ Regex and Wildcard patterns are supported. Use{" "}+ <span className="font-mono">*</span> to explicitly allow all.+ </p>+ <p className="text-sm">+ Examples: <span className="font-mono">dev-*</span>,{" "}+ <span className="font-mono">staging-*</span>,{" "}+ <span className="font-mono">team-{"{a,b}"}</span>+ </p>+ </div>+ }errorText={error?.message}><Input{...field}- placeholder="service-account-1-name, service-account-1-name"+ placeholder="service-account-1-name, sa-*, app-*-prod"autoComplete="off"/></FormControl>