Skip to content

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

show the federated credential values in the managed identity form and verify after create

DimitrisStaratzise062f4430460
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AddAppConnectionModal.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AddAppConnectionModal.tsx
index 360b9926e6..e3f82d7310 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AddAppConnectionModal.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AddAppConnectionModal.tsx
@@ -12,6 +12,7 @@ import {
import { useDiscardChangesGuard } from "@app/hooks";
import { TAppConnection } from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { AzureKeyVaultConnectionMethod } from "@app/hooks/api/appConnections/types/azure-key-vault-connection";
import { ProjectType } from "@app/hooks/api/projects/types";
import { AppConnectionForm } from "./AppConnectionForm";
@@ -40,6 +41,7 @@ export const AddAppConnectionModal = ({
// When `app` is preset (inline create from another flow, or an OAuth reopen) we skip the provider
// select screen and go straight to that app's form. Otherwise the user picks a provider first.
const [selectedApp, setSelectedApp] = useState<AppConnection | null>(app ?? null);
+ const [createdConnection, setCreatedConnection] = useState<TAppConnection | null>(null);
const [isDirty, setIsDirty] = useState(false);
const discardActionRef = useRef<VoidFunction>(() => {});
@@ -50,6 +52,7 @@ export const AddAppConnectionModal = ({
useEffect(() => {
if (isOpen) {
setSelectedApp(app ?? null);
+ setCreatedConnection(null);
setIsDirty(false);
}
}, [isOpen, app]);
@@ -57,6 +60,7 @@ export const AddAppConnectionModal = ({
const closeSheet = useCallback(() => {
setIsDirty(false);
setSelectedApp(null);
+ setCreatedConnection(null);
onOpenChange(false);
}, [onOpenChange]);
@@ -78,6 +82,15 @@ export const AddAppConnectionModal = ({
const handleComplete = (appConnection: TAppConnection) => {
onComplete?.(appConnection);
+
+ // Azure can only be told to trust a managed identity connection once it has an ID, so the sheet stays open on
+ // its credentials, which show the federated credential values and verify the setup on reconnect
+ if (appConnection.method === AzureKeyVaultConnectionMethod.ManagedIdentity) {
+ setIsDirty(false);
+ setCreatedConnection(appConnection);
+ return;
+ }
+
closeSheet();
};
@@ -90,7 +103,7 @@ export const AddAppConnectionModal = ({
};
// Only offer "back to select" when the user navigated here from the select screen (no preset app).
- const showBack = !app && Boolean(selectedApp);
+ const showBack = !app && Boolean(selectedApp) && !createdConnection;
return (
<>
@@ -110,7 +123,7 @@ export const AddAppConnectionModal = ({
</button>
)}
<SheetTitle>
- <AppConnectionHeader app={selectedApp} isConnected={false} />
+ <AppConnectionHeader app={selectedApp} isConnected={Boolean(createdConnection)} />
</SheetTitle>
</>
) : (
@@ -122,14 +135,23 @@ export const AddAppConnectionModal = ({
</SheetHeader>
{selectedApp ? (
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto">
- <AppConnectionForm
- app={selectedApp}
- projectId={projectId}
- projectType={projectType}
- onComplete={handleComplete}
- onCancel={() => requestDiscardAction(closeSheet)}
- onDirtyChange={setIsDirty}
- />
+ {createdConnection ? (
+ <AppConnectionForm
+ appConnection={createdConnection}
+ onComplete={closeSheet}
+ onCancel={() => requestDiscardAction(closeSheet)}
+ onDirtyChange={setIsDirty}
+ />
+ ) : (
+ <AppConnectionForm
+ app={selectedApp}
+ projectId={projectId}
+ projectType={projectType}
+ onComplete={handleComplete}
+ onCancel={() => requestDiscardAction(closeSheet)}
+ onDirtyChange={setIsDirty}
+ />
+ )}
</div>
) : (
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto p-4">
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 25d1ba1708..17437692be 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
@@ -115,12 +115,22 @@ const formSchema = z.discriminatedUnion("method", [
// Entra only accepts federated tokens with this audience
const AZURE_FEDERATED_TOKEN_AUDIENCE = "api://AzureADTokenExchange";
-const CopyableValue = ({ label, value }: { label: string; value: string }) => (
+const CopyableValue = ({
+ label,
+ value,
+ placeholder
+}: {
+ label: string;
+ value?: string;
+ placeholder?: 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}`} />
+ <p className={`grow font-mono text-sm break-all ${value ? "text-foreground" : "text-muted"}`}>
+ {value ?? placeholder}
+ </p>
+ {value && <CopyButton value={value} ariaLabel={`Copy ${label}`} />}
</div>
</div>
);
@@ -252,7 +262,7 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
const { currentOrg } = useOrganization();
const { data: issuerUrl } = useGetOidcIssuerUrl(currentOrg.id, {
- enabled: isUpdate && selectedMethod === AzureKeyVaultConnectionMethod.ManagedIdentity
+ enabled: selectedMethod === AzureKeyVaultConnectionMethod.ManagedIdentity
});
const onSubmitHandler = async (formData: FormData) => {
@@ -306,6 +316,11 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
const methodDetails = getAppConnectionMethodDetails(selectedMethod);
+ let submitLabel = isUpdate ? "Reconnect to Azure" : "Connect to Azure";
+ if (selectedMethod === AzureKeyVaultConnectionMethod.ManagedIdentity) {
+ submitLabel = isUpdate ? "Verify Connection" : "Create Connection";
+ }
+
return (
<FormProvider {...form}>
<form onSubmit={handleSubmit(onSubmitHandler)}>
@@ -673,26 +688,21 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
</Field>
)}
/>
- {appConnection ? (
- <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, then select Reconnect to Azure to verify it.
- </FieldDescription>
- {issuerUrl && <CopyableValue label="Issuer" value={issuerUrl} />}
- <CopyableValue
- label="Subject Identifier"
- value={`app-connection:${appConnection.id}`}
- />
- <CopyableValue label="Audience" value={AZURE_FEDERATED_TOKEN_AUDIENCE} />
- </Field>
- ) : (
- <FieldDescription className="mb-4">
- After you create the connection, open Edit Credentials to copy the values for the
- federated credential in Azure.
+ <Field className="mb-4">
+ <FieldLabel>Federated Credential</FieldLabel>
+ <FieldDescription>
+ {appConnection
+ ? "Add these values to a federated credential on the managed identity, with the Other issuer scenario, then select Verify Connection."
+ : "The subject is filled in once you create the connection. Then add these values to a federated credential on the managed identity, with the Other issuer scenario."}
</FieldDescription>
- )}
+ {issuerUrl && <CopyableValue label="Issuer" value={issuerUrl} />}
+ <CopyableValue
+ label="Subject Identifier"
+ value={appConnection && `app-connection:${appConnection.id}`}
+ placeholder="app-connection:<connection ID>"
+ />
+ <CopyableValue label="Audience" value={AZURE_FEDERATED_TOKEN_AUDIENCE} />
+ </Field>
</>
)}
@@ -708,7 +718,7 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId
isRedirecting
}
>
- {isUpdate ? "Reconnect to Azure" : "Connect to Azure"}
+ {submitLabel}
</Button>
<Button
type="button"