feat(secret-syncs): azure app config & key vault support

This commit is contained in:
Daniel Hougaard
2025-02-08 04:27:17 +04:00
parent 4e41e84491
commit 5cd6a66989
70 changed files with 2065 additions and 204 deletions
@@ -27,7 +27,9 @@ import { ValidateGitHubConnectionCredentialsSchema } from "@app/services/app-con
import { githubConnectionService } from "@app/services/app-connection/github/github-connection-service";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "../kms/kms-types";
import { TAppConnectionDALFactory } from "./app-connection-dal";
import { AzureResources } from "./azure";
import { ValidateGcpConnectionCredentialsSchema } from "./gcp";
import { gcpConnectionService } from "./gcp/gcp-connection-service";
@@ -42,7 +44,8 @@ export type TAppConnectionServiceFactory = ReturnType<typeof appConnectionServic
const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAppConnectionCredentials> = {
[AppConnection.AWS]: ValidateAwsConnectionCredentialsSchema,
[AppConnection.GitHub]: ValidateGitHubConnectionCredentialsSchema,
[AppConnection.GCP]: ValidateGcpConnectionCredentialsSchema
[AppConnection.GCP]: ValidateGcpConnectionCredentialsSchema,
[AppConnection.Azure]: ValidateGcpConnectionCredentialsSchema
};
export const appConnectionServiceFactory = ({
@@ -347,7 +350,27 @@ export const appConnectionServiceFactory = ({
)
);
return availableConnections as Omit<TAppConnection, "credentials">[];
const { decryptor } = await kmsService.createCipherPairWithDataKey({
type: KmsDataKey.Organization,
orgId: actor.orgId
});
const decryptedConnections = availableConnections.map((connection) => {
const decryptedPlainTextBlob = decryptor({
cipherTextBlob: connection.encryptedCredentials
});
const credentials = JSON.parse(decryptedPlainTextBlob.toString()) as TAppConnection["credentials"];
return {
...connection,
...(app === AppConnection.Azure && {
azureResource: (credentials as { resource: AzureResources }).resource
})
};
});
return decryptedConnections as Omit<TAppConnection, "credentials">[];
};
return {