From 7473e3e21e39a88d842e5fe5223540b6cd7c638c Mon Sep 17 00:00:00 2001 From: carlosmonastyrski Date: Thu, 19 Jun 2025 09:28:43 -0300 Subject: [PATCH] Add Heroku PR suggestions --- .../app-connection/heroku/heroku-connection-fns.ts | 2 +- .../heroku/heroku-connection-schemas.ts | 12 ++++++------ .../services/secret-sync/heroku/heroku-sync-fns.ts | 2 +- docs/integrations/app-connections/heroku.mdx | 6 +++--- .../AppConnectionForm/HerokuAppConnectionForm.tsx | 11 +++++++++-- .../HerokuSyncDestinationSection.tsx | 4 ++-- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/backend/src/services/app-connection/heroku/heroku-connection-fns.ts b/backend/src/services/app-connection/heroku/heroku-connection-fns.ts index dfb6f1e4b..6d04c4780 100644 --- a/backend/src/services/app-connection/heroku/heroku-connection-fns.ts +++ b/backend/src/services/app-connection/heroku/heroku-connection-fns.ts @@ -86,7 +86,7 @@ export const refreshHerokuToken = async ( credentials: { refreshToken, authToken: data.access_token, - expiresAt: new Date(Date.now() + data.expires_in - 60) + expiresAt: new Date(Date.now() + data.expires_in * 1000 - 60000) }, orgId, kmsService diff --git a/backend/src/services/app-connection/heroku/heroku-connection-schemas.ts b/backend/src/services/app-connection/heroku/heroku-connection-schemas.ts index 57f992eea..99d637dd5 100644 --- a/backend/src/services/app-connection/heroku/heroku-connection-schemas.ts +++ b/backend/src/services/app-connection/heroku/heroku-connection-schemas.ts @@ -10,8 +10,8 @@ import { import { HerokuConnectionMethod } from "./heroku-connection-enums"; -export const HerokuConnectionAccessTokenCredentialsSchema = z.object({ - authToken: z.string().trim().min(1, "Auth Token required") +export const HerokuConnectionAuthTokenCredentialsSchema = z.object({ + authToken: z.string().trim().min(1, "Auth Token required").startsWith("HRKU-", "Token must start with 'HRKU-") }); export const HerokuConnectionOAuthCredentialsSchema = z.object({ @@ -38,7 +38,7 @@ export const HerokuConnectionSchema = z.intersection( z.discriminatedUnion("method", [ z.object({ method: z.literal(HerokuConnectionMethod.AuthToken), - credentials: HerokuConnectionAccessTokenCredentialsSchema + credentials: HerokuConnectionAuthTokenCredentialsSchema }), z.object({ method: z.literal(HerokuConnectionMethod.OAuth), @@ -50,7 +50,7 @@ export const HerokuConnectionSchema = z.intersection( export const SanitizedHerokuConnectionSchema = z.discriminatedUnion("method", [ BaseHerokuConnectionSchema.extend({ method: z.literal(HerokuConnectionMethod.AuthToken), - credentials: HerokuConnectionAccessTokenCredentialsSchema.pick({}) + credentials: HerokuConnectionAuthTokenCredentialsSchema.pick({}) }), BaseHerokuConnectionSchema.extend({ method: z.literal(HerokuConnectionMethod.OAuth), @@ -61,7 +61,7 @@ export const SanitizedHerokuConnectionSchema = z.discriminatedUnion("method", [ export const ValidateHerokuConnectionCredentialsSchema = z.discriminatedUnion("method", [ z.object({ method: z.literal(HerokuConnectionMethod.AuthToken).describe(AppConnections.CREATE(AppConnection.Heroku).method), - credentials: HerokuConnectionAccessTokenCredentialsSchema.describe( + credentials: HerokuConnectionAuthTokenCredentialsSchema.describe( AppConnections.CREATE(AppConnection.Heroku).credentials ) }), @@ -85,7 +85,7 @@ export const UpdateHerokuConnectionSchema = z .object({ credentials: z .union([ - HerokuConnectionAccessTokenCredentialsSchema, + HerokuConnectionAuthTokenCredentialsSchema, HerokuConnectionOAuthOutputCredentialsSchema, HerokuConnectionRefreshTokenCredentialsSchema, HerokuConnectionOAuthCredentialsSchema diff --git a/backend/src/services/secret-sync/heroku/heroku-sync-fns.ts b/backend/src/services/secret-sync/heroku/heroku-sync-fns.ts index a19578f50..402b0bb2c 100644 --- a/backend/src/services/secret-sync/heroku/heroku-sync-fns.ts +++ b/backend/src/services/secret-sync/heroku/heroku-sync-fns.ts @@ -55,7 +55,7 @@ const getHerokuConfigVars = async ({ authToken, app }: THerokuListVariables): Pr }; const updateHerokuConfigVars = async ({ authToken, app, configVars }: THerokuUpdateVariables) => { - return request.patch(`${IntegrationUrls.HEROKU_API_URL}/apps/${app}/config-vars`, configVars, { + return request.patch(`${IntegrationUrls.HEROKU_API_URL}/apps/${encodeURIComponent(app)}/config-vars`, configVars, { headers: { Authorization: `Bearer ${authToken}`, Accept: "application/vnd.heroku+json; version=3", diff --git a/docs/integrations/app-connections/heroku.mdx b/docs/integrations/app-connections/heroku.mdx index 0c27a8dc5..2a5620d5f 100644 --- a/docs/integrations/app-connections/heroku.mdx +++ b/docs/integrations/app-connections/heroku.mdx @@ -39,8 +39,8 @@ Infisical supports two methods for connecting to Heroku: **OAuth** and **Auth To Back in your Infisical instance, add two new environment variables for the credentials of your Heroku API client: - - `INF_APP_CONNECTION_HEROKU_CLIENT_ID`: The **Client ID** of your Heroku API client. - - `INF_APP_CONNECTION_HEROKU_CLIENT_SECRET`: The **Client Secret** of your Heroku API client. + - `CLIENT_ID_HEROKU`: The **Client ID** of your Heroku API client. + - `CLIENT_SECRET_HEROKU`: The **Client Secret** of your Heroku API client. Once added, restart your Infisical instance and use the Heroku App Connection. @@ -84,7 +84,7 @@ Infisical supports two methods for connecting to Heroku: **OAuth** and **Auth To Log in to your Heroku account and navigate to Account Settings. - Under the **Authorizations** section, reveal and copy your Authorization token. If you don't have one, click **Create Authorization** to create a new token. + Under the **Authorizations** section on the **Applications** tab, reveal and copy your Authorization token. If you don't have one, click **Create Authorization** to create a new token. Keep your Authorization token secure and do not share it. Anyone with access to this token can manage your Heroku applications. diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HerokuAppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HerokuAppConnectionForm.tsx index a7ab5e70c..085ef49c5 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HerokuAppConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HerokuAppConnectionForm.tsx @@ -81,6 +81,7 @@ export const HerokuConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr handleSubmit, control, watch, + setValue, formState: { isSubmitting, isDirty } } = form; @@ -175,7 +176,13 @@ export const HerokuConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr