fix: unable to update integration when encryption key changed (#2133)
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
"@trpc/server": "next",
|
"@trpc/server": "next",
|
||||||
"lodash.clonedeep": "^4.5.0",
|
"lodash.clonedeep": "^4.5.0",
|
||||||
"next": "15.1.6",
|
"next": "15.1.6",
|
||||||
|
"pretty-print-error": "^1.1.2",
|
||||||
"react": "19.0.0",
|
"react": "19.0.0",
|
||||||
"react-dom": "19.0.0",
|
"react-dom": "19.0.0",
|
||||||
"superjson": "2.2.2",
|
"superjson": "2.2.2",
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
import { formatError } from "pretty-print-error";
|
||||||
|
|
||||||
import { decryptSecret } from "@homarr/common/server";
|
import { decryptSecret } from "@homarr/common/server";
|
||||||
import type { Integration } from "@homarr/db/schema";
|
import type { Integration } from "@homarr/db/schema";
|
||||||
import type { IntegrationKind, IntegrationSecretKind } from "@homarr/definitions";
|
import type { IntegrationKind, IntegrationSecretKind } from "@homarr/definitions";
|
||||||
import { getAllSecretKindOptions } from "@homarr/definitions";
|
import { getAllSecretKindOptions } from "@homarr/definitions";
|
||||||
import { integrationCreator, IntegrationTestConnectionError } from "@homarr/integrations";
|
import { integrationCreator, IntegrationTestConnectionError } from "@homarr/integrations";
|
||||||
|
import { logger } from "@homarr/log";
|
||||||
|
|
||||||
type FormIntegration = Integration & {
|
type FormIntegration = Integration & {
|
||||||
secrets: {
|
secrets: {
|
||||||
@@ -28,11 +31,22 @@ export const testConnectionAsync = async (
|
|||||||
source: "form" as const,
|
source: "form" as const,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const decryptedDbSecrets = dbSecrets.map((secret) => ({
|
const decryptedDbSecrets = dbSecrets
|
||||||
...secret,
|
.map((secret) => {
|
||||||
value: decryptSecret(secret.value),
|
try {
|
||||||
source: "db" as const,
|
return {
|
||||||
}));
|
...secret,
|
||||||
|
value: decryptSecret(secret.value),
|
||||||
|
source: "db" as const,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn(
|
||||||
|
`Failed to decrypt secret from database integration="${integration.name}" secretKind="${secret.kind}"\n${formatError(error)}`,
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter((secret) => secret !== null);
|
||||||
|
|
||||||
const sourcedSecrets = [...formSecrets, ...decryptedDbSecrets];
|
const sourcedSecrets = [...formSecrets, ...decryptedDbSecrets];
|
||||||
const secretKinds = getSecretKindOption(integration.kind, sourcedSecrets);
|
const secretKinds = getSecretKindOption(integration.kind, sourcedSecrets);
|
||||||
|
|||||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -578,6 +578,9 @@ importers:
|
|||||||
next:
|
next:
|
||||||
specifier: 15.1.6
|
specifier: 15.1.6
|
||||||
version: 15.1.6(@babel/core@7.26.0)(@playwright/test@1.49.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.83.4)
|
version: 15.1.6(@babel/core@7.26.0)(@playwright/test@1.49.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.83.4)
|
||||||
|
pretty-print-error:
|
||||||
|
specifier: ^1.1.2
|
||||||
|
version: 1.1.2(patch_hash=4arrfgbz7em6s4gqywse7esg4u)
|
||||||
react:
|
react:
|
||||||
specifier: 19.0.0
|
specifier: 19.0.0
|
||||||
version: 19.0.0
|
version: 19.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user