Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add managed identity method to azure key vault connections

DimitrisStaratzis1730709a3b5c
diff --git a/backend/AGENTS.md b/backend/AGENTS.md
index 59d352893f..285d6c92b1 100644
--- a/backend/AGENTS.md
+++ b/backend/AGENTS.md
@@ -1216,6 +1216,15 @@ The issuer URL and each consumer's `sub` format are one-way doors: customers cop
route. The 24h lead makes a stale set safe. Empty sets are never cached, in Redis or over HTTP.
- **Fresh keys are read on the primary.** Signing and the JWKS a rotation caches pass a `tx` to
`getPublicKey` and `signWithKmsKey`, because a read replica may not have a key created moments earlier.
+- **Every signed token is audit logged** (`issue-oidc-token`) inside `signToken`, so a new consumer gets it
+ for free and never logs on its own.
+- **Connections sign for their own ID only.** The subject is `getAppConnectionOidcSubject(connection.id)`,
+ built server-side from the connection row, and the token is only ever sent to the provider's token
+ endpoint, never returned to a caller. The form picks a new connection's ID so the subject can be shown
+ before it exists; create rejects an ID that is already in use before validation signs anything. The
+ Azure Key Vault `managed-identity` method is the reference consumer: copy its
+ `getManagedIdentityAccessToken`, which caches the provider's access token in the credentials like the
+ secret-based methods do.
### Enterprise (EE) Features
diff --git a/backend/src/ee/services/audit-log/audit-log-event-classes.ts b/backend/src/ee/services/audit-log/audit-log-event-classes.ts
index ec072c6354..31aa23dc0d 100644
--- a/backend/src/ee/services/audit-log/audit-log-event-classes.ts
+++ b/backend/src/ee/services/audit-log/audit-log-event-classes.ts
@@ -70,6 +70,7 @@ const AUTHENTICATION_EVENT_TYPES: readonly EventType[] = [
EventType.AGENT_VAULT_PROXY_ENROLL,
EventType.OAUTH_CLIENT_AUTHORIZE,
EventType.OAUTH_CLIENT_TOKEN_EXCHANGE,
+ EventType.ISSUE_OIDC_TOKEN,
EventType.GATEWAY_ENROLL,
EventType.GATEWAY_CONNECT,
EventType.RESOURCE_AUTH_METHOD_LOGIN,
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 785a2f83f3..a62a958ffc 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -957,6 +957,9 @@ export enum EventType {
OAUTH_CLIENT_AUTHORIZE = "oauth-client-authorize",
OAUTH_CLIENT_TOKEN_EXCHANGE = "oauth-client-token-exchange",
+ // OIDC Issuer
+ ISSUE_OIDC_TOKEN = "issue-oidc-token",
+
// Email Domains
CREATE_EMAIL_DOMAIN = "create-email-domain",
VERIFY_EMAIL_DOMAIN = "verify-email-domain",
@@ -7864,6 +7867,15 @@ interface OauthClientTokenExchangeEvent {
};
}
+interface IssueOidcTokenEvent {
+ type: EventType.ISSUE_OIDC_TOKEN;
+ metadata: {
+ subject: string;
+ audience: string;
+ tokenId: string;
+ };
+}
+
interface CreateEmailDomainEvent {
type: EventType.CREATE_EMAIL_DOMAIN;
metadata: {
@@ -8925,6 +8937,7 @@ export type Event =
| RotateOauthClientSecretEvent
| OauthClientAuthorizeEvent
| OauthClientTokenExchangeEvent
+ | IssueOidcTokenEvent
| CreateEmailDomainEvent
| VerifyEmailDomainEvent
| DeleteEmailDomainEvent
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index aae6ff5b7e..a0840d2be6 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2913,6 +2913,7 @@ export const AppConnections = {
credentials: `The credentials used to connect with ${appName}.`,
method: `The method used to authenticate with ${appName}.`,
stsEndpoint: `An optional custom endpoint URL for the AWS STS API to use when connecting with ${appName}.`,
+ id: `The ID to give the ${appName} Connection. Required for the managed-identity method: Infisical signs its tokens with the subject 'app-connection:<id>', so that subject must be on the federated credential before the connection is created.`,
isPlatformManagedCredentials: `Whether or not the ${appName} Connection credentials should be managed by Infisical. Once enabled this cannot be reversed.`,
projectId: `The ID of the project to create the ${appName} Connection in.`,
isAutoRotationEnabled: `Whether or not automatic credential rotation is enabled for the ${appName} Connection.`,
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index de43e9bb26..f4fecc1fa9 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1088,8 +1088,6 @@ export const registerRoutes = async (
envConfig
});
- const oidcIssuerService = oidcIssuerServiceFactory({ kmsDAL, kmsService, keyStore });
-
const encryptionKeyRotationService = encryptionKeyRotationServiceFactory({
kmsService,
kmsRootConfigDAL,
@@ -1347,6 +1345,8 @@ export const registerRoutes = async (
})
});
+ const oidcIssuerService = oidcIssuerServiceFactory({ kmsDAL, kmsService, keyStore, auditLogService });
+
const membershipUserService = membershipUserServiceFactory({
licenseService,
membershipRoleDAL,
@@ -2391,7 +2391,8 @@ export const registerRoutes = async (
microsoftTeamsService,
telemetryService,
projectFolderGrantDAL,
- orgDAL
+ orgDAL,
+ oidcIssuerService
});
const secretQueueService = secretQueueFactory({
@@ -3341,7 +3342,8 @@ export const registerRoutes = async (
appConnectionCredentialRotationService,
identityUaDAL,
gitHubAppDAL,
- keyStore
+ keyStore,
+ oidcIssuerService
});
const delegatedApprovalCallbackService = delegatedApprovalCallbackServiceFactory({
@@ -3757,7 +3759,8 @@ export const registerRoutes = async (
certificateSyncDAL,
gatewayV2Service,
gatewayPoolService,
- telemetryService
+ telemetryService,
+ oidcIssuerService
});
const pkiSyncCleanup = pkiSyncCleanupQueueServiceFactory({
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
index 946c50f53a..4de55435cb 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
@@ -16,6 +16,7 @@ import { AuthMode } from "@app/services/auth/auth-type";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
type TAppConnectionCreateSchema<I extends TAppConnectionInput> = z.ZodType<{
+ id?: string;
name: string;
method: I["method"];
credentials: I["credentials"];
@@ -343,6 +344,7 @@ export const buildCreateAppConnectionRoute = <I extends TAppConnectionInput>(
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
const {
+ id,
name,
method,
credentials,
@@ -358,6 +360,7 @@ export const buildCreateAppConnectionRoute = <I extends TAppConnectionInput>(
const appConnection = await server.services.appConnection.createAppConnection(
{
+ id,
name,
method,
app,
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index b86ec73f9b..7c6c42abae 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -29,6 +29,7 @@ import { TGitHubAppDALFactory } from "@app/services/github-app/github-app-dal";
import { TIdentityUaDALFactory } from "@app/services/identity-ua/identity-ua-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { SECRET_SYNC_CONNECTION_MAP } from "@app/services/secret-sync/secret-sync-maps";
import {
@@ -84,7 +85,7 @@ import {
getAzureEntraIdConnectionListItem,
validateAzureEntraIdConnectionCredentials
} from "./azure-entra-id";
-import { AzureKeyVaultConnectionMethod } from "./azure-key-vault";
+import { AzureKeyVaultConnectionMethod, TAzureKeyVaultConnectionConfig } from "./azure-key-vault";
import {
getAzureKeyVaultConnectionListItem,
validateAzureKeyVaultConnectionCredentials
@@ -644,6 +645,7 @@ export const validateAppConnectionCredentials = async (
gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
keyStore: Pick<TKeyStoreFactory, "setItemWithExpiryNX">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
actorId?: string;
}
): Promise<TAppConnection["credentials"]> => {
@@ -657,7 +659,11 @@ export const validateAppConnectionCredentials = async (
})) as TAppConnectionCredentialsValidator,
[AppConnection.GitHubRadar]: validateGitHubRadarConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.GCP]: validateGcpConnectionCredentials as TAppConnectionCredentialsValidator,
- [AppConnection.AzureKeyVault]: validateAzureKeyVaultConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.AzureKeyVault]: ((config: TAppConnectionConfig) =>
+ validateAzureKeyVaultConnectionCredentials(
+ config as TAzureKeyVaultConnectionConfig,
+ deps.oidcIssuerService
+ )) as TAppConnectionCredentialsValidator,
[AppConnection.AzureAppConfiguration]:
validateAzureAppConfigurationConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.AzureClientSecrets]:
@@ -896,6 +902,8 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
return "API Token";
case OVHConnectionMethod.Certificate:
return "Certificate";
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
+ return "Managed Identity";
default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new Error(`Unhandled App Connection Method: ${method}`);
diff --git a/backend/src/services/app-connection/app-connection-service.test.ts b/backend/src/services/app-connection/app-connection-service.test.ts
index a716aef5a1..41c659003e 100644
--- a/backend/src/services/app-connection/app-connection-service.test.ts
+++ b/backend/src/services/app-connection/app-connection-service.test.ts
@@ -11,6 +11,7 @@ import { ActorType, AuthMethod } from "@app/services/auth/auth-type";
import { AppConnection } from "./app-connection-enums";
import { appConnectionServiceFactory } from "./app-connection-service";
+import { AzureKeyVaultConnectionMethod } from "./azure-key-vault";
const ACTOR_ORG_ID = "org-1";
const CONNECTION_ID = "conn-1";
@@ -28,7 +29,8 @@ class PermissionReached extends Error {}
const buildService = (
connection: { orgId: string; projectId: string | null; app?: AppConnection },
- abilities: { org?: unknown; project?: unknown } = {}
+ abilities: { org?: unknown; project?: unknown } = {},
+ extraDeps: Record<string, unknown> = {}
) => {
const permissionService = {
getOrgPermission: vi.fn(async () => {
@@ -57,7 +59,8 @@ const buildService = (
}))
},
permissionService,
- licenseService: { getPlan: vi.fn(async () => ({})) }
+ licenseService: { getPlan: vi.fn(async () => ({})) },
+ ...extraDeps
};
const deps = new Proxy(overrides, {
@@ -203,3 +206,35 @@ describe("validateAppConnectionUsageById refuses connections the caller cannot u
).rejects.toThrow(BadRequestError);
});
});
+
+describe("createAppConnection", () => {
+ test("refuses an ID another connection has, before signing a token for it", async () => {
+ const signToken = vi.fn();
+ const { service } = buildService(
+ { orgId: ACTOR_ORG_ID, projectId: null },
+ {
+ org: createMongoAbility([
+ { action: OrgPermissionAppConnectionActions.Create, subject: OrgPermissionSubjects.AppConnections }
+ ])
+ },
+ { oidcIssuerService: { signToken } }
+ );
+
+ await expect(
+ service.createAppConnection(
+ {
+ id: CONNECTION_ID,
+ name: "key-vault",
+ app: AppConnection.AzureKeyVault,
+ method: AzureKeyVaultConnectionMethod.ManagedIdentity,
+ credentials: {
+ tenantId: "00000000-0000-0000-0000-000000000000",
+ clientId: "00000000-0000-0000-0000-000000000000"
+ }
+ },
+ actor
+ )
+ ).rejects.toThrow(`App Connection ID '${CONNECTION_ID}' is already in use`);
+ expect(signToken).not.toHaveBeenCalled();
+ });
+});
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 09c8b539e9..0ec8c493f3 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -44,6 +44,7 @@ import {
import { TGitHubAppDALFactory } from "@app/services/github-app/github-app-dal";
import { TIdentityUaDALFactory } from "@app/services/identity-ua/identity-ua-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TProjectDALFactory } from "@app/services/project/project-dal";
@@ -243,6 +244,7 @@ export type TAppConnectionServiceFactoryDep = {
TKeyStoreFactory,
"setItemWithExpiryNX" | "deleteItem" | "getItem" | "setItemWithExpiry" | "acquireLock"
>;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
export type TAppConnectionServiceFactory = ReturnType<typeof appConnectionServiceFactory>;
@@ -357,7 +359,8 @@ export const appConnectionServiceFactory = ({
appConnectionCredentialRotationService,
identityUaDAL,
gitHubAppDAL,
- keyStore
+ keyStore,
+ oidcIssuerService
}: TAppConnectionServiceFactoryDep) => {
const listAppConnections = async (actor: OrgServiceActor, app?: AppConnection, projectId?: string) => {
let appConnections: TAppConnections[];
@@ -646,6 +649,11 @@ export const appConnectionServiceFactory = ({
}
}
+ // Validation signs a token for the connection's ID, so it must not be one another connection already has
+ if (params.id && (await appConnectionDAL.findById(params.id))) {
+ throw new BadRequestError({ message: `App Connection ID '${params.id}' is already in use. Use a new ID.` });
+ }
+
const runValidation = (validationGatewayId: string | null | undefined) =>
validateAppConnectionCredentials(
{
@@ -654,12 +662,13 @@ export const appConnectionServiceFactory = ({
method,
orgId: actor.orgId,
projectId,
+ connectionId: params.id,
version: 2,
gatewayId: validationGatewayId,
projectType: project?.type
} as TAppConnectionConfig,
gatewayV2Service,
- { identityUaDAL, gitHubAppDAL, kmsService, keyStore, actorId: actor.id }
+ { identityUaDAL, gitHubAppDAL, kmsService, keyStore, oidcIssuerService, actorId: actor.id }
);
// Validation only dials the target and reads back, so retrying it on another member is safe.
@@ -946,6 +955,7 @@ export const appConnectionServiceFactory = ({
app,
orgId: actor.orgId,
projectId: appConnection.projectId,
+ connectionId: appConnection.id,
version: appConnection.version,
credentials: credentialsToValidate,
method,
@@ -953,7 +963,7 @@ export const appConnectionServiceFactory = ({
projectType: updateProject?.type
} as TAppConnectionConfig,
gatewayV2Service,
- { identityUaDAL, gitHubAppDAL, kmsService, keyStore, actorId: actor.id }
+ { identityUaDAL, gitHubAppDAL, kmsService, keyStore, oidcIssuerService, actorId: actor.id }
);
// Validation only dials the target and reads back, so retrying it on another member is safe.
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index 2101c97bd7..e853163772 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -781,6 +781,7 @@ export type TCreateAppConnectionDTO = Pick<
| "rotation"
| "isAutoRotationEnabled"
> & {
+ id?: string;
configuration?: Record<string, unknown>;
};
diff --git a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-enums.ts b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-enums.ts
index 529d7f4842..991c07a30d 100644
--- a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-enums.ts
+++ b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-enums.ts
@@ -1,5 +1,6 @@
export enum AzureKeyVaultConnectionMethod {
OAuth = "oauth",
ClientSecret = "client-secret",
- Certificate = "certificate"
+ Certificate = "certificate",
+ ManagedIdentity = "managed-identity"
}
diff --git a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts
index 07651fdb38..6f6e82adb0 100644
--- a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts
+++ b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts
@@ -21,6 +21,8 @@ import {
} from "@app/services/app-connection/app-connection-fns";
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { getAppConnectionOidcSubject } from "@app/services/oidc-issuer/oidc-issuer-fns";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { TAppConnectionDALFactory } from "../app-connection-dal";
import { AppConnection } from "../app-connection-enums";
@@ -31,9 +33,44 @@ import {
TAzureKeyVaultConnectionCertificateCredentials,
TAzureKeyVaultConnectionClientSecretCredentials,
TAzureKeyVaultConnectionConfig,
- TAzureKeyVaultConnectionCredentials
+ TAzureKeyVaultConnectionCredentials,
+ TAzureKeyVaultConnectionManagedIdentityCredentials
} from "./azure-key-vault-connection-types";
+// Entra only accepts federated tokens with this audience
+const AZURE_FEDERATED_TOKEN_AUDIENCE = "api://AzureADTokenExchange";
+
+const getManagedIdentityAccessToken = async (
+ {
+ orgId,
+ projectId,
+ connectionId,
+ tenantId,
+ clientId
+ }: { orgId: string; projectId?: string | null; connectionId: string; tenantId: string; clientId: string },
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">
+) => {
+ const clientAssertion = await oidcIssuerService.signToken({
+ orgId,
+ projectId,
+ subject: getAppConnectionOidcSubject(connectionId),
+ audience: AZURE_FEDERATED_TOKEN_AUDIENCE
+ });
+
+ const { data } = await request.post<ExchangeCodeAzureResponse>(
+ IntegrationUrls.AZURE_TOKEN_URL.replace("common", tenantId),
+ new URLSearchParams({
+ grant_type: "client_credentials",
+ scope: `https://vault.azure.net/.default`,
+ client_id: clientId,
+ client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
+ client_assertion: clientAssertion
+ })
+ );
+
+ return { accessToken: data.access_token, expiresAt: Date.now() + data.expires_in * 1000 };
+};
+
/**
* Proxies an Azure Key Vault data-plane request through a gateway when the connection has one
* configured, otherwise sends it directly. Mirrors `requestWithHCVaultGateway`.
@@ -132,7 +169,8 @@ export const requestWithAzureKeyVaultGateway = async <T>(
export const getAzureConnectionAccessToken = async (
connectionId: string,
appConnectionDAL: Pick<TAppConnectionDALFactory, "findById" | "updateById">,
- kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">
+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">,
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">
) => {
const appConnection = await appConnectionDAL.findById(connectionId);
@@ -301,6 +339,42 @@ export const getAzureConnectionAccessToken = async (
return { accessToken: certificateData.access_token };
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
+ const managedIdentityCredentials = (await decryptAppConnectionCredentials({
+ orgId: appConnection.orgId,
+ kmsService,
+ encryptedCredentials: appConnection.encryptedCredentials,
+ projectId: appConnection.projectId
+ })) as TAzureKeyVaultConnectionManagedIdentityCredentials;
+
+ if (managedIdentityCredentials.expiresAt > currentTime + 300000) {
+ return { accessToken: managedIdentityCredentials.accessToken };
+ }
+
+ const managedIdentityToken = await getManagedIdentityAccessToken(
+ {
+ orgId: appConnection.orgId,
+ projectId: appConnection.projectId,
+ connectionId: appConnection.id,
+ tenantId: managedIdentityCredentials.tenantId,
+ clientId: managedIdentityCredentials.clientId
+ },
+ oidcIssuerService
+ );
+
+ const encryptedManagedIdentityCredentials = await encryptAppConnectionCredentials({
+ credentials: { ...managedIdentityCredentials, ...managedIdentityToken },
+ orgId: appConnection.orgId,
+ kmsService,
+ projectId: appConnection.projectId
+ });
+
+ await appConnectionDAL.updateById(appConnection.id, {
+ encryptedCredentials: encryptedManagedIdentityCredentials
+ });
+
+ return { accessToken: managedIdentityToken.accessToken };
+
default:
throw new InternalServerError({
message: `Unhandled Azure Key Vault connection method: ${appConnection.method as AzureKeyVaultConnectionMethod}`
@@ -317,14 +391,18 @@ export const getAzureKeyVaultConnectionListItem = () => {
methods: Object.values(AzureKeyVaultConnectionMethod) as [
AzureKeyVaultConnectionMethod.OAuth,
AzureKeyVaultConnectionMethod.ClientSecret,
- AzureKeyVaultConnectionMethod.Certificate
+ AzureKeyVaultConnectionMethod.Certificate,
+ AzureKeyVaultConnectionMethod.ManagedIdentity
],
oauthClientId: INF_APP_CONNECTION_AZURE_KEY_VAULT_CLIENT_ID
};
};
-export const validateAzureKeyVaultConnectionCredentials = async (config: TAzureKeyVaultConnectionConfig) => {
- const { credentials: inputCredentials, method } = config;
+export const validateAzureKeyVaultConnectionCredentials = async (
+ config: TAzureKeyVaultConnectionConfig,
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">
+) => {
+ const { credentials: inputCredentials, method, orgId, projectId, connectionId } = config;
const { INF_APP_CONNECTION_AZURE_KEY_VAULT_CLIENT_ID, INF_APP_CONNECTION_AZURE_KEY_VAULT_CLIENT_SECRET, SITE_URL } =
getConfig();
@@ -481,6 +559,37 @@ export const validateAzureKeyVaultConnectionCredentials = async (config: TAzureK
}
}
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
+ const { tenantId: managedIdentityTenantId, clientId: managedIdentityClientId } = inputCredentials as {
+ tenantId: string;
+ clientId: string;
+ };
+
+ try {
+ const managedIdentityToken = await getManagedIdentityAccessToken(
+ {
+ orgId,
+ projectId,
+ // The create schema requires an ID for this method, and updates pass the connection's own
+ connectionId: connectionId as string,
+ tenantId: managedIdentityTenantId,
+ clientId: managedIdentityClientId
+ },
+ oidcIssuerService
+ );
+
+ return { tenantId: managedIdentityTenantId, clientId: managedIdentityClientId, ...managedIdentityToken };
+ } catch (e: unknown) {
+ if (e instanceof AxiosError) {
+ throw new BadRequestError({
+ message: `Failed to get access token: ${
+ (e?.response?.data as { error_description?: string })?.error_description || "Unknown error"
+ }`
+ });
+ }
+ throw e;
+ }
+
default:
throw new InternalServerError({
message: `Unhandled Azure Key Vault connection method: ${method as AzureKeyVaultConnectionMethod}`
diff --git a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts
index b2af69b188..774e503536 100644
--- a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts
+++ b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts
@@ -71,6 +71,18 @@ export const AzureKeyVaultConnectionCertificateOutputCredentialsSchema = z.objec
expiresAt: z.number()
});
+export const AzureKeyVaultConnectionManagedIdentityInputCredentialsSchema = z.object({
+ tenantId: z.string().uuid().trim().min(1, "Tenant ID required"),
+ clientId: z.string().uuid().trim().min(1, "Client ID required")
+});
+
+export const AzureKeyVaultConnectionManagedIdentityOutputCredentialsSchema = z.object({
+ tenantId: z.string(),
+ clientId: z.string(),
+ accessToken: z.string(),
+ expiresAt: z.number()
+});
+
export const ValidateAzureKeyVaultConnectionCredentialsSchema = z.discriminatedUnion("method", [
z.object({
method: z
@@ -95,6 +107,14 @@ export const ValidateAzureKeyVaultConnectionCredentialsSchema = z.discriminatedU
credentials: AzureKeyVaultConnectionCertificateInputCredentialsSchema.describe(
AppConnections.CREATE(AppConnection.AzureKeyVault).credentials
)
+ }),
+ z.object({
+ method: z
+ .literal(AzureKeyVaultConnectionMethod.ManagedIdentity)
+ .describe(AppConnections.CREATE(AppConnection.AzureKeyVault).method),
+ credentials: AzureKeyVaultConnectionManagedIdentityInputCredentialsSchema.describe(
+ AppConnections.CREATE(AppConnection.AzureKeyVault).credentials
+ )
})
]);
@@ -103,15 +123,26 @@ export const CreateAzureKeyVaultConnectionSchema = ValidateAzureKeyVaultConnecti
supportsCredentialRotation: true,
supportsGateways: true
})
-).superRefine((data, ctx) => {
- if (data.method !== AzureKeyVaultConnectionMethod.ClientSecret && data.isAutoRotationEnabled) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: "Credential rotation is only supported for the client-secret method",
- path: ["isAutoRotationEnabled"]
- });
- }
-});
+)
+ .and(z.object({ id: z.string().uuid().optional().describe(AppConnections.CREATE(AppConnection.AzureKeyVault).id) }))
+ .superRefine((data, ctx) => {
+ if (data.method !== AzureKeyVaultConnectionMethod.ClientSecret && data.isAutoRotationEnabled) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "Credential rotation is only supported for the client-secret method",
+ path: ["isAutoRotationEnabled"]
+ });
+ }
+
+ if (data.method === AzureKeyVaultConnectionMethod.ManagedIdentity && !data.id) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message:
+ "The managed-identity method requires an ID. Set the federated credential's subject to 'app-connection:<id>' before creating the connection.",
+ path: ["id"]
+ });
+ }
+ });
export const UpdateAzureKeyVaultConnectionSchema = z
.object({
@@ -119,7 +150,8 @@ export const UpdateAzureKeyVaultConnectionSchema = z
.union([
AzureKeyVaultConnectionOAuthInputCredentialsSchema,
AzureKeyVaultConnectionClientSecretInputCredentialsSchema,
- AzureKeyVaultConnectionCertificateInputCredentialsSchema
+ AzureKeyVaultConnectionCertificateInputCredentialsSchema,
+ AzureKeyVaultConnectionManagedIdentityInputCredentialsSchema
])
.optional()
.describe(AppConnections.UPDATE(AppConnection.AzureKeyVault).credentials)
@@ -149,6 +181,10 @@ export const AzureKeyVaultConnectionSchema = z.intersection(
z.object({
method: z.literal(AzureKeyVaultConnectionMethod.Certificate),
credentials: AzureKeyVaultConnectionCertificateOutputCredentialsSchema
+ }),
+ z.object({
+ method: z.literal(AzureKeyVaultConnectionMethod.ManagedIdentity),
+ credentials: AzureKeyVaultConnectionManagedIdentityOutputCredentialsSchema
})
])
);
@@ -173,7 +209,14 @@ export const SanitizedAzureKeyVaultConnectionSchema = z.discriminatedUnion("meth
clientId: true,
tenantId: true
})
- }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.AzureKeyVault]} (Certificate)` }))
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.AzureKeyVault]} (Certificate)` })),
+ BaseAzureKeyVaultConnectionSchema.extend({
+ method: z.literal(AzureKeyVaultConnectionMethod.ManagedIdentity),
+ credentials: AzureKeyVaultConnectionManagedIdentityOutputCredentialsSchema.pick({
+ clientId: true,
+ tenantId: true
+ })
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.AzureKeyVault]} (Managed Identity)` }))
]);
export const AzureKeyVaultConnectionListItemSchema = z
diff --git a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-types.ts b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-types.ts
index 6e93dee126..b9a7b4343c 100644
--- a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-types.ts
+++ b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-types.ts
@@ -6,6 +6,7 @@ import { AppConnection } from "../app-connection-enums";
import {
AzureKeyVaultConnectionCertificateOutputCredentialsSchema,
AzureKeyVaultConnectionClientSecretOutputCredentialsSchema,
+ AzureKeyVaultConnectionManagedIdentityOutputCredentialsSchema,
AzureKeyVaultConnectionOAuthOutputCredentialsSchema,
AzureKeyVaultConnectionSchema,
CreateAzureKeyVaultConnectionSchema,
@@ -25,6 +26,8 @@ export type TAzureKeyVaultConnectionConfig = DiscriminativePick<
"method" | "app" | "credentials"
> & {
orgId: string;
+ projectId?: string | null;
+ connectionId?: string;
};
export type ExchangeCodeAzureResponse = {
@@ -46,3 +49,7 @@ export type TAzureKeyVaultConnectionClientSecretCredentials = z.infer<
export type TAzureKeyVaultConnectionCertificateCredentials = z.infer<
typeof AzureKeyVaultConnectionCertificateOutputCredentialsSchema
>;
+
+export type TAzureKeyVaultConnectionManagedIdentityCredentials = z.infer<
+ typeof AzureKeyVaultConnectionManagedIdentityOutputCredentialsSchema
+>;
diff --git a/backend/src/services/oidc-issuer/oidc-issuer-fns.ts b/backend/src/services/oidc-issuer/oidc-issuer-fns.ts
index 6b727e46d1..83ef8391d8 100644
--- a/backend/src/services/oidc-issuer/oidc-issuer-fns.ts
+++ b/backend/src/services/oidc-issuer/oidc-issuer-fns.ts
@@ -10,6 +10,10 @@ const MAX_KEYS = 3;
type TIssuerKey = { id: string; createdAt: Date };
+// Customers copy this into their provider, so its shape can never change. The prefix keeps it from matching a
+// credential set up for a future use of the issuer.
+export const getAppConnectionOidcSubject = (connectionId: string) => `app-connection:${connectionId}`;
+
// Keys are oldest first: previous, current, next. The next key is published a full signing period before it
// takes over, so a provider that cached the JWKS already has it.
export const getSigningKey = <T extends TIssuerKey>(keys: T[]): T | undefined => keys[keys.length - 2];
diff --git a/backend/src/services/oidc-issuer/oidc-issuer-service.ts b/backend/src/services/oidc-issuer/oidc-issuer-service.ts
index 4c751553ac..3434109a20 100644
--- a/backend/src/services/oidc-issuer/oidc-issuer-service.ts
+++ b/backend/src/services/oidc-issuer/oidc-issuer-service.ts
@@ -1,11 +1,13 @@
import { Knex } from "knex";
+import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
import { AsymmetricKeyAlgorithm, SigningAlgorithm } from "@app/lib/crypto/sign/types";
import { BadRequestError, InternalServerError, NotFoundError } from "@app/lib/errors";
import { alphaNumericNanoId } from "@app/lib/nanoid";
+import { ActorType } from "@app/services/auth/auth-type";
import { TKmsKeyDALFactory } from "@app/services/kms/kms-key-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsKeyUsage } from "@app/services/kms/kms-types";
@@ -28,13 +30,19 @@ type TOidcIssuerServiceFactoryDep = {
kmsDAL: Pick<TKmsKeyDALFactory, "find" | "delete" | "transaction">;
kmsService: Pick<TKmsServiceFactory, "generateKmsKey" | "getPublicKey" | "signWithKmsKey">;
keyStore: Pick<TKeyStoreFactory, "acquireLock" | "getItem" | "setItemWithExpiry">;
+ auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;
};
type TJwks = { keys: Awaited<ReturnType<typeof publicKeyToJwk>>[] };
export type TOidcIssuerServiceFactory = ReturnType<typeof oidcIssuerServiceFactory>;
-export const oidcIssuerServiceFactory = ({ kmsDAL, kmsService, keyStore }: TOidcIssuerServiceFactoryDep) => {
+export const oidcIssuerServiceFactory = ({
+ kmsDAL,
+ kmsService,
+ keyStore,
+ auditLogService
+}: TOidcIssuerServiceFactoryDep) => {
const $getIssuerUrl = (orgId: string) => {
const { SITE_URL } = getConfig();
if (!SITE_URL) {
@@ -160,7 +168,7 @@ export const oidcIssuerServiceFactory = ({ kmsDAL, kmsService, keyStore }: TOidc
return signingKey;
};
- const signToken = async ({ orgId, subject, audience }: TSignOidcIssuerTokenDTO) => {
+ const signToken = async ({ orgId, projectId, subject, audience }: TSignOidcIssuerTokenDTO) => {
const issuer = $getIssuerUrl(orgId);
const { id: kmsId } = await $getSigningKey(orgId);
@@ -173,8 +181,9 @@ export const oidcIssuerServiceFactory = ({ kmsDAL, kmsService, keyStore }: TOidc
);
const iat = Math.floor(Date.now() / 1000);
+ const jti = crypto.nativeCrypto.randomUUID();
- return signJwt({
+ const token = await signJwt({
kid,
claims: {
iss: issuer,
@@ -183,11 +192,20 @@ export const oidcIssuerServiceFactory = ({ kmsDAL, kmsService, keyStore }: TOidc
iat,
nbf: iat,
exp: iat + TOKEN_TTL_SECONDS,
- jti: crypto.nativeCrypto.randomUUID()
+ jti
},
sign: async (data) =>
(await sign({ data, signingAlgorithm: SigningAlgorithm.RSASSA_PKCS1_V1_5_SHA_256, isDigest: false })).signature
});
+
+ await auditLogService.createAuditLog({
+ orgId,
+ projectId: projectId ?? undefined,
+ actor: { type: ActorType.PLATFORM, metadata: {} },
+ event: { type: EventType.ISSUE_OIDC_TOKEN, metadata: { subject, audience, tokenId: jti } }
+ });
+
+ return token;
};
const getDiscoveryDocument = (orgId: string) => {
diff --git a/backend/src/services/oidc-issuer/oidc-issuer-types.ts b/backend/src/services/oidc-issuer/oidc-issuer-types.ts
index ab7b7fe783..bf695a7267 100644
--- a/backend/src/services/oidc-issuer/oidc-issuer-types.ts
+++ b/backend/src/services/oidc-issuer/oidc-issuer-types.ts
@@ -1,5 +1,6 @@
export type TSignOidcIssuerTokenDTO = {
orgId: string;
+ projectId?: string | null;
subject: string;
audience: string;
};
diff --git a/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-fns.ts b/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-fns.ts
index 19faa08c3d..caffd508b7 100644
--- a/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-fns.ts
@@ -13,6 +13,7 @@ import { CertificateSyncStatus } from "@app/services/certificate-sync/certificat
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
import { createConnectionQueue, RateLimitConfig } from "@app/services/connection-queue";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { certificateNameSchemaHasFreeTextPlaceholder } from "@app/services/pki-sync/pki-sync-certificate-name-fns";
import { matchesCertificateNameSchema } from "@app/services/pki-sync/pki-sync-fns";
import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";
@@ -65,6 +66,7 @@ type TAzureKeyVaultPkiSyncFactoryDeps = {
| "claimExternalIdentifier"
>;
certificateDAL: Pick<TCertificateDALFactory, "findById">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
const parseCertificateX509Props = (certPem: string) => {
@@ -211,7 +213,8 @@ export const azureKeyVaultPkiSyncFactory = ({
kmsService,
appConnectionDAL,
certificateSyncDAL,
- certificateDAL
+ certificateDAL,
+ oidcIssuerService
}: TAzureKeyVaultPkiSyncFactoryDeps) => {
const $getAzureKeyVaultCertificates = async (accessToken: string, vaultBaseUrl: string, syncId = "unknown") => {
await blockLocalAndPrivateIpAddresses(vaultBaseUrl);
@@ -340,7 +343,12 @@ export const azureKeyVaultPkiSyncFactory = ({
};
const syncCertificates = async (pkiSync: TPkiSyncWithCredentials, certificateMap: TCertificateMap) => {
- const { accessToken } = await getAzureConnectionAccessToken(pkiSync.connection.id, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ pkiSync.connection.id,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
// Cast destination config to Azure Key Vault config
const destinationConfig = pkiSync.destinationConfig as TAzureKeyVaultPkiSyncConfig;
@@ -752,7 +760,12 @@ export const azureKeyVaultPkiSyncFactory = ({
certificateNames: string[],
deps?: { certificateSyncDAL?: TCertificateSyncDALFactory; certificateMap?: TCertificateMap }
) => {
- const { accessToken } = await getAzureConnectionAccessToken(pkiSync.connection.id, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ pkiSync.connection.id,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
// Cast destination config to Azure Key Vault config
const destinationConfig = pkiSync.destinationConfig as TAzureKeyVaultPkiSyncConfig;
diff --git a/backend/src/services/pki-sync/pki-sync-fns.ts b/backend/src/services/pki-sync/pki-sync-fns.ts
index ae76432e3d..033a3541e3 100644
--- a/backend/src/services/pki-sync/pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/pki-sync-fns.ts
@@ -10,6 +10,7 @@ import { TAppConnectionDALFactory } from "@app/services/app-connection/app-conne
import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certificate-sync-dal";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { AWS_CERTIFICATE_MANAGER_PKI_SYNC_LIST_OPTION } from "./aws-certificate-manager/aws-certificate-manager-pki-sync-constants";
import { awsCertificateManagerPkiSyncFactory } from "./aws-certificate-manager/aws-certificate-manager-pki-sync-fns";
@@ -319,6 +320,7 @@ export const PkiSyncFns = {
gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId" | "getGatewayById">;
gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
}
): Promise<TPkiSyncSyncResult> => {
switch (pkiSync.destination) {
@@ -328,7 +330,8 @@ export const PkiSyncFns = {
appConnectionDAL: dependencies.appConnectionDAL,
kmsService: dependencies.kmsService,
certificateDAL: dependencies.certificateDAL,
- certificateSyncDAL: dependencies.certificateSyncDAL
+ certificateSyncDAL: dependencies.certificateSyncDAL,
+ oidcIssuerService: dependencies.oidcIssuerService
});
return azureKeyVaultPkiSync.syncCertificates(pkiSync, certificateMap);
}
@@ -575,6 +578,7 @@ export const PkiSyncFns = {
gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId" | "getGatewayById">;
gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
}
): Promise<void> => {
switch (pkiSync.destination) {
@@ -584,7 +588,8 @@ export const PkiSyncFns = {
appConnectionDAL: dependencies.appConnectionDAL,
kmsService: dependencies.kmsService,
certificateDAL: dependencies.certificateDAL,
- certificateSyncDAL: dependencies.certificateSyncDAL
+ certificateSyncDAL: dependencies.certificateSyncDAL,
+ oidcIssuerService: dependencies.oidcIssuerService
});
await azureKeyVaultPkiSync.removeCertificates(pkiSync, certificateNames, {
certificateSyncDAL: dependencies.certificateSyncDAL,
diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.ts
index 39ed662fb8..d870c64936 100644
--- a/backend/src/services/pki-sync/pki-sync-queue.ts
+++ b/backend/src/services/pki-sync/pki-sync-queue.ts
@@ -14,6 +14,7 @@ import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
import { ActorType } from "@app/services/auth/auth-type";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TNotificationServiceFactory } from "@app/services/notification/notification-service";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { TPkiApplicationDALFactory } from "@app/services/pki-application/pki-application-dal";
import { hydratePkiSyncCredentials } from "@app/services/pki-sync/pki-sync-credentials-fns";
import { TProjectDALFactory } from "@app/services/project/project-dal";
@@ -101,6 +102,7 @@ type TPkiSyncQueueFactoryDep = {
gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId" | "getGatewayById">;
gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
telemetryService: Pick<TTelemetryServiceFactory, "sendPostHogEvents">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
type PkiSyncActionJob = Job<
@@ -138,7 +140,8 @@ export const pkiSyncQueueFactory = ({
certificateSyncDAL,
gatewayV2Service,
gatewayPoolService,
- telemetryService
+ telemetryService,
+ oidcIssuerService
}: TPkiSyncQueueFactoryDep) => {
const appCfg = getConfig();
@@ -291,7 +294,8 @@ export const pkiSyncQueueFactory = ({
certificateSyncDAL,
gatewayV2Service,
gatewayPoolService,
- keyStore
+ keyStore,
+ oidcIssuerService
});
logger.info(
@@ -664,7 +668,8 @@ export const pkiSyncQueueFactory = ({
removalOptions,
gatewayV2Service,
gatewayPoolService,
- keyStore
+ keyStore,
+ oidcIssuerService
});
isSuccess = true;
diff --git a/backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts b/backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts
index a3f11a8106..03e1f01c8c 100644
--- a/backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts
+++ b/backend/src/services/secret-sync/azure-app-configuration/azure-app-configuration-sync-fns.ts
@@ -7,6 +7,7 @@ import { TAppConnectionDALFactory } from "@app/services/app-connection/app-conne
import { getAzureConnectionAccessToken } from "@app/services/app-connection/azure-key-vault/azure-key-vault-connection-fns";
import { isAzureKeyVaultReference } from "@app/services/integration-auth/integration-sync-secret-fns";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";
import { TSecretSyncPayload } from "@app/services/secret-sync/secret-sync-payload";
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
@@ -16,6 +17,7 @@ import { TAzureAppConfigurationSyncWithCredentials } from "./azure-app-configura
type TAzureAppConfigurationSyncFactoryDeps = {
appConnectionDAL: Pick<TAppConnectionDALFactory, "findById" | "updateById">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
interface AzureAppConfigKeyValue {
@@ -26,7 +28,8 @@ interface AzureAppConfigKeyValue {
export const azureAppConfigurationSyncFactory = ({
kmsService,
- appConnectionDAL
+ appConnectionDAL,
+ oidcIssuerService
}: TAzureAppConfigurationSyncFactoryDeps) => {
const $getCompleteAzureAppConfigValues = async (accessToken: string, baseURL: string, url: string) => {
let result: AzureAppConfigKeyValue[] = [];
@@ -76,7 +79,12 @@ export const azureAppConfigurationSyncFactory = ({
});
}
- const { accessToken } = await getAzureConnectionAccessToken(secretSync.connectionId, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ secretSync.connectionId,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
const azureAppConfigValuesUrl = `/kv?api-version=2023-11-01${
secretSync.destinationConfig.label ? `&label=${secretSync.destinationConfig.label}` : "&label=%00"
@@ -159,7 +167,12 @@ export const azureAppConfigurationSyncFactory = ({
const removeSecrets = async (secretSync: TAzureAppConfigurationSyncWithCredentials, payload: TSecretSyncPayload) => {
const secretMap = payload.flatten();
- const { accessToken } = await getAzureConnectionAccessToken(secretSync.connectionId, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ secretSync.connectionId,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
const azureAppConfigValuesUrl = `/kv?api-version=2023-11-01${
secretSync.destinationConfig.label ? `&label=${secretSync.destinationConfig.label}` : "&label=%00"
@@ -188,7 +201,12 @@ export const azureAppConfigurationSyncFactory = ({
};
const getSecrets = async (secretSync: TAzureAppConfigurationSyncWithCredentials) => {
- const { accessToken } = await getAzureConnectionAccessToken(secretSync.connectionId, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ secretSync.connectionId,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
const secretMap: TSecretMap = {};
diff --git a/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts b/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts
index e73441c439..db774d9a91 100644
--- a/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts
+++ b/backend/src/services/secret-sync/azure-key-vault/azure-key-vault-sync-fns.ts
@@ -9,6 +9,7 @@ import {
requestWithAzureKeyVaultGateway
} from "@app/services/app-connection/azure-key-vault/azure-key-vault-connection-fns";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";
import { TSecretSyncPayload } from "@app/services/secret-sync/secret-sync-payload";
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
@@ -28,6 +29,7 @@ type TAzureKeyVaultSyncFactoryDeps = {
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;
gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
// the effective gateway is resolved up front, so callers thread a connection that only carries a gatewayId
@@ -39,7 +41,8 @@ export const azureKeyVaultSyncFactory = ({
kmsService,
appConnectionDAL,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
}: TAzureKeyVaultSyncFactoryDeps) => {
const $getAzureKeyVaultSecrets = async (
accessToken: string,
@@ -142,7 +145,12 @@ export const azureKeyVaultSyncFactory = ({
});
const gatewayConnection: TGatewayConnection = { gatewayId: effectiveGatewayId, gatewayPoolId: null };
- const { accessToken } = await getAzureConnectionAccessToken(connection.id, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ connection.id,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
const { vaultSecrets, disabledAzureKeyVaultSecretKeys } = await $getAzureKeyVaultSecrets(
accessToken,
@@ -286,7 +294,12 @@ export const azureKeyVaultSyncFactory = ({
});
const gatewayConnection: TGatewayConnection = { gatewayId: effectiveGatewayId, gatewayPoolId: null };
- const { accessToken } = await getAzureConnectionAccessToken(connection.id, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ connection.id,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
const { vaultSecrets, disabledAzureKeyVaultSecretKeys } = await $getAzureKeyVaultSecrets(
accessToken,
@@ -319,7 +332,12 @@ export const azureKeyVaultSyncFactory = ({
});
const gatewayConnection: TGatewayConnection = { gatewayId: effectiveGatewayId, gatewayPoolId: null };
- const { accessToken } = await getAzureConnectionAccessToken(connection.id, appConnectionDAL, kmsService);
+ const { accessToken } = await getAzureConnectionAccessToken(
+ connection.id,
+ appConnectionDAL,
+ kmsService,
+ oidcIssuerService
+ );
const { vaultSecrets, disabledAzureKeyVaultSecretKeys } = await $getAzureKeyVaultSecrets(
accessToken,
diff --git a/backend/src/services/secret-sync/secret-sync-fns.ts b/backend/src/services/secret-sync/secret-sync-fns.ts
index 6d19b89574..2910ec990b 100644
--- a/backend/src/services/secret-sync/secret-sync-fns.ts
+++ b/backend/src/services/secret-sync/secret-sync-fns.ts
@@ -35,6 +35,7 @@ import {
import { TAppConnectionDALFactory } from "../app-connection/app-connection-dal";
import { TGitHubAppDALFactory } from "../github-app/github-app-dal";
import { TKmsServiceFactory } from "../kms/kms-service";
+import { TOidcIssuerServiceFactory } from "../oidc-issuer/oidc-issuer-service";
import { ONEPASS_SYNC_LIST_OPTION, OnePassSyncFns } from "./1password";
import { AwsSecretsManagerSyncMappingBehavior } from "./aws-secrets-manager/aws-secrets-manager-sync-enums";
import { AZURE_APP_CONFIGURATION_SYNC_LIST_OPTION, azureAppConfigurationSyncFactory } from "./azure-app-configuration";
@@ -194,6 +195,7 @@ type TSyncSecretDeps = {
gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;
gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
// Strip schema from secret keys
@@ -284,7 +286,14 @@ export const SecretSyncFns = {
syncSecrets: (
secretSync: TSecretSyncWithCredentials,
payload: TSecretSyncPayload,
- { kmsService, appConnectionDAL, gitHubAppDAL, gatewayV2Service, gatewayPoolService }: TSyncSecretDeps
+ {
+ kmsService,
+ appConnectionDAL,
+ gitHubAppDAL,
+ gatewayV2Service,
+ gatewayPoolService,
+ oidcIssuerService
+ }: TSyncSecretDeps
): Promise<TSyncSecretsResult | void> => {
switch (secretSync.destination) {
case SecretSync.AWSParameterStore:
@@ -303,12 +312,14 @@ export const SecretSyncFns = {
appConnectionDAL,
kmsService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
}).syncSecrets(secretSync, payload);
case SecretSync.AzureAppConfiguration:
return azureAppConfigurationSyncFactory({
appConnectionDAL,
- kmsService
+ kmsService,
+ oidcIssuerService
}).syncSecrets(secretSync, payload);
case SecretSync.AzureDevOps:
return azureDevOpsSyncFactory({
@@ -419,7 +430,7 @@ export const SecretSyncFns = {
},
getSecrets: async (
secretSync: TSecretSyncWithCredentials,
- { kmsService, appConnectionDAL, gatewayV2Service, gatewayPoolService }: TSyncSecretDeps
+ { kmsService, appConnectionDAL, gatewayV2Service, gatewayPoolService, oidcIssuerService }: TSyncSecretDeps
): Promise<TSecretMap> => {
let secretMap: TSecretMap;
switch (secretSync.destination) {
@@ -443,13 +454,15 @@ export const SecretSyncFns = {
appConnectionDAL,
kmsService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
}).getSecrets(secretSync);
break;
case SecretSync.AzureAppConfiguration:
secretMap = await azureAppConfigurationSyncFactory({
appConnectionDAL,
- kmsService
+ kmsService,
+ oidcIssuerService
}).getSecrets(secretSync);
break;
case SecretSync.AzureDevOps:
@@ -611,7 +624,14 @@ export const SecretSyncFns = {
removeSecrets: (
secretSync: TSecretSyncWithCredentials,
payload: TSecretSyncPayload,
- { kmsService, appConnectionDAL, gitHubAppDAL, gatewayV2Service, gatewayPoolService }: TSyncSecretDeps
+ {
+ kmsService,
+ appConnectionDAL,
+ gitHubAppDAL,
+ gatewayV2Service,
+ gatewayPoolService,
+ oidcIssuerService
+ }: TSyncSecretDeps
): Promise<void> => {
switch (secretSync.destination) {
case SecretSync.AWSParameterStore:
@@ -630,12 +650,14 @@ export const SecretSyncFns = {
appConnectionDAL,
kmsService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
}).removeSecrets(secretSync, payload);
case SecretSync.AzureAppConfiguration:
return azureAppConfigurationSyncFactory({
appConnectionDAL,
- kmsService
+ kmsService,
+ oidcIssuerService
}).removeSecrets(secretSync, payload);
case SecretSync.AzureDevOps:
return azureDevOpsSyncFactory({
diff --git a/backend/src/services/secret-sync/secret-sync-queue.ts b/backend/src/services/secret-sync/secret-sync-queue.ts
index d1ab0632e0..c0c771a0d7 100644
--- a/backend/src/services/secret-sync/secret-sync-queue.ts
+++ b/backend/src/services/secret-sync/secret-sync-queue.ts
@@ -25,6 +25,7 @@ import { ActorType } from "@app/services/auth/auth-type";
import { TEventEmitter } from "@app/services/event-outbox/event-outbox-types";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
+import { TOidcIssuerServiceFactory } from "@app/services/oidc-issuer/oidc-issuer-service";
import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TProjectBotDALFactory } from "@app/services/project-bot/project-bot-dal";
import { TProjectEnvDALFactory } from "@app/services/project-env/project-env-dal";
@@ -144,6 +145,7 @@ type TSecretSyncQueueFactoryDep = {
telemetryService: Pick<TTelemetryServiceFactory, "sendPostHogEvents">;
projectFolderGrantDAL: Pick<TProjectFolderGrantDALFactory, "find">;
orgDAL: Pick<TOrgDALFactory, "findOrgById">;
+ oidcIssuerService: Pick<TOidcIssuerServiceFactory, "signToken">;
};
type SecretSyncActionJob = Job<
@@ -198,7 +200,8 @@ export const secretSyncQueueFactory = ({
microsoftTeamsService,
telemetryService,
projectFolderGrantDAL,
- orgDAL
+ orgDAL,
+ oidcIssuerService
}: TSecretSyncQueueFactoryDep) => {
const appCfg = getConfig();
@@ -413,7 +416,8 @@ export const secretSyncQueueFactory = ({
gitHubAppDAL,
kmsService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
});
if (!Object.keys(importedSecrets).length) return {};
@@ -576,7 +580,8 @@ export const secretSyncQueueFactory = ({
gitHubAppDAL,
kmsService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
});
syncResult = result ?? undefined;
@@ -891,7 +896,8 @@ export const secretSyncQueueFactory = ({
gitHubAppDAL,
kmsService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ oidcIssuerService
}
);
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index 943e6e15b4..0034d20a2e 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -884,6 +884,8 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
case AzureClientSecretsConnectionMethod.Certificate:
case AzureKeyVaultConnectionMethod.Certificate:
return { name: "Certificate", icon: FileBadgeIcon };
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
+ return { name: "Managed Identity", icon: IdCardIcon };
case DNSMadeEasyConnectionMethod.APIKeySecret:
case SpaceliftConnectionMethod.ApiKeySecret:
return { name: "API Key & Secret", icon: KeyRoundIcon };
diff --git a/frontend/src/hooks/api/appConnections/types/azure-key-vault-connection.ts b/frontend/src/hooks/api/appConnections/types/azure-key-vault-connection.ts
index ce69ee66f3..0d35dd9cac 100644
--- a/frontend/src/hooks/api/appConnections/types/azure-key-vault-connection.ts
+++ b/frontend/src/hooks/api/appConnections/types/azure-key-vault-connection.ts
@@ -4,7 +4,8 @@ import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-con
export enum AzureKeyVaultConnectionMethod {
OAuth = "oauth",
ClientSecret = "client-secret",
- Certificate = "certificate"
+ Certificate = "certificate",
+ ManagedIdentity = "managed-identity"
}
export type TAzureKeyVaultConnection = TRootAppConnection & { app: AppConnection.AzureKeyVault } & (
@@ -32,4 +33,11 @@ export type TAzureKeyVaultConnection = TRootAppConnection & { app: AppConnection
privateKey: string;
};
}
+ | {
+ method: AzureKeyVaultConnectionMethod.ManagedIdentity;
+ credentials: {
+ clientId: string;
+ tenantId: string;
+ };
+ }
);
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index 78ead5dbc6..c3df9b16ef 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -177,6 +177,7 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.DELETE_APP_CONNECTION]: "Delete App Connection",
[EventType.GET_APP_CONNECTION_USAGE]: "Get App Connection Usage",
[EventType.MIGRATE_APP_CONNECTION]: "Migrate App Connection",
+ [EventType.ISSUE_OIDC_TOKEN]: "Issue OIDC Token",
[EventType.CREATE_GITHUB_APP]: "Create GitHub App",
[EventType.DELETE_GITHUB_APP]: "Delete GitHub App",
[EventType.GET_SECRET_SYNCS]: "List secret syncs",
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index ac14e2d56d..fd118943ce 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -188,6 +188,7 @@ export enum EventType {
DELETE_APP_CONNECTION = "delete-app-connection",
GET_APP_CONNECTION_USAGE = "get-app-connection-usage",
MIGRATE_APP_CONNECTION = "migrate-app-connection",
+ ISSUE_OIDC_TOKEN = "issue-oidc-token",
CREATE_GITHUB_APP = "create-github-app",
DELETE_GITHUB_APP = "delete-github-app",
GET_SECRET_SYNCS = "get-secret-syncs",
diff --git a/frontend/src/hooks/api/index.tsx b/frontend/src/hooks/api/index.tsx
index 62cb7135a7..4137c42c6d 100644
--- a/frontend/src/hooks/api/index.tsx
+++ b/frontend/src/hooks/api/index.tsx
@@ -40,6 +40,7 @@ export * from "./ldapConfig";
export * from "./mfaSession";
export * from "./oauthClients";
export * from "./oidcConfig";
+export * from "./oidcIssuer";
export * from "./orgAdmin";
export * from "./organization";
export * from "./orgIdentity";
diff --git a/frontend/src/hooks/api/oidcIssuer/index.tsx b/frontend/src/hooks/api/oidcIssuer/index.tsx
new file mode 100644
index 0000000000..ac765ee93c
--- /dev/null
+++ b/frontend/src/hooks/api/oidcIssuer/index.tsx
@@ -0,0 +1 @@
+export { useGetOidcIssuerUrl } from "./queries";
diff --git a/frontend/src/hooks/api/oidcIssuer/queries.tsx b/frontend/src/hooks/api/oidcIssuer/queries.tsx
new file mode 100644
index 0000000000..dd723bd12a
--- /dev/null
+++ b/frontend/src/hooks/api/oidcIssuer/queries.tsx
@@ -0,0 +1,31 @@
+import { useQuery, UseQueryOptions } from "@tanstack/react-query";
+
+import { apiRequest } from "@app/config/request";
+
+export const oidcIssuerKeys = {
+ getIssuerUrl: (orgId: string) => [{ orgId }, "oidc-issuer-url"] as const
+};
+
+// Read from the discovery document, because the issuer is built from SITE_URL, which can differ from the
+// address the browser uses
+export const useGetOidcIssuerUrl = (
+ orgId: string,
+ options?: Omit<
+ UseQueryOptions<string, unknown, string, ReturnType<typeof oidcIssuerKeys.getIssuerUrl>>,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: oidcIssuerKeys.getIssuerUrl(orgId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ issuer: string }>(
+ `/api/v1/oidc-issuer/organizations/${orgId}/.well-known/openid-configuration`,
+ // The document is cached for an hour for providers, but the form must show the issuer tokens use now
+ { headers: { "Cache-Control": "no-cache" } }
+ );
+
+ return data.issuer;
+ },
+ ...options
+ });
+};
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
index 6a881a3007..009c41683d 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
@@ -9,7 +9,9 @@ import { z } from "zod";
import { OrgPermissionCan } from "@app/components/permissions";
import {
Button,
+ CopyButton,
Field,
+ FieldDescription,
FieldError,
FieldLabel,
Input,
@@ -25,7 +27,7 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";
-import { useSubscription } from "@app/context";
+import { useOrganization, useSubscription } from "@app/context";
import {
OrgGatewayPermissionActions,
OrgPermissionSubjects
@@ -37,6 +39,7 @@ import {
} from "@app/helpers/appConnections";
import { isInfisicalCloud } from "@app/helpers/platform";
import { useScopeVariant } from "@app/hooks";
+import { useGetOidcIssuerUrl } from "@app/hooks/api";
import { useGetAppConnectionOption } from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import {
@@ -54,8 +57,9 @@ import {
type ClientSecretForm = z.infer<typeof clientSecretSchema>;
type CertificateForm = z.infer<typeof certificateSchema>;
+type ManagedIdentityForm = z.infer<typeof managedIdentitySchema>;
-type TInputFormData = ClientSecretForm | CertificateForm;
+type TInputFormData = ClientSecretForm | CertificateForm | (ManagedIdentityForm & { id?: string });
type Props = {
appConnection?: TAzureKeyVaultConnection;
@@ -93,12 +97,34 @@ const certificateSchema = baseSchema.extend({
})
});
+const managedIdentitySchema = baseSchema.extend({
+ method: z.literal(AzureKeyVaultConnectionMethod.ManagedIdentity),
+ credentials: z.object({
+ clientId: z.string().trim().min(1, "Client ID is required"),
+ tenantId: z.string().trim().min(1, "Tenant ID is required")
+ })
+});
+
const formSchema = z.discriminatedUnion("method", [
oauthSchema,
clientSecretSchema,
- certificateSchema
+ certificateSchema,
+ managedIdentitySchema
]);
+// Entra only accepts federated tokens with this audience
+const AZURE_FEDERATED_TOKEN_AUDIENCE = "api://AzureADTokenExchange";
+
+const CopyableValue = ({ label, value }: { label: string; value: string }) => (
+ <div className="flex flex-col gap-1">
+ <span className="text-xs text-accent">{label}</span>
+ <div className="flex items-center gap-2 rounded-md border border-border bg-container p-2">
+ <p className="grow font-mono text-sm break-all text-foreground">{value}</p>
+ <CopyButton value={value} ariaLabel={`Copy ${label}`} />
+ </div>
+ </div>
+);
+
type FormData = z.infer<typeof formSchema>;
const getDefaultValues = (appConnection?: TAzureKeyVaultConnection): Partial<FormData> => {
@@ -170,6 +196,18 @@ const getDefaultValues = (appConnection?: TAzureKeyVaultConnection): Partial<For
};
}
break;
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
+ if ("clientId" in credentials && "tenantId" in credentials) {
+ return {
+ ...base,
+ method: AzureKeyVaultConnectionMethod.ManagedIdentity,
+ credentials: {
+ clientId: credentials.clientId,
+ tenantId: credentials.tenantId
+ }
+ };
+ }
+ break;
default:
return base;
}
@@ -211,6 +249,15 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
const gatewayPoolId = watch("gatewayPoolId");
const { subscription } = useSubscription();
+ const { currentOrg } = useOrganization();
+
+ // The subject Infisical signs is the connection's ID, so a new connection's ID is chosen here and shown
+ // before it exists
+ const [connectionId] = useState(() => appConnection?.id ?? window.crypto.randomUUID());
+
+ const { data: issuerUrl } = useGetOidcIssuerUrl(currentOrg.id, {
+ enabled: selectedMethod === AzureKeyVaultConnectionMethod.ManagedIdentity
+ });
const onSubmitHandler = async (formData: FormData) => {
const state = crypto.randomBytes(16).toString("hex");
@@ -238,6 +285,9 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
case AzureKeyVaultConnectionMethod.Certificate:
await onSubmit(formData);
break;
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
+ await onSubmit(isUpdate ? formData : { ...formData, id: connectionId });
+ break;
default:
throw new Error(`Unhandled Azure Connection method: ${(formData as FormData).method}`);
}
@@ -253,6 +303,7 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
isMissingConfig = false;
break;
case AzureKeyVaultConnectionMethod.Certificate:
+ case AzureKeyVaultConnectionMethod.ManagedIdentity:
isMissingConfig = false;
break;
default:
@@ -581,6 +632,66 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
</>
)}
+ {selectedMethod === AzureKeyVaultConnectionMethod.ManagedIdentity && (
+ <>
+ <Controller
+ name="credentials.tenantId"
+ control={control}
+ render={({ field, fieldState: { error } }) => (
+ <Field className="mb-4">
+ <FieldLabel htmlFor="credentials.tenantId">
+ Tenant ID
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Info />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-sm">
+ The Azure Active Directory (Entra ID) Tenant ID.
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="credentials.tenantId"
+ placeholder="00000000-0000-0000-0000-000000000000"
+ isError={Boolean(error)}
+ />
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+ <Controller
+ name="credentials.clientId"
+ control={control}
+ render={({ field, fieldState: { error } }) => (
+ <Field className="mb-4">
+ <FieldLabel htmlFor="credentials.clientId">Client ID</FieldLabel>
+ <Input
+ {...field}
+ id="credentials.clientId"
+ placeholder="00000000-0000-0000-0000-000000000000"
+ isError={Boolean(error)}
+ />
+ <FieldDescription>
+ The client ID of the user-assigned managed identity.
+ </FieldDescription>
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+ <Field className="mb-4">
+ <FieldLabel>Federated Credential</FieldLabel>
+ <FieldDescription>
+ Add a federated credential to the managed identity with the Other issuer scenario
+ and these values.
+ </FieldDescription>
+ {issuerUrl && <CopyableValue label="Issuer" value={issuerUrl} />}
+ <CopyableValue label="Subject Identifier" value={`app-connection:${connectionId}`} />
+ <CopyableValue label="Audience" value={AZURE_FEDERATED_TOKEN_AUDIENCE} />
+ </Field>
+ </>
+ )}
+
<SheetFooter className="sticky bottom-0 -mx-4 items-center border-t bg-popover">
<Button
type="submit"