Skip to content

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

feat: change copy

adilson1e1245ffc052
diff --git a/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-fns.ts
index 321d744809..af1ea61a69 100644
--- a/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-fns.ts
@@ -10,7 +10,7 @@ import {
} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";
import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
-import { OPENAI_API_BASE_URL } from "@app/services/app-connection/openai";
+import { OPENAI_API_BASE_URL, verifyOpenAIAdminApiKey } from "@app/services/app-connection/openai";
import {
TOpenAIAdminApiKeyCreateResponse,
@@ -51,6 +51,11 @@ export const openAIAdminApiKeyRotationFactory: TRotationFactory<
const provisioningApiKey = connection.credentials.apiKey;
+ const provisioningHeaders = {
+ Authorization: `Bearer ${provisioningApiKey}`,
+ "Content-Type": "application/json"
+ };
+
/**
* Creates a new admin API key via the OpenAI Admin API.
*/
@@ -64,12 +69,7 @@ export const openAIAdminApiKeyRotationFactory: TRotationFactory<
const { data } = await request.post<TOpenAIAdminApiKeyCreateResponse>(
`${OPENAI_API_BASE_URL}/organization/admin_api_keys`,
{ name: keyName },
- {
- headers: {
- Authorization: `Bearer ${provisioningApiKey}`,
- "Content-Type": "application/json"
- }
- }
+ { headers: provisioningHeaders }
);
if (!data.value || !data.id) {
@@ -93,10 +93,7 @@ export const openAIAdminApiKeyRotationFactory: TRotationFactory<
const $deleteApiKey = async (keyId: string) => {
try {
await request.delete(`${OPENAI_API_BASE_URL}/organization/admin_api_keys/${keyId}`, {
- headers: {
- Authorization: `Bearer ${provisioningApiKey}`,
- "Content-Type": "application/json"
- }
+ headers: provisioningHeaders
});
} catch (error: unknown) {
// If key doesn't exist (404), consider it already deleted
@@ -167,12 +164,7 @@ export const openAIAdminApiKeyRotationFactory: TRotationFactory<
> = async ({ apiKey }) => {
try {
// A valid admin key can list admin keys; a 200 confirms the rotated key is still active.
- await request.get(`${OPENAI_API_BASE_URL}/organization/admin_api_keys?limit=1`, {
- headers: {
- Authorization: `Bearer ${apiKey}`,
- "Content-Type": "application/json"
- }
- });
+ await verifyOpenAIAdminApiKey(apiKey);
} catch (error: unknown) {
throw new BadRequestError({
message: `OpenAI admin API key verification failed: ${createErrorMessage(error)}`
diff --git a/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-schemas.ts
index 55569d1d6a..90a6fc957a 100644
--- a/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-schemas.ts
+++ b/backend/src/ee/services/secret-rotation-v2/openai-admin-api-key/openai-admin-api-key-rotation-schemas.ts
@@ -19,7 +19,7 @@ export const OpenAIAdminApiKeyRotationGeneratedCredentialsSchema = z
.min(1)
.max(2);
-/** Max length for OpenAI admin API key name. */
+/** Max length for the user-provided base name; the created key name also gets a `-<timestamp>` suffix. */
export const OPENAI_ADMIN_API_KEY_NAME_MAX_LENGTH = 100;
const OpenAIAdminApiKeyRotationParametersSchema = z.object({
diff --git a/backend/src/services/app-connection/openai/openai-connection-fns.ts b/backend/src/services/app-connection/openai/openai-connection-fns.ts
index ec3bc7c008..ec207d4cb4 100644
--- a/backend/src/services/app-connection/openai/openai-connection-fns.ts
+++ b/backend/src/services/app-connection/openai/openai-connection-fns.ts
@@ -15,18 +15,25 @@ export const getOpenAIConnectionListItem = () => {
};
};
+/**
+ * Verifies an OpenAI admin API key by listing admin API keys (requires a valid admin key).
+ * Resolves on a 200 and throws the underlying request error otherwise, so callers can wrap
+ * it in their own domain-specific error.
+ */
+export const verifyOpenAIAdminApiKey = async (apiKey: string) =>
+ request.get(`${OPENAI_API_BASE_URL}/organization/admin_api_keys?limit=1`, {
+ headers: {
+ Authorization: `Bearer ${apiKey}`,
+ "Content-Type": "application/json"
+ },
+ validateStatus: (status) => status === 200
+ });
+
export const validateOpenAIConnectionCredentials = async (config: TOpenAIConnectionConfig) => {
const { apiKey } = config.credentials;
try {
- // Validate by listing admin API keys (requires a valid admin key)
- await request.get(`${OPENAI_API_BASE_URL}/organization/admin_api_keys?limit=1`, {
- headers: {
- Authorization: `Bearer ${apiKey}`,
- "Content-Type": "application/json"
- },
- validateStatus: (status) => status === 200
- });
+ await verifyOpenAIAdminApiKey(apiKey);
} catch (error: unknown) {
throw new UnauthorizedError({
message: "Unable to validate connection: invalid API key or insufficient permissions"
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenAIAdminApiKeyRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenAIAdminApiKeyRotationParametersFields.tsx
index 64ec024e2a..0a7c93d4dd 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenAIAdminApiKeyRotationParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/OpenAIAdminApiKeyRotationParametersFields.tsx
@@ -1,12 +1,10 @@
import { Controller, useFormContext } from "react-hook-form";
import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { OPENAI_ADMIN_API_KEY_NAME_MAX_LENGTH } from "@app/components/secret-rotations-v2/forms/schemas/openai-admin-api-key-rotation-schema";
import { FormControl, Input } from "@app/components/v2";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
-/** Max length for OpenAI admin API key name (matches backend schema). */
-const OPENAI_ADMIN_API_KEY_NAME_MAX_LENGTH = 100;
-
export const OpenAIAdminApiKeyRotationParametersFields = () => {
const { control } = useFormContext<
TSecretRotationV2Form & {
@@ -23,12 +21,12 @@ export const OpenAIAdminApiKeyRotationParametersFields = () => {
isError={Boolean(error)}
errorText={error?.message}
label="Key Name"
- tooltipText="A descriptive name for the generated admin API key"
+ tooltipText="A descriptive name for the generated admin API key. This will be saved in the OpenAI dashboard for reference with a suffix of the timestamp of the key creation."
>
<Input
value={value}
onChange={onChange}
- placeholder="My Rotated Admin API Key"
+ placeholder="OpenAI Admin API Key Name"
maxLength={OPENAI_ADMIN_API_KEY_NAME_MAX_LENGTH}
/>
</FormControl>
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/openai-admin-api-key-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/openai-admin-api-key-rotation-schema.ts
index 782de9202a..a90c70919d 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/openai-admin-api-key-rotation-schema.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/openai-admin-api-key-rotation-schema.ts
@@ -3,8 +3,8 @@ import { z } from "zod";
import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
-/** Max length for OpenAI admin API key name (matches backend schema). */
-const OPENAI_ADMIN_API_KEY_NAME_MAX_LENGTH = 100;
+/** Max length for the user-provided base name (matches backend schema). */
+export const OPENAI_ADMIN_API_KEY_NAME_MAX_LENGTH = 100;
export const OpenAIAdminApiKeyRotationSchema = z
.object({