Skip to content

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

misc: addressed greptile comments

Sheen Capadngan3a30c57b7e6b
diff --git a/docs/documentation/platform/agent-vault/session-logs.mdx b/docs/documentation/platform/agent-vault/session-logs.mdx
index c1139a0485..e998ed379e 100644
--- a/docs/documentation/platform/agent-vault/session-logs.mdx
+++ b/docs/documentation/platform/agent-vault/session-logs.mdx
@@ -254,7 +254,7 @@ Request and response bodies, headers, and query strings aren't recorded. For a r
If a request matched an MCP service, its row shows an **MCP** badge and the call the agent made, in place of the path:
-- For a tool call, the tool's name and the method, such as `create_issue` and `tools/call`
+- For a tool call, the tool's name, such as `create_issue`
- For any other call, the method, such as `initialize` or `tools/list`
The proxy never records a tool's arguments or results.
diff --git a/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx b/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx
index 6135dee9fa..7ab8751f7c 100644
--- a/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/OAuthAuthorizeCard.tsx
@@ -145,18 +145,26 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service, onSignInChange }:
clearErrors,
formState: { errors }
} = useFormContext<TServiceForm>();
- const [serverUrl, authorizationId, authorizedUrl, scopes, clientId = "", clientSecret = ""] =
- useWatch({
- control,
- name: [
- "serverUrl",
- "oauthAuthorizationId",
- "oauthAuthorizedUrl",
- "oauthScopes",
- "oauthClientId",
- "oauthClientSecret"
- ]
- });
+ const [
+ serverUrl,
+ authorizationId,
+ authorizedUrl,
+ scopes,
+ clientId = "",
+ clientSecret = "",
+ rejection = ""
+ ] = useWatch({
+ control,
+ name: [
+ "serverUrl",
+ "oauthAuthorizationId",
+ "oauthAuthorizedUrl",
+ "oauthScopes",
+ "oauthClientId",
+ "oauthClientSecret",
+ "oauthAuthorizationRejection"
+ ]
+ });
const clientIdInputId = useId();
const clientSecretInputId = useId();
const redirectUriInputId = useId();
@@ -176,6 +184,7 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service, onSignInChange }:
const { state, isClientRequired, isOAuthAdvertised, redirectUri, authorize, cancel } =
useOAuthAuthorize({
onAuthorized: (authorization) => {
+ setValue("oauthAuthorizationRejection", "");
setValue("oauthAuthorizedUrl", trimmedUrl, { shouldDirty: true });
setValue("oauthScopes", authorization.scopes, { shouldDirty: true });
setValue("oauthAuthorizationId", authorization.id, {
@@ -465,6 +474,22 @@ export const OAuthAuthorizeCard = ({ accessBundleId, service, onSignInChange }:
)}
</div>
<FieldError>{errors.oauthAuthorizationId?.message}</FieldError>
+ {rejection && stored && !isWaiting && (
+ <div>
+ <Button
+ type="button"
+ variant="link"
+ size="sm"
+ className="text-muted hover:text-foreground"
+ onClick={() => {
+ setValue("oauthAuthorizationRejection", "");
+ clearErrors("oauthAuthorizationId");
+ }}
+ >
+ Keep Current Login
+ </Button>
+ </div>
+ )}
</FieldContent>
</Field>
);
diff --git a/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx b/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx
index 27cbe4f50f..58a161e6d5 100644
--- a/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx
@@ -102,6 +102,7 @@ const BLANK_SERVICE_FORM: TServiceForm = {
oauthAuthorizationId: "",
oauthAuthorizedUrl: "",
oauthScopes: [],
+ oauthAuthorizationRejection: "",
oauthClientId: "",
oauthClientSecret: "",
methods: [...HTTP_METHODS],
@@ -510,10 +511,12 @@ export const ServiceSheet = ({
// The template step is skipped for a prefilled sheet, so this is where a wrong guess of the type is corrected.
const switchPrefillType = (serviceType: AgentVaultServiceType) => {
if (!prefillHost) return;
- const { template: picked, form } = prefillFor(serviceType, prefillHost, prefillPath);
- setTemplate(picked);
- setOpenItem(serviceType === AgentVaultServiceType.Mcp ? "" : ADVANCED_ITEM);
- reset(form);
+ requestDiscardAction(() => {
+ const { template: picked, form } = prefillFor(serviceType, prefillHost, prefillPath);
+ setTemplate(picked);
+ setOpenItem(serviceType === AgentVaultServiceType.Mcp ? "" : ADVANCED_ITEM);
+ reset(form);
+ });
};
const handleTemplatePicked = (
@@ -585,6 +588,7 @@ export const ServiceSheet = ({
: null;
if (rejectedAuthorization) {
setValue("oauthAuthorizationId", "");
+ setValue("oauthAuthorizationRejection", rejectedAuthorization);
setError("oauthAuthorizationId", { type: "server", message: rejectedAuthorization });
setStep(stepKeys.indexOf(ServiceStep.Credential));
return;
@@ -704,6 +708,7 @@ export const ServiceSheet = ({
if (getValues("oauthAuthorizationId") !== oauthAuthorizationId) return;
setValue("oauthAuthorizationId", "");
if (getValues("credentialType") === AgentVaultCredentialType.OAuth) {
+ setValue("oauthAuthorizationRejection", OAUTH_AUTHORIZATION_EXPIRED_MESSAGE);
setError("oauthAuthorizationId", {
type: "server",
message: OAUTH_AUTHORIZATION_EXPIRED_MESSAGE
diff --git a/frontend/src/components/agent-vault/service-sheet/serviceSchema.test.ts b/frontend/src/components/agent-vault/service-sheet/serviceSchema.test.ts
index cc3995bce2..3e1cae84ed 100644
--- a/frontend/src/components/agent-vault/service-sheet/serviceSchema.test.ts
+++ b/frontend/src/components/agent-vault/service-sheet/serviceSchema.test.ts
@@ -249,6 +249,41 @@ describe("buildServiceSchema with OAuth", () => {
]);
});
+ it("ignores leftover client values once the service switches to a bearer token", () => {
+ const result = buildServiceSchema(storedOAuthService()).safeParse(
+ mcpForm({
+ credentialType: AgentVaultCredentialType.Bearer,
+ secret: "token",
+ oauthClientId: "{{GITHUB_CLIENT_ID}}",
+ oauthClientSecret: "\u201csecret\u201d"
+ })
+ );
+ expect(result.success).toBe(true);
+ });
+
+ it("refuses to save an existing service whose new authorization expired, until it is reauthorized or kept", () => {
+ const schema = buildServiceSchema(storedOAuthService());
+ const expired = schema.safeParse(
+ mcpForm({
+ oauthAuthorizationRejection: "This authorization expired before the service was saved."
+ })
+ );
+ expect(expired.error?.issues.map(({ path, message }) => [path.join("."), message])).toEqual([
+ ["oauthAuthorizationId", "This authorization expired before the service was saved."]
+ ]);
+
+ expect(schema.safeParse(mcpForm({ oauthAuthorizationRejection: "" })).success).toBe(true);
+ expect(
+ schema.safeParse(
+ mcpForm({
+ oauthAuthorizationRejection: "This authorization expired before the service was saved.",
+ oauthAuthorizationId: "auth-2",
+ oauthAuthorizedUrl: SERVER_URL
+ })
+ ).success
+ ).toBe(true);
+ });
+
it("ignores the bearer header fields and reserves Authorization for the token", () => {
const authorized = { oauthAuthorizationId: "auth-1", oauthAuthorizedUrl: SERVER_URL };
expect(
diff --git a/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts b/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts
index ffba4e898e..4b1c6a9057 100644
--- a/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts
+++ b/frontend/src/components/agent-vault/service-sheet/serviceSchema.ts
@@ -283,8 +283,12 @@ export const buildServiceSchema = (
// The server URL the authorization was made for, so editing the URL afterwards asks for a new one.
oauthAuthorizedUrl: z.string(),
oauthScopes: z.array(z.string()),
- oauthClientId: oauthClientIdSchema.optional(),
- oauthClientSecret: oauthClientSecretSchema.optional(),
+ // Why a new authorization was dropped (expired, or refused on save). While set, the stored login doesn't
+ // count, so the save can't quietly keep the old one.
+ oauthAuthorizationRejection: z.string().optional(),
+ // Checked in the refine below, only while OAuth is selected: switching to Bearer keeps these values.
+ oauthClientId: z.string().optional(),
+ oauthClientSecret: z.string().optional(),
methods: z.array(z.nativeEnum(AgentVaultHttpMethod)),
pathPrefixes: z
.array(z.string())
@@ -327,11 +331,34 @@ export const buildServiceSchema = (
message: "An MCP server takes OAuth or a bearer token."
});
}
- if (isOAuthAuthorizationMissing(data, service)) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- path: ["oauthAuthorizationId"],
- message: "Authorize the server to continue."
+ if (data.credentialType === AgentVaultCredentialType.OAuth) {
+ if (data.oauthAuthorizationRejection && !data.oauthAuthorizationId) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["oauthAuthorizationId"],
+ message: data.oauthAuthorizationRejection
+ });
+ } else if (isOAuthAuthorizationMissing(data, service)) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["oauthAuthorizationId"],
+ message: "Authorize the server to continue."
+ });
+ }
+ (
+ [
+ ["oauthClientId", oauthClientIdSchema, data.oauthClientId],
+ ["oauthClientSecret", oauthClientSecretSchema, data.oauthClientSecret]
+ ] as const
+ ).forEach(([field, fieldSchema, value]) => {
+ const result = fieldSchema.safeParse(value ?? "");
+ if (!result.success) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: [field],
+ message: result.error.issues[0].message
+ });
+ }
});
}
}