From bfcbffbdc6499ac5f10bfbf2f5db141eef955049 Mon Sep 17 00:00:00 2001 From: Meier Lukas Date: Wed, 10 Sep 2025 21:17:36 +0200 Subject: [PATCH] feat(integration): add github app authentication (#3968) --- .../secrets/integration-secret-icons.ts | 5 ++ .../secrets/integration-secret-inputs.tsx | 36 ++++++++- .../integration-test-connection.ts | 27 +++---- .../integration-test-connection.spec.ts | 73 +++++++++++++++++++ packages/common/package.json | 1 + .../common/src/errors/http/handlers/index.ts | 1 + .../handlers/octokit-http-error-handler.ts | 24 ++++++ packages/definitions/src/integration.ts | 27 ++++--- packages/integrations/package.json | 1 + .../src/base/errors/http/index.ts | 2 + .../github-container-registry-integration.ts | 58 ++++++++++----- .../src/github/github-integration.ts | 64 +++++++++++----- packages/translation/src/lang/en.json | 12 +++ pnpm-lock.yaml | 28 ++++--- 14 files changed, 282 insertions(+), 77 deletions(-) create mode 100644 packages/common/src/errors/http/handlers/octokit-http-error-handler.ts diff --git a/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-icons.ts b/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-icons.ts index 008d8b34f..0faccc11c 100644 --- a/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-icons.ts +++ b/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-icons.ts @@ -1,9 +1,11 @@ import { + IconCode, IconGrid3x3, IconKey, IconMessage, IconPassword, IconPasswordUser, + IconPlug, IconServer, IconUser, } from "@tabler/icons-react"; @@ -21,4 +23,7 @@ export const integrationSecretIcons = { topic: IconMessage, opnsenseApiKey: IconKey, opnsenseApiSecret: IconPassword, + githubAppId: IconCode, + githubInstallationId: IconPlug, + privateKey: IconKey, } satisfies Record; diff --git a/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-inputs.tsx b/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-inputs.tsx index 45f5b3156..78e2d78c1 100644 --- a/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-inputs.tsx +++ b/apps/nextjs/src/app/[locale]/manage/integrations/_components/secrets/integration-secret-inputs.tsx @@ -1,7 +1,7 @@ "use client"; import type { ChangeEventHandler, FocusEventHandler } from "react"; -import { PasswordInput, TextInput } from "@mantine/core"; +import { PasswordInput, Textarea, TextInput } from "@mantine/core"; import { integrationSecretKindObject } from "@homarr/definitions"; import type { IntegrationSecretKind } from "@homarr/definitions"; @@ -14,9 +14,9 @@ interface IntegrationSecretInputProps { label?: string; kind: IntegrationSecretKind; value?: string; - onChange: ChangeEventHandler; - onFocus?: FocusEventHandler; - onBlur?: FocusEventHandler; + onChange: ChangeEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; error?: string; } @@ -31,6 +31,19 @@ export const IntegrationSecretInput = (props: IntegrationSecretInputProps) => { const PublicSecretInput = ({ kind, ...props }: IntegrationSecretInputProps) => { const t = useI18n(); const Icon = integrationSecretIcons[kind]; + const { multiline } = integrationSecretKindObject[kind]; + if (multiline) { + return ( +