diff --git a/backend/src/services/app-connection/humanitec/humanitec-connection-fns.ts b/backend/src/services/app-connection/humanitec/humanitec-connection-fns.ts index 5775e5b24..55094629b 100644 --- a/backend/src/services/app-connection/humanitec/humanitec-connection-fns.ts +++ b/backend/src/services/app-connection/humanitec/humanitec-connection-fns.ts @@ -84,21 +84,17 @@ export const listOrganizations = async (appConnection: THumanitecConnection): Pr } ); - if (!appsResponse.data) { - throw new InternalServerError({ - message: "Failed to get apps for organization: Response was empty" + if (appsResponse.data) { + const apps = appsResponse.data; + orgsWithApps.push({ + ...org, + apps: apps.map((app) => ({ + name: app.name, + id: app.id, + envs: app.envs + })) }); } - - const apps = appsResponse.data; - orgsWithApps.push({ - ...org, - apps: apps.map((app) => ({ - name: app.name, - id: app.id, - envs: app.envs - })) - }); } catch (error) { logger.error(error, `Failed to get apps for organization ${org.name}`); } diff --git a/backend/src/services/secret-sync/humanitec/humanitec-sync-fns.ts b/backend/src/services/secret-sync/humanitec/humanitec-sync-fns.ts index c9253377a..280e1ce7d 100644 --- a/backend/src/services/secret-sync/humanitec/humanitec-sync-fns.ts +++ b/backend/src/services/secret-sync/humanitec/humanitec-sync-fns.ts @@ -15,26 +15,20 @@ const getHumanitecSecrets = async (secretSync: THumanitecSyncWithCredentials) => } } = secretSync; - try { - let url = `${IntegrationUrls.HUMANITEC_API_URL}/orgs/${destinationConfig.org}/apps/${destinationConfig.app}`; - if (destinationConfig.scope === HumanitecSyncScope.Environment) { - url += `/envs/${destinationConfig.env}`; - } - url += "/values"; - - const { data } = await request.get(url, { - headers: { - Authorization: `Bearer ${apiToken}`, - "Accept-Encoding": "application/json" - } - }); - - return data; - } catch (error) { - throw new SecretSyncError({ - error - }); + let url = `${IntegrationUrls.HUMANITEC_API_URL}/orgs/${destinationConfig.org}/apps/${destinationConfig.app}`; + if (destinationConfig.scope === HumanitecSyncScope.Environment) { + url += `/envs/${destinationConfig.env}`; } + url += "/values"; + + const { data } = await request.get(url, { + headers: { + Authorization: `Bearer ${apiToken}`, + "Accept-Encoding": "application/json" + } + }); + + return data; }; const deleteSecret = async (secretSync: THumanitecSyncWithCredentials, encryptedSecret: HumanitecSecret) => { diff --git a/docs/api-reference/endpoints/app-connections/humanitec/available.mdx b/docs/api-reference/endpoints/app-connections/humanitec/available.mdx new file mode 100644 index 000000000..eb95b2e54 --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/available.mdx @@ -0,0 +1,4 @@ +--- +title: "Available" +openapi: "GET /api/v1/app-connections/humanitec/available" +--- diff --git a/docs/api-reference/endpoints/app-connections/humanitec/create.mdx b/docs/api-reference/endpoints/app-connections/humanitec/create.mdx new file mode 100644 index 000000000..328af9cd9 --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/create.mdx @@ -0,0 +1,10 @@ +--- +title: "Create" +openapi: "POST /api/v1/app-connections/humanitec" +--- + + + Humanitec Connections must be created through the Infisical UI. + Check out the configuration docs for [Humanitec Connections](/integrations/app-connections/humanitec) for a step-by-step + guide. + \ No newline at end of file diff --git a/docs/api-reference/endpoints/app-connections/humanitec/delete.mdx b/docs/api-reference/endpoints/app-connections/humanitec/delete.mdx new file mode 100644 index 000000000..d8786e08a --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/delete.mdx @@ -0,0 +1,4 @@ +--- +title: "Delete" +openapi: "DELETE /api/v1/app-connections/humanitec/{connectionId}" +--- diff --git a/docs/api-reference/endpoints/app-connections/humanitec/get-by-id.mdx b/docs/api-reference/endpoints/app-connections/humanitec/get-by-id.mdx new file mode 100644 index 000000000..22473a7a1 --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/get-by-id.mdx @@ -0,0 +1,4 @@ +--- +title: "Get by ID" +openapi: "GET /api/v1/app-connections/humanitec/{connectionId}" +--- diff --git a/docs/api-reference/endpoints/app-connections/humanitec/get-by-name.mdx b/docs/api-reference/endpoints/app-connections/humanitec/get-by-name.mdx new file mode 100644 index 000000000..fd848ae4f --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/get-by-name.mdx @@ -0,0 +1,4 @@ +--- +title: "Get by Name" +openapi: "GET /api/v1/app-connections/humanitec/connection-name/{connectionName}" +--- diff --git a/docs/api-reference/endpoints/app-connections/humanitec/list.mdx b/docs/api-reference/endpoints/app-connections/humanitec/list.mdx new file mode 100644 index 000000000..07f30f674 --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/list.mdx @@ -0,0 +1,4 @@ +--- +title: "List" +openapi: "GET /api/v1/app-connections/humanitec" +--- diff --git a/docs/api-reference/endpoints/app-connections/humanitec/update.mdx b/docs/api-reference/endpoints/app-connections/humanitec/update.mdx new file mode 100644 index 000000000..023264bb3 --- /dev/null +++ b/docs/api-reference/endpoints/app-connections/humanitec/update.mdx @@ -0,0 +1,10 @@ +--- +title: "Update" +openapi: "PATCH /api/v1/app-connections/humanitec/{connectionId}" +--- + + + Humanitec Connections must be updated through the Infisical UI. + Check out the configuration docs for [Humanitec Connections](/integrations/app-connections/humanitec) for a step-by-step + guide. + diff --git a/docs/images/secret-syncs/humanitec/humanitec-options.png b/docs/images/secret-syncs/humanitec/humanitec-options.png index f9d6fb34f..bc907bbfc 100644 Binary files a/docs/images/secret-syncs/humanitec/humanitec-options.png and b/docs/images/secret-syncs/humanitec/humanitec-options.png differ diff --git a/docs/integrations/app-connections/humanitec.mdx b/docs/integrations/app-connections/humanitec.mdx index 6f6624151..14fdd9bfe 100644 --- a/docs/integrations/app-connections/humanitec.mdx +++ b/docs/integrations/app-connections/humanitec.mdx @@ -9,7 +9,7 @@ Infisical supports connecting to Humanitec using a service user. - Navigate to the Humanitec Service Users tab. + Navigate to the Humanitec **Service Users** tab. ![Humanitec Service Users Tab](/images/app-connections/humanitec/humanitec-service-users.png) @@ -21,25 +21,26 @@ Infisical supports connecting to Humanitec using a service user. ![Humanitec Add API Token](/images/app-connections/humanitec/humanitec-add-api-token.png) - Create the API token for the service user. Depending on the expiry date set, the token will expire and this integration will stop working. + Create the API token for the service user. + If you configure an expiry date for your API token you will need to manually rotate to a new token prior to expiration to avoid integration downtime. This token's permission will be limited to the **Service User** role. ![Humanitec Create API Token](/images/app-connections/humanitec/humanitec-create-api-token.png) - A modal with the API token will be displayed. Copy the token and save it in a secure location. + A modal with the API token will be displayed. Save the token in a secure location for later use in the following steps. ![Humanitec Copy API Token](/images/app-connections/humanitec/humanitec-copy-api-token.png) - After following the previous steps the Service User has been successfully created. And now should be visible on the Service Users tab. + After following the previous steps the Service User has been successfully created, and now should be visible on the Service Users tab. ![Humanitec Service User Created](/images/app-connections/humanitec/humanitec-service-account-filled.png) - Move to Appplication Tab and add the Service User to the Application you want to sync with Infisical. + Move to the **Applications** tab and add the Service User to the Application you want to sync with Infisical. Clicking on the App Title will open the App details page. ![Humanitec Applications Tab](/images/app-connections/humanitec/humanitec-applications-tab.png) - Move to the People tab and add a new member to this Application. The recently created User Service should be visible on the dropdown shown. + Move to the **People** tab and add a new member to this Application. The recently created User Service should be visible on the dropdown shown. Make sure to assign at least Developer role as Write permissions are required. ![Humanitec Add User to Application](/images/app-connections/humanitec/humanitec-add-user.png) ![Humanitec Add User Options](/images/app-connections/humanitec/humanitec-add-user-options.png) diff --git a/docs/integrations/secret-syncs/humanitec.mdx b/docs/integrations/secret-syncs/humanitec.mdx index b4897a4e4..0edc2098e 100644 --- a/docs/integrations/secret-syncs/humanitec.mdx +++ b/docs/integrations/secret-syncs/humanitec.mdx @@ -129,8 +129,8 @@ description: "Learn how to configure a Humanitec Sync for Infisical." }, "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", "connection": { - "app": "github", - "name": "my-github-connection", + "app": "humanitec", + "name": "my-humanitec-connection", "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }, "environment": { diff --git a/docs/mint.json b/docs/mint.json index 29422e490..8f4c22bd1 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -900,6 +900,18 @@ "api-reference/endpoints/app-connections/github/update", "api-reference/endpoints/app-connections/github/delete" ] + }, + { + "group": "Humanitec", + "pages": [ + "api-reference/endpoints/app-connections/humanitec/list", + "api-reference/endpoints/app-connections/humanitec/available", + "api-reference/endpoints/app-connections/humanitec/get-by-id", + "api-reference/endpoints/app-connections/humanitec/get-by-name", + "api-reference/endpoints/app-connections/humanitec/create", + "api-reference/endpoints/app-connections/humanitec/update", + "api-reference/endpoints/app-connections/humanitec/delete" + ] } ] }, diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HumanitecSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HumanitecSyncFields.tsx index 438717785..f6db55693 100644 --- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HumanitecSyncFields.tsx +++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HumanitecSyncFields.tsx @@ -5,6 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField"; import { FilterableSelect, FormControl, Select, SelectItem, Tooltip } from "@app/components/v2"; +import { HUMANITEC_SYNC_SCOPES } from "@app/helpers/secretSyncs"; import { THumanitecConnectionApp, THumanitecConnectionEnvironment, @@ -41,6 +42,7 @@ export const HumanitecSyncFields = () => { onChange={() => { setValue("destinationConfig.org", ""); setValue("destinationConfig.app", ""); + setValue("destinationConfig.env", ""); }} /> { control={control} defaultValue={HumanitecSyncScope.Application} render={({ field: { value, onChange }, fieldState: { error } }) => ( - + +

+ Specify how Infisical should manage secrets from Humanitec. The following options + are available: +

+
    + {Object.values(HUMANITEC_SYNC_SCOPES).map(({ name, description }) => { + return ( +
  • +

    + {name}: {description} +

    +
  • + ); + })} +
+ + } + >