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
improvement(agent-vault): simplify the MCP OAuth authorization card
Saif22415c5305d7
diff --git a/docs/documentation/platform/agent-vault/mcp-servers.mdx b/docs/documentation/platform/agent-vault/mcp-servers.mdxindex a12d4b2a4f..0d241acdab 100644--- a/docs/documentation/platform/agent-vault/mcp-servers.mdx+++ b/docs/documentation/platform/agent-vault/mcp-servers.mdx@@ -45,16 +45,16 @@ The service covers every request to the server URL's host, whatever the path. If## Credential types-### OAuth 2.1+### OAuth-With OAuth 2.1, you sign in to the provider once from Infisical. Infisical stores the tokens the provider returns and refreshes the access token before it expires. The proxy only receives the access token, and the agent never receives any token.+With OAuth, you sign in to the provider once from Infisical. Infisical stores the tokens the provider returns and refreshes the access token before it expires. The proxy only receives the access token, and the agent never receives any token.<Steps><Step>- Under **Auth Method**, select **OAuth 2.1**, then select **Authorize**.+ Under **Auth Method**, select **OAuth**, then select the button that names your server, such as **Authorize with mcp.linear.app**.<Note>- Some servers, such as GitHub's, don't let Infisical register itself as an OAuth client. For these servers, the card asks for an OAuth app of your own instead. Create an OAuth app with the provider, and set its redirect URI to the **Redirect URI** the card shows. Then enter the app's **Client ID** and **Client Secret** (leave **Client Secret** empty for a public client), and select **Authorize** again.+ Some servers, such as GitHub's, don't let Infisical register itself as an OAuth client. For these servers, the card asks for an OAuth app of your own instead. Create an OAuth app with the provider, and set its redirect URI to the **Redirect URI** the card shows. Then enter the app's **Client ID** and **Client Secret** (leave **Client Secret** empty for a public client), and authorize again.</Note></Step><Step>@@ -73,7 +73,7 @@ With OAuth 2.1, you sign in to the provider once from Infisical. Infisical storeWith a Bearer token, you paste a token the MCP server accepts into **Token**, such as a [GitHub personal access token](https://github.com/settings/tokens) for GitHub MCP. The proxy sends the token as `Authorization: Bearer <token>`.-To send the token in a different header or with a different prefix, expand **Advanced** and change **Header Name** or **Prefix**. To use a token that several services share, type `{{` in **Token** and select a [variable](/documentation/platform/agent-vault/variables).+To send the token in a different header or with a different prefix, expand **Advanced Options** and change **Header Name** or **Prefix**. To use a token that several services share, type `{{` in **Token** and select a [variable](/documentation/platform/agent-vault/variables).## Custom headers@@ -81,7 +81,7 @@ If the MCP server needs another header besides the credential, such as an organi<Steps><Step>- On the **Credential** step, expand **Advanced** and select **Add Custom Header**.+ On the **Credential** step, expand **Advanced Options** and select **Add Custom Header**.</Step><Step>Enter the header's **Name**, an optional **Prefix**, and the **Value**. To use a [variable](/documentation/platform/agent-vault/variables), type `{{` in **Value**.diff --git a/frontend/src/components/agent-vault/service-sheet/McpCredentialFields.tsx b/frontend/src/components/agent-vault/service-sheet/McpCredentialFields.tsxindex 1abd710b26..e68ef66821 100644--- a/frontend/src/components/agent-vault/service-sheet/McpCredentialFields.tsx+++ b/frontend/src/components/agent-vault/service-sheet/McpCredentialFields.tsx@@ -1,17 +1,17 @@import { useId } from "react";import { Controller, useFormContext } from "react-hook-form";-import { KeyRoundIcon, ShieldCheckIcon } from "lucide-react";import {Field,FieldContent,- FieldDescription,FieldError,FieldLabel,- FieldTitle,Input,- RadioGroup,- RadioGroupItem+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue} from "@app/components/v3";import { AgentVaultCredentialType } from "@app/hooks/api/agentVault";import { TAgentVaultService } from "@app/hooks/api/agentVault/types";@@ -23,20 +23,13 @@ import { TServiceForm, UNCHANGED_SECRET } from "./serviceSchema";import { useServiceVariables } from "./ServiceVariablesContext";import { TransformationsFields } from "./TransformationsFields";-const AUTH_METHOD_OPTIONS = [- {- type: AgentVaultCredentialType.OAuth,- icon: ShieldCheckIcon,- title: "OAuth 2.1",- description: "Authorize once. Infisical stores the token and keeps it fresh."- },- {- type: AgentVaultCredentialType.Bearer,- icon: KeyRoundIcon,- title: "Bearer Token",- description: "A token you provide, sent in a header on every request to the server."- }-] as const;+const AUTH_METHOD_LABELS = {+ [AgentVaultCredentialType.OAuth]: "OAuth",+ [AgentVaultCredentialType.Bearer]: "Bearer Token"+} as const;++const DEFAULT_HEADER_NAME = "Authorization";+const DEFAULT_HEADER_PREFIX = "Bearer";type Props = {accessBundleId: string;@@ -50,6 +43,9 @@ export const McpCredentialFields = ({ accessBundleId, service, openItem, onOpenCconst { storedKeys } = useServiceVariables();const secret = watch("secret");const credentialType = watch("credentialType");+ const headerName = watch("headerName");+ const headerPrefix = watch("headerPrefix");+ const customHeaders = watch("customHeaders");const isOAuth = credentialType === AgentVaultCredentialType.OAuth;const authMethodLabelId = useId();const headerNameInputId = useId();@@ -63,36 +59,34 @@ export const McpCredentialFields = ({ accessBundleId, service, openItem, onOpenC};const hasStoredSecret = storedType === AgentVaultCredentialType.Bearer;+ const trimmedHeaderName = (headerName ?? "").trim();+ // The default Authorization: Bearer header needs no preview; it earns one once something is customized.+ const isHeaderCustomized =+ !isOAuth &&+ ((trimmedHeaderName && trimmedHeaderName.toLowerCase() !== DEFAULT_HEADER_NAME.toLowerCase()) ||+ (headerPrefix ?? "").trim() !== DEFAULT_HEADER_PREFIX);+ const showSends = isHeaderCustomized || customHeaders.length > 0;return (<div className="flex flex-col gap-5"><Field><FieldLabel id={authMethodLabelId}>Auth Method</FieldLabel><FieldContent>- <RadioGroup- aria-labelledby={authMethodLabelId}+ <Selectvalue={isOAuth ? AgentVaultCredentialType.OAuth : AgentVaultCredentialType.Bearer}onValueChange={(value) => selectType(value as AgentVaultCredentialType)}- className="gap-3 md:grid-cols-2">- {AUTH_METHOD_OPTIONS.map(({ type, icon: Icon, title, description }) => {- const id = `${authMethodLabelId}-${type}`;- return (- <FieldLabel key={type} htmlFor={id} variant="av">- <Field orientation="horizontal">- <FieldContent>- <FieldTitle>- <Icon />- {title}- </FieldTitle>- <FieldDescription>{description}</FieldDescription>- </FieldContent>- <RadioGroupItem id={id} value={type} />- </Field>- </FieldLabel>- );- })}- </RadioGroup>+ <SelectTrigger aria-labelledby={authMethodLabelId} className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent position="popper">+ {Object.entries(AUTH_METHOD_LABELS).map(([type, label]) => (+ <SelectItem key={type} value={type}>+ {label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select></FieldContent></Field>@@ -124,12 +118,11 @@ export const McpCredentialFields = ({ accessBundleId, service, openItem, onOpenC/>)}- <SendsPreview />+ {showSends && <SendsPreview />}<TransformationsFieldsopenItem={openItem}onOpenChange={onOpenChange}- label="Advanced"hasSubstitutions={false}>{!isOAuth && (diff --git a/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx b/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsxindex 3f546e8e3f..0e5e17b558 100644--- a/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx+++ b/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx@@ -1,24 +1,26 @@-import { useId, useState } from "react";+import { Fragment, ReactNode, useId, useState } from "react";import { useFormContext, useWatch } from "react-hook-form";import { format } from "date-fns";-import { CheckIcon, CircleAlertIcon, ShieldCheckIcon } from "lucide-react";+import { CheckIcon, CircleAlertIcon, CircleXIcon, InfoIcon } from "lucide-react";+import { twMerge } from "tailwind-merge";import {- Alert,- AlertDescription,Badge,Button,CopyButton,- Detail,- DetailLabel,- DetailValue,Field,FieldContent,FieldDescription,FieldError,FieldLabel,Input,- Spinner+ InputGroup,+ InputGroupAddon,+ InputGroupInput,+ Spinner,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@app/components/v3";import { AgentVaultOAuthStatus } from "@app/hooks/api/agentVault";import { TAgentVaultService } from "@app/hooks/api/agentVault/types";@@ -31,6 +33,8 @@ import {} from "./serviceSchema";import { useOAuthAuthorize } from "./useOAuthAuthorize";+const CALLBACK_PATH = "/agent-vault/oauth/callback";+const hostOf = (serverUrl: string) => {try {return new URL(serverUrl).host;@@ -39,19 +43,6 @@ const hostOf = (serverUrl: string) => {}};-const ScopeList = ({ scopes }: { scopes: string[] }) =>- scopes.length ? (- <div className="flex flex-wrap gap-1.5">- {scopes.map((scope) => (- <Badge key={scope} variant="outline" className="font-mono">- {scope}- </Badge>- ))}- </div>- ) : (- <span className="text-muted">None requested</span>- );-const OAUTH_STATUS_VARIANTS = {[AgentVaultOAuthStatus.Connected]: "success",[AgentVaultOAuthStatus.NeedsReauthorization]: "danger",@@ -65,6 +56,75 @@ export const OAuthStatusBadge = ({ status }: { status: AgentVaultOAuthStatus })</Badge>);+const TONE_CLASS = { danger: "text-danger", warning: "text-warning" } as const;++const Status = ({+ icon,+ tone,+ title,+ children+}: {+ icon?: ReactNode;+ tone?: "warning" | "danger";+ title: ReactNode;+ children?: ReactNode;+}) => (+ <div className="flex min-w-0 flex-col gap-0.5">+ <span+ className={twMerge(+ "flex items-center gap-1.5 text-sm [&>svg]:size-3.5 [&>svg]:shrink-0",+ tone ? TONE_CLASS[tone] : "text-foreground"+ )}+ >+ {icon}+ {title}+ </span>+ {children && <span className="text-xs text-muted">{children}</span>}+ </div>+);++const SCOPE_PREVIEW = 10;++const ScopeValues = ({ scopes, className }: { scopes: string[]; className?: string }) => {+ const [isExpanded, setIsExpanded] = useState(false);+ const shown = isExpanded ? scopes : scopes.slice(0, SCOPE_PREVIEW);+ const hidden = scopes.length - shown.length;+ return (+ <span className={twMerge("min-w-0", className)}>+ {shown.map((scope, index) => (+ <Fragment key={scope}>+ <span className="whitespace-nowrap">{scope}</span>+ {index < shown.length - 1 ? ", " : ""}+ </Fragment>+ ))}+ {hidden > 0 && (+ <Button+ type="button"+ variant="link"+ size="sm"+ className="ml-1.5 align-baseline text-xs text-muted hover:text-foreground"+ onClick={() => setIsExpanded(true)}+ >+ +{hidden} more+ </Button>+ )}+ </span>+ );+};++const Scopes = ({ granted, requested }: { granted: string[]; requested: string[] }) => (+ <div className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs">+ <span className="text-muted">Scopes</span>+ {granted.length ? <ScopeValues scopes={granted} /> : <span className="text-muted">None</span>}+ {requested.length > 0 && (+ <>+ <span className="text-muted">Requested</span>+ <ScopeValues scopes={requested} className="text-warning" />+ </>+ )}+ </div>+);+type Props = {accessBundleId: string;service?: TAgentVaultService | null;@@ -91,9 +151,8 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service }: Props) => {});const clientIdInputId = useId();const clientSecretInputId = useId();- // The server reuses a stored client on reauthorization, so a rotated or expired one can only be- // replaced by entering it here.- const [isReplacingClient, setIsReplacingClient] = useState(false);+ const redirectUriInputId = useId();+ const [isUsingOwnApp, setIsUsingOwnApp] = useState(false);const trimmedUrl = serverUrl.trim();const host = hostOf(trimmedUrl);@@ -119,10 +178,12 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service }: Props) => {});const isWaiting = state.status === "starting" || state.status === "pending";- const isClientEntered = isClientRequired || isReplacingClient;+ const wantsOwnApp = isClientRequired || isUsingOwnApp;+ const isOwnApp = wantsOwnApp && !isNewlyAuthorized;+ const hasAuthorization = isNewlyAuthorized || Boolean(stored);- const keepSavedClient = () => {- setIsReplacingClient(false);+ const switchToAutomaticSetup = () => {+ setIsUsingOwnApp(false);setValue("oauthClientId", "");setValue("oauthClientSecret", "");};@@ -132,154 +193,192 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service }: Props) => {accessBundleId,serverUrl: trimmedUrl,...(stored && service ? { serviceId: service.id } : {}),- ...(isClientEntered- ? { clientId: clientId.trim(), clientSecret: clientSecret || undefined }- : {})+ ...(wantsOwnApp ? { clientId: clientId.trim(), clientSecret: clientSecret || undefined } : {})});- const hasAuthorization = isNewlyAuthorized || Boolean(stored);- const authorizeLabel = hasAuthorization ? "Reauthorize" : "Authorize";+ const requested = stored+ ? stored.requiredScopes.filter((scope) => !stored.grantedScopes.includes(scope))+ : [];++ const isProblem =+ state.status === "failed" ||+ (stored && stored.status !== AgentVaultOAuthStatus.Connected && !isNewlyAuthorized);++ let authorizeLabel = `Authorize with ${host}`;+ if (state.status === "failed") authorizeLabel = "Try Again";+ else if (hasAuthorization) authorizeLabel = "Reauthorize";++ const authorizeButton = isWaiting ? (+ <div className="flex items-center gap-2">+ <Button type="button" variant="outline" size="sm" isDisabled>+ <Spinner size="xs" className="m-0 shrink-0 fill-product-av" />+ Waiting for sign-in...+ </Button>+ <Button type="button" variant="ghost" size="sm" onClick={cancel}>+ Cancel+ </Button>+ </div>+ ) : (+ <Button+ type="button"+ variant={hasAuthorization && !isProblem ? "outline" : "av"}+ size="sm"+ className="shrink-0"+ onClick={handleAuthorize}+ isDisabled={!trimmedUrl || (wantsOwnApp && !clientId.trim())}+ >+ {authorizeLabel}+ </Button>+ );++ const renderStatus = (): { head: ReactNode; details?: ReactNode } | null => {+ if (state.status === "failed") {+ return {+ head: (+ <Status icon={<CircleXIcon />} tone="danger" title="Couldn't Authorize">+ {state.message}+ </Status>+ ),+ details: stored ? (+ <Scopes granted={stored.grantedScopes} requested={requested} />+ ) : undefined+ };+ }- const renderStatus = () => {if (isNewlyAuthorized) {- return (- <div className="flex flex-col gap-4">- <div className="flex items-center gap-2">- <Badge variant="success">- <CheckIcon />- Authorized- </Badge>- <span className="text-sm text-muted">- {stored ? "Saving replaces the stored tokens." : `Connected to ${host}.`}- </span>- </div>- <Detail>- <DetailLabel>Granted Scopes</DetailLabel>- <DetailValue>- <ScopeList scopes={scopes} />- </DetailValue>- </Detail>- </div>- );+ return {+ head: <Status icon={<CheckIcon />} title={stored ? "Reauthorized" : "Authorized"} />,+ details: <Scopes granted={scopes} requested={[]} />+ };}- if (stored) {- return (- <div className="flex flex-col gap-4">- <div className="flex items-center gap-2">- <OAuthStatusBadge status={stored.status} />- {stored.status === AgentVaultOAuthStatus.NeedsReauthorization && (- <span className="text-sm text-muted">- The server no longer accepts the stored tokens. Reauthorize to restore access.- </span>- )}- {stored.status === AgentVaultOAuthStatus.NeedsAdditionalScopes && (- <span className="text-sm text-muted">- A tool call needed scopes this authorization lacks. Reauthorize to grant them.- </span>- )}- </div>- <div className="flex flex-wrap gap-x-8 gap-y-4">- <Detail>- <DetailLabel>Granted Scopes</DetailLabel>- <DetailValue>- <ScopeList scopes={stored.grantedScopes} />- </DetailValue>- </Detail>- {stored.status === AgentVaultOAuthStatus.NeedsAdditionalScopes &&- stored.requiredScopes.length > 0 && (- <Detail>- <DetailLabel>Missing Scopes</DetailLabel>- <DetailValue>- <ScopeList scopes={stored.requiredScopes} />- </DetailValue>- </Detail>- )}- <Detail>- <DetailLabel>Authorized By</DetailLabel>- <DetailValue>- {stored.authorizedBy?.username ?? "Unknown"}- {stored.authorizedAt && (- <>- {" on "}- <span className="font-mono">- {format(new Date(stored.authorizedAt), "MMM d, yyyy h:mm a")}- </span>- </>- )}- </DetailValue>- </Detail>- </div>- {stored.lastError && (- <Alert variant="warning">- <CircleAlertIcon />- <AlertDescription>Last refresh failed: {stored.lastError}</AlertDescription>- </Alert>- )}- </div>+ if (!stored) return null;++ const authorizedAt = stored.authorizedAt ? new Date(stored.authorizedAt) : null;++ let head: ReactNode;+ if (stored.status === AgentVaultOAuthStatus.NeedsReauthorization) {+ head = (+ <Status+ icon={<CircleXIcon />}+ tone="danger"+ title={OAUTH_STATUS_LABELS[AgentVaultOAuthStatus.NeedsReauthorization]}+ >+ {host} no longer accepts this authorization.+ </Status>+ );+ } else if (stored.status === AgentVaultOAuthStatus.NeedsAdditionalScopes) {+ head = (+ <Status+ icon={<CircleAlertIcon />}+ tone="warning"+ title={OAUTH_STATUS_LABELS[AgentVaultOAuthStatus.NeedsAdditionalScopes]}+ >+ An agent needed scopes this authorization doesn't have.+ </Status>+ );+ } else {+ head = (+ <Status+ title={+ authorizedAt ? (+ <Tooltip>+ <TooltipTrigger asChild>+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}+ <span tabIndex={0}>Authorized on {format(authorizedAt, "MMM d, yyyy")}</span>+ </TooltipTrigger>+ <TooltipContent>{format(authorizedAt, "MMM d, yyyy h:mm a")}</TooltipContent>+ </Tooltip>+ ) : (+ "Authorized"+ )+ }+ />);}- return (- <p className="text-sm text-muted">- Sign in to {host} in a pop-up window. Infisical stores the tokens it returns, and the agent- never sees them.- </p>- );+ return {+ head,+ details: (+ <div className="flex flex-col gap-2">+ {stored.lastError && stored.status !== AgentVaultOAuthStatus.NeedsReauthorization && (+ <Tooltip>+ <TooltipTrigger asChild>+ <span+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex+ tabIndex={0}+ className={twMerge(+ "flex w-fit items-center gap-1.5 text-xs",+ // Under a yellow status, Reauthorize already fixes this, so it shouldn't compete with it.+ stored.status === AgentVaultOAuthStatus.NeedsAdditionalScopes+ ? "text-muted"+ : "text-danger"+ )}+ >+ <InfoIcon className="size-3 shrink-0" />+ The last token refresh failed.+ </span>+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">{stored.lastError}</TooltipContent>+ </Tooltip>+ )}+ <Scopes granted={stored.grantedScopes} requested={requested} />+ </div>+ )+ };};+ const status = renderStatus();+return (<Field><FieldLabel>Authorization</FieldLabel><FieldContent>- <div className="flex flex-col gap-4 rounded-md border border-border bg-container p-4">- <div className="flex items-start gap-3">- <ShieldCheckIcon className="mt-0.5 size-4 shrink-0 text-muted" />- <div className="min-w-0 flex-1">{renderStatus()}</div>- </div>-- {isClientEntered && !isNewlyAuthorized && (- <div className="flex flex-col gap-4 border-t border-border pt-4">- {!isClientRequired && (- <p className="text-sm text-muted">- Enter the client ID and secret of the OAuth app to use from now on. They replace- the saved client when you reauthorize. Its redirect URI must point to this- Infisical instance.- </p>- )}- {isClientRequired && registrationError && (- <>- <Alert variant="warning">- <CircleAlertIcon />- <AlertDescription>{registrationError}</AlertDescription>- </Alert>- <p className="text-sm text-muted">- Create an OAuth app with the provider, set its redirect URI to the one below,- then enter its client ID and secret.- </p>- </>- )}- {isClientRequired && !registrationError && (- <p className="text-sm text-muted">- {host} doesn't let Infisical register itself as a client. Create an OAuth app- with the provider, set its redirect URI to the one below, then enter its client ID- and secret.+ <div className="flex flex-col gap-3">+ {status ? (+ <div className="flex flex-col gap-2">+ <div className="flex items-start justify-between gap-4">+ <div className="min-w-0 flex-1">{status.head}</div>+ {!isOwnApp && authorizeButton}+ </div>+ {status.details}+ </div>+ ) : (+ !isOwnApp && <div>{authorizeButton}</div>+ )}++ {isOwnApp && (+ <div className="flex flex-col gap-4">+ {isClientRequired && (+ <p className="text-xs text-muted">+ {registrationError+ ? `${host} didn't accept automatic setup, so use your own OAuth app.`+ : `${host} needs your own OAuth app.`}</p>)}- {redirectUri && (- <Field>- <FieldLabel>Redirect URI</FieldLabel>- <FieldContent>- <div className="flex items-center gap-2">- <code className="min-w-0 flex-1 truncate rounded-md border border-border bg-card px-2 py-1.5 font-mono text-xs">- {redirectUri}- </code>- <CopyButton value={redirectUri} ariaLabel="Copy redirect URI" />- </div>- </FieldContent>- </Field>- )}- <div className="flex flex-col gap-3 md:flex-row">+ <Field>+ <FieldLabel htmlFor={redirectUriInputId}>Redirect URI</FieldLabel>+ <FieldContent>+ <InputGroup>+ <InputGroupInput+ id={redirectUriInputId}+ readOnly+ value={redirectUri ?? `${window.location.origin}${CALLBACK_PATH}`}+ />+ <InputGroupAddon align="inline-end">+ <CopyButton+ value={redirectUri ?? `${window.location.origin}${CALLBACK_PATH}`}+ ariaLabel="Copy redirect URI"+ />+ </InputGroupAddon>+ </InputGroup>+ <FieldDescription>+ Add this as a redirect URI in your OAuth app on {host}, then enter the+ app's client ID and secret.+ </FieldDescription>+ </FieldContent>+ </Field>+ <div className="flex flex-col gap-4 md:flex-row md:gap-3"><Field className="flex-1"><FieldLabel htmlFor={clientIdInputId}>Client ID</FieldLabel><FieldContent>@@ -295,7 +394,7 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service }: Props) => {</FieldContent></Field><Field className="flex-1">- <FieldLabel htmlFor={clientSecretInputId}>Client Secret</FieldLabel>+ <FieldLabel htmlFor={clientSecretInputId}>Client Secret (optional)</FieldLabel><FieldContent><Inputtype="password"@@ -305,56 +404,25 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service }: Props) => {autoComplete="new-password"isError={Boolean(errors.oauthClientSecret)}/>- <FieldDescription>Leave empty for a public client.</FieldDescription><FieldError>{errors.oauthClientSecret?.message}</FieldError></FieldContent></Field></div>+ <div>{authorizeButton}</div></div>)}- {state.status === "failed" && (- <Alert variant="danger">- <CircleAlertIcon />- <AlertDescription>{state.message}</AlertDescription>- </Alert>- )}-- {isWaiting ? (- <div className="flex items-center justify-between gap-3">- <div className="flex min-w-0 items-center gap-2 text-sm text-muted">- <Spinner size="xs" className="m-0 shrink-0 fill-product-av" />- <span>- {state.status === "pending" && state.popupClosed- ? "Waiting for the authorization. If you closed the window before finishing, select Cancel and try again."- : `Waiting for you to finish signing in to ${host} in the pop-up window.`}- </span>- </div>- <Button type="button" variant="ghost" size="sm" onClick={cancel}>- Cancel- </Button>- </div>- ) : (- <div className="flex flex-wrap items-center gap-2">+ {!isClientRequired && !isNewlyAuthorized && !isWaiting && (+ <div><Buttontype="button"- variant={hasAuthorization ? "outline" : "av"}+ variant="link"size="sm"- onClick={handleAuthorize}- isDisabled={!trimmedUrl || (isClientEntered && !clientId.trim())}+ className="text-muted hover:text-foreground"+ onClick={isUsingOwnApp ? switchToAutomaticSetup : () => setIsUsingOwnApp(true)}>- {state.status === "failed" ? "Try Again" : authorizeLabel}+ {isUsingOwnApp ? "Use automatic setup" : "Use your own OAuth app"}</Button>- {stored && !isClientRequired && !isNewlyAuthorized && (- <Button- type="button"- variant="ghost"- size="sm"- onClick={isReplacingClient ? keepSavedClient : () => setIsReplacingClient(true)}- >- {isReplacingClient ? "Keep Saved Client" : "Use a Different Client"}- </Button>- )}</div>)}</div>diff --git a/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts b/frontend/src/components/agent-vault/service-sheet/serviceSchema.tsindex e26e9d4c95..98996cc84b 100644--- a/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts+++ b/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts@@ -34,7 +34,7 @@ export const CREDENTIAL_LABELS: Record<AgentVaultCredentialType, string> = {[AgentVaultCredentialType.Bearer]: "Bearer",[AgentVaultCredentialType.Basic]: "Basic Auth",[AgentVaultCredentialType.Passthrough]: "Pass-through",- [AgentVaultCredentialType.OAuth]: "OAuth 2.1"+ [AgentVaultCredentialType.OAuth]: "OAuth"};export const HTTP_CREDENTIAL_TYPES = [@@ -301,7 +301,7 @@ export const buildServiceSchema = (service?: TAgentVaultService | null, variablectx.addIssue({code: z.ZodIssueCode.custom,path: ["credentialType"],- message: "An MCP server takes OAuth 2.1 or a bearer token."+ message: "An MCP server takes OAuth or a bearer token."});}if (isOAuthAuthorizationMissing(data, service)) {diff --git a/frontend/src/components/agent-vault/service-sheet/useOAuthAuthorize.ts b/frontend/src/components/agent-vault/service-sheet/useOAuthAuthorize.tsindex 7850d9941c..35bfbfbeee 100644--- a/frontend/src/components/agent-vault/service-sheet/useOAuthAuthorize.ts+++ b/frontend/src/components/agent-vault/service-sheet/useOAuthAuthorize.ts@@ -18,7 +18,7 @@ const POPUP_FEATURES = "popup,width=600,height=720";export type TOAuthAuthorizeState =| { status: "idle" }| { status: "starting" }- | { status: "pending"; popupClosed: boolean }+ | { status: "pending" }| { status: "authorized"; authorization: TAgentVaultOAuthAuthorization }| { status: "failed"; message: string };@@ -42,11 +42,9 @@ export const useOAuthAuthorize = ({id: string;attempt: number;} | null>(null);- const {- data: authorization,- error: authorizationError,- dataUpdatedAt- } = useGetAgentVaultOAuthAuthorization(pendingAuthorization?.id ?? "");+ const { data: authorization, error: authorizationError } = useGetAgentVaultOAuthAuthorization(+ pendingAuthorization?.id ?? ""+ );const popupRef = useRef<Window | null>(null);// Bumped by every new attempt and by cancel, so a response for an older attempt is dropped.@@ -74,10 +72,7 @@ export const useOAuthAuthorize = ({useEffect(() => {if (!pendingAuthorization || attemptRef.current !== pendingAuthorization.attempt) return;if (authorizationError) {- fail(- serverMessage(authorizationError) ??- "Couldn't check the authorization status. Select Authorize to try again."- );+ fail(serverMessage(authorizationError) ?? "Couldn't check the authorization status.");return;}if (!authorization) return;@@ -88,24 +83,15 @@ export const useOAuthAuthorize = ({return;}if (authorization.status === AgentVaultOAuthAuthorizationStatus.Failed) {- fail(authorization.error ?? "The server refused the authorization. Try again.");- return;+ fail(authorization.error ?? "The server refused the authorization.");}-- // Cross-Origin-Opener-Policy can report an open popup as closed, so this changes only the hint.- const popupClosed = !popupRef.current || popupRef.current.closed;- setState((previous) =>- previous.status === "pending" && previous.popupClosed !== popupClosed- ? { status: "pending", popupClosed }- : previous- );- }, [pendingAuthorization, authorization, authorizationError, dataUpdatedAt, fail, stop]);+ }, [pendingAuthorization, authorization, authorizationError, fail, stop]);useEffect(() => {if (!pendingAuthorization) return undefined;const timeout = window.setTimeout(() => {if (attemptRef.current === pendingAuthorization.attempt) {- fail("The authorization timed out after 5 minutes. Select Authorize to try again.");+ fail("Timed out waiting for the sign-in.");}}, POLL_TIMEOUT_MS);return () => window.clearTimeout(timeout);@@ -122,8 +108,7 @@ export const useOAuthAuthorize = ({if (!popup) {setState({status: "failed",- message:- "Your browser blocked the authorization window. Allow pop-ups for this site, then select Authorize again."+ message: "Your browser blocked the sign-in window. Allow pop-ups for this site."});return;}@@ -151,16 +136,13 @@ export const useOAuthAuthorize = ({return;}popup.location.href = createdAuthorization.authorizeUrl;- setState({ status: "pending", popupClosed: false });+ setState({ status: "pending" });setPendingAuthorization({ id: createdAuthorization.id, attempt });}).catch((error: unknown) => {if (attemptRef.current !== attempt) return;- fail(- serverMessage(error) ??- "Couldn't start the authorization. Check the server URL and try again."- );+ fail(serverMessage(error) ?? "Couldn't start the sign-in.");});},[createAuthorization, fail, stop]diff --git a/frontend/src/pages/agent-vault/AgentVaultOAuthCallbackPage/AgentVaultOAuthCallbackPage.tsx b/frontend/src/pages/agent-vault/AgentVaultOAuthCallbackPage/AgentVaultOAuthCallbackPage.tsxindex a2cd0fe7fb..4feb5b8b8b 100644--- a/frontend/src/pages/agent-vault/AgentVaultOAuthCallbackPage/AgentVaultOAuthCallbackPage.tsx+++ b/frontend/src/pages/agent-vault/AgentVaultOAuthCallbackPage/AgentVaultOAuthCallbackPage.tsx@@ -21,7 +21,6 @@ import {} from "@app/hooks/api/agentVault";const CLOSE_AFTER_SUCCESS_MS = 1000;-const CLOSE_AFTER_FAILURE_MS = 4000;type TOutcome =| { status: "working" }@@ -78,11 +77,8 @@ export const AgentVaultOAuthCallbackPage = () => {}, []);useEffect(() => {- if (outcome.status === "working") return undefined;- const id = window.setTimeout(- () => window.close(),- outcome.status === "authorized" ? CLOSE_AFTER_SUCCESS_MS : CLOSE_AFTER_FAILURE_MS- );+ if (outcome.status !== "authorized") return undefined;+ const id = window.setTimeout(() => window.close(), CLOSE_AFTER_SUCCESS_MS);return () => window.clearTimeout(id);}, [outcome.status]);@@ -90,11 +86,10 @@ export const AgentVaultOAuthCallbackPage = () => {let description = "Confirming the authorization with Infisical.";if (outcome.status === "authorized") {title = "Authorization Complete";- description =- "This window closes on its own. Return to Infisical to finish adding the service.";+ description = "This window closes on its own. Return to Infisical to finish.";} else if (outcome.status === "failed") {title = "Authorization Failed";- description = "This window closes on its own. Return to Infisical and select Authorize again.";+ description = "Return to Infisical and try again.";}return (@@ -108,7 +103,7 @@ export const AgentVaultOAuthCallbackPage = () => {<CardDescription>{description}</CardDescription></CardHeader>{outcome.status !== "working" && (- <CardContent className="flex flex-col gap-4">+ <CardContent className="mt-4 flex flex-col gap-4">{outcome.status === "failed" && (<Alert variant="danger"><CircleAlertIcon />