diff --git a/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-fns.ts b/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-fns.ts index fa2563078..a28217320 100644 --- a/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-fns.ts +++ b/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-fns.ts @@ -17,7 +17,7 @@ import { AppConnection } from "../app-connection-enums"; import { AzureClientSecretsConnectionMethod } from "./azure-client-secrets-connection-enums"; import { ExchangeCodeAzureResponse, - TAzureClientSecretsConnectionAccessTokenCredentials, + TAzureClientSecretsConnectionClientSecretCredentials, TAzureClientSecretsConnectionConfig, TAzureClientSecretsConnectionCredentials } from "./azure-client-secrets-connection-types"; @@ -101,7 +101,7 @@ export const getAzureConnectionAccessToken = async ( orgId: appConnection.orgId, kmsService, encryptedCredentials: appConnection.encryptedCredentials - })) as TAzureClientSecretsConnectionAccessTokenCredentials; + })) as TAzureClientSecretsConnectionClientSecretCredentials; const { accessToken, expiresAt, clientId, clientSecret, tenantId } = accessTokenCredentials; if (accessToken && expiresAt && expiresAt > currentTime + 300000) { return accessToken; diff --git a/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-schemas.ts b/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-schemas.ts index 4d2c486d7..41c9a1d36 100644 --- a/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-schemas.ts +++ b/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-schemas.ts @@ -26,16 +26,18 @@ export const AzureClientSecretsConnectionOAuthOutputCredentialsSchema = z.object expiresAt: z.number() }); -export const AzureClientSecretsConnectionAccessTokenInputCredentialsSchema = z.object({ +export const AzureClientSecretsConnectionClientSecretInputCredentialsSchema = z.object({ clientId: z .string() .trim() .min(1, "Client ID required") + .max(50, "Client ID must be at most 50 characters long") .describe(AppConnections.CREDENTIALS.AZURE_CLIENT_SECRETS.clientId), clientSecret: z .string() .trim() .min(1, "Client Secret required") + .max(50, "Client Secret must be at most 50 characters long") .describe(AppConnections.CREDENTIALS.AZURE_CLIENT_SECRETS.clientSecret), tenantId: z .string() @@ -44,7 +46,7 @@ export const AzureClientSecretsConnectionAccessTokenInputCredentialsSchema = z.o .describe(AppConnections.CREDENTIALS.AZURE_CLIENT_SECRETS.tenantId) }); -export const AzureClientSecretsConnectionAccessTokenOutputCredentialsSchema = z.object({ +export const AzureClientSecretsConnectionClientSecretOutputCredentialsSchema = z.object({ clientId: z.string(), clientSecret: z.string(), tenantId: z.string(), @@ -65,7 +67,7 @@ export const ValidateAzureClientSecretsConnectionCredentialsSchema = z.discrimin method: z .literal(AzureClientSecretsConnectionMethod.ClientSecret) .describe(AppConnections.CREATE(AppConnection.AzureClientSecrets).method), - credentials: AzureClientSecretsConnectionAccessTokenInputCredentialsSchema.describe( + credentials: AzureClientSecretsConnectionClientSecretInputCredentialsSchema.describe( AppConnections.CREATE(AppConnection.AzureClientSecrets).credentials ) }) @@ -80,7 +82,7 @@ export const UpdateAzureClientSecretsConnectionSchema = z credentials: z .union([ AzureClientSecretsConnectionOAuthInputCredentialsSchema, - AzureClientSecretsConnectionAccessTokenInputCredentialsSchema + AzureClientSecretsConnectionClientSecretInputCredentialsSchema ]) .optional() .describe(AppConnections.UPDATE(AppConnection.AzureClientSecrets).credentials) @@ -100,7 +102,7 @@ export const AzureClientSecretsConnectionSchema = z.intersection( }), z.object({ method: z.literal(AzureClientSecretsConnectionMethod.ClientSecret), - credentials: AzureClientSecretsConnectionAccessTokenOutputCredentialsSchema + credentials: AzureClientSecretsConnectionClientSecretOutputCredentialsSchema }) ]) ); @@ -114,7 +116,7 @@ export const SanitizedAzureClientSecretsConnectionSchema = z.discriminatedUnion( }), BaseAzureClientSecretsConnectionSchema.extend({ method: z.literal(AzureClientSecretsConnectionMethod.ClientSecret), - credentials: AzureClientSecretsConnectionAccessTokenOutputCredentialsSchema.pick({ + credentials: AzureClientSecretsConnectionClientSecretOutputCredentialsSchema.pick({ clientId: true, tenantId: true }) diff --git a/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-types.ts b/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-types.ts index f6aa932d7..1ad5a3411 100644 --- a/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-types.ts +++ b/backend/src/services/app-connection/azure-client-secrets/azure-client-secrets-connection-types.ts @@ -4,7 +4,7 @@ import { DiscriminativePick } from "@app/lib/types"; import { AppConnection } from "../app-connection-enums"; import { - AzureClientSecretsConnectionAccessTokenOutputCredentialsSchema, + AzureClientSecretsConnectionClientSecretOutputCredentialsSchema, AzureClientSecretsConnectionOAuthOutputCredentialsSchema, AzureClientSecretsConnectionSchema, CreateAzureClientSecretsConnectionSchema, @@ -31,8 +31,8 @@ export type TAzureClientSecretsConnectionCredentials = z.infer< typeof AzureClientSecretsConnectionOAuthOutputCredentialsSchema >; -export type TAzureClientSecretsConnectionAccessTokenCredentials = z.infer< - typeof AzureClientSecretsConnectionAccessTokenOutputCredentialsSchema +export type TAzureClientSecretsConnectionClientSecretCredentials = z.infer< + typeof AzureClientSecretsConnectionClientSecretOutputCredentialsSchema >; export interface ExchangeCodeAzureResponse { diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureClientSecretsConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureClientSecretsConnectionForm.tsx index 927189e6d..6aa6ee63c 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureClientSecretsConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureClientSecretsConnectionForm.tsx @@ -205,7 +205,7 @@ export const AzureClientSecretsConnectionForm = ({ appConnection, onSubmit }: Pr > { field.onChange(e.target.value); setValue("credentials.tenantId", e.target.value); @@ -223,12 +223,11 @@ export const AzureClientSecretsConnectionForm = ({ appConnection, onSubmit }: Pr control={control} render={({ field, fieldState: { error } }) => ( - + )} /> @@ -237,7 +236,6 @@ export const AzureClientSecretsConnectionForm = ({ appConnection, onSubmit }: Pr control={control} render={({ field, fieldState: { error } }) => (