mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 13:27:46 +00:00
greptile review fixes
This commit is contained in:
@@ -3,10 +3,9 @@ import {
|
|||||||
OCIVaultSyncSchema,
|
OCIVaultSyncSchema,
|
||||||
UpdateOCIVaultSyncSchema
|
UpdateOCIVaultSyncSchema
|
||||||
} from "@app/ee/services/secret-sync/oci-vault";
|
} from "@app/ee/services/secret-sync/oci-vault";
|
||||||
|
import { registerSyncSecretsEndpoints } from "@app/server/routes/v1/secret-sync-routers/secret-sync-endpoints";
|
||||||
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
|
||||||
import { registerSyncSecretsEndpoints } from "../../../../server/routes/v1/secret-sync-routers/secret-sync-endpoints";
|
|
||||||
|
|
||||||
export const registerOCIVaultSyncRouter = async (server: FastifyZodProvider) =>
|
export const registerOCIVaultSyncRouter = async (server: FastifyZodProvider) =>
|
||||||
registerSyncSecretsEndpoints({
|
registerSyncSecretsEndpoints({
|
||||||
destination: SecretSync.OCIVault,
|
destination: SecretSync.OCIVault,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { registerOCIConnectionRouter } from "@app/ee/routes/v1/app-connection-routers/oci-connection-router";
|
||||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
|
||||||
import { registerOCIConnectionRouter } from "../../../../ee/routes/v1/app-connection-routers/oci-connection-router";
|
|
||||||
import { registerAuth0ConnectionRouter } from "./auth0-connection-router";
|
import { registerAuth0ConnectionRouter } from "./auth0-connection-router";
|
||||||
import { registerAwsConnectionRouter } from "./aws-connection-router";
|
import { registerAwsConnectionRouter } from "./aws-connection-router";
|
||||||
import { registerAzureAppConfigurationConnectionRouter } from "./azure-app-configuration-connection-router";
|
import { registerAzureAppConfigurationConnectionRouter } from "./azure-app-configuration-connection-router";
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { TAppConnections } from "@app/db/schemas/app-connections";
|
import { TAppConnections } from "@app/db/schemas/app-connections";
|
||||||
|
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
||||||
import { generateHash } from "@app/lib/crypto/encryption";
|
import { generateHash } from "@app/lib/crypto/encryption";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
import { APP_CONNECTION_NAME_MAP } from "@app/services/app-connection/app-connection-maps";
|
import { APP_CONNECTION_NAME_MAP, APP_CONNECTION_PLAN_MAP } from "@app/services/app-connection/app-connection-maps";
|
||||||
import {
|
import {
|
||||||
transferSqlConnectionCredentialsToPlatform,
|
transferSqlConnectionCredentialsToPlatform,
|
||||||
validateSqlConnectionCredentials
|
validateSqlConnectionCredentials
|
||||||
@@ -13,7 +14,7 @@ import {
|
|||||||
OCIConnectionMethod,
|
OCIConnectionMethod,
|
||||||
validateOCIConnectionCredentials
|
validateOCIConnectionCredentials
|
||||||
} from "../../ee/services/app-connections/oci";
|
} from "../../ee/services/app-connections/oci";
|
||||||
import { AppConnection } from "./app-connection-enums";
|
import { AppConnection, AppConnectionPlanType } from "./app-connection-enums";
|
||||||
import { TAppConnectionServiceFactoryDep } from "./app-connection-service";
|
import { TAppConnectionServiceFactoryDep } from "./app-connection-service";
|
||||||
import {
|
import {
|
||||||
TAppConnection,
|
TAppConnection,
|
||||||
@@ -261,3 +262,18 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
|
|||||||
[AppConnection.TeamCity]: platformManagedCredentialsNotSupported,
|
[AppConnection.TeamCity]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.OCI]: platformManagedCredentialsNotSupported
|
[AppConnection.OCI]: platformManagedCredentialsNotSupported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const enterpriseAppCheck = async (
|
||||||
|
licenseService: Pick<TLicenseServiceFactory, "getPlan">,
|
||||||
|
appConnection: AppConnection,
|
||||||
|
orgId: string,
|
||||||
|
errorMessage: string
|
||||||
|
) => {
|
||||||
|
if (APP_CONNECTION_PLAN_MAP[appConnection] === AppConnectionPlanType.Enterprise) {
|
||||||
|
const plan = await licenseService.getPlan(orgId);
|
||||||
|
if (!plan.enterpriseAppConnections)
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: errorMessage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { DiscriminativePick, OrgServiceActor } from "@app/lib/types";
|
|||||||
import {
|
import {
|
||||||
decryptAppConnection,
|
decryptAppConnection,
|
||||||
encryptAppConnectionCredentials,
|
encryptAppConnectionCredentials,
|
||||||
|
enterpriseAppCheck,
|
||||||
getAppConnectionMethodName,
|
getAppConnectionMethodName,
|
||||||
listAppConnectionOptions,
|
listAppConnectionOptions,
|
||||||
TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM,
|
TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM,
|
||||||
@@ -21,8 +22,8 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";
|
|||||||
import { ValidateOCIConnectionCredentialsSchema } from "../../ee/services/app-connections/oci";
|
import { ValidateOCIConnectionCredentialsSchema } from "../../ee/services/app-connections/oci";
|
||||||
import { ociConnectionService } from "../../ee/services/app-connections/oci/oci-connection-service";
|
import { ociConnectionService } from "../../ee/services/app-connections/oci/oci-connection-service";
|
||||||
import { TAppConnectionDALFactory } from "./app-connection-dal";
|
import { TAppConnectionDALFactory } from "./app-connection-dal";
|
||||||
import { AppConnection, AppConnectionPlanType } from "./app-connection-enums";
|
import { AppConnection } from "./app-connection-enums";
|
||||||
import { APP_CONNECTION_NAME_MAP, APP_CONNECTION_PLAN_MAP } from "./app-connection-maps";
|
import { APP_CONNECTION_NAME_MAP } from "./app-connection-maps";
|
||||||
import {
|
import {
|
||||||
TAppConnection,
|
TAppConnection,
|
||||||
TAppConnectionConfig,
|
TAppConnectionConfig,
|
||||||
@@ -194,15 +195,12 @@ export const appConnectionServiceFactory = ({
|
|||||||
OrgPermissionSubjects.AppConnections
|
OrgPermissionSubjects.AppConnections
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseAppCheck(
|
||||||
if (APP_CONNECTION_PLAN_MAP[app] === AppConnectionPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
app,
|
||||||
if (!plan.enterpriseAppConnections)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to create app connection due to plan restriction. Upgrade plan to access enterprise app connections."
|
"Failed to create app connection due to plan restriction. Upgrade plan to access enterprise app connections."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const validatedCredentials = await validateAppConnectionCredentials({
|
const validatedCredentials = await validateAppConnectionCredentials({
|
||||||
app,
|
app,
|
||||||
@@ -266,15 +264,12 @@ export const appConnectionServiceFactory = ({
|
|||||||
|
|
||||||
if (!appConnection) throw new NotFoundError({ message: `Could not find App Connection with ID ${connectionId}` });
|
if (!appConnection) throw new NotFoundError({ message: `Could not find App Connection with ID ${connectionId}` });
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseAppCheck(
|
||||||
if (APP_CONNECTION_PLAN_MAP[appConnection.app as AppConnection] === AppConnectionPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
appConnection.app as AppConnection,
|
||||||
if (!plan.enterpriseAppConnections)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to update app connection due to plan restriction. Upgrade plan to access enterprise app connections."
|
"Failed to update app connection due to plan restriction. Upgrade plan to access enterprise app connections."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const { permission } = await permissionService.getOrgPermission(
|
const { permission } = await permissionService.getOrgPermission(
|
||||||
actor.type,
|
actor.type,
|
||||||
@@ -422,15 +417,12 @@ export const appConnectionServiceFactory = ({
|
|||||||
|
|
||||||
if (!appConnection) throw new NotFoundError({ message: `Could not find App Connection with ID ${connectionId}` });
|
if (!appConnection) throw new NotFoundError({ message: `Could not find App Connection with ID ${connectionId}` });
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseAppCheck(
|
||||||
if (APP_CONNECTION_PLAN_MAP[app] === AppConnectionPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
app,
|
||||||
if (!plan.enterpriseAppConnections)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
"Failed to connect app due to plan restriction. Upgrade plan to access enterprise app connections."
|
||||||
message:
|
);
|
||||||
"Failed to connect app connection due to plan restriction. Upgrade plan to access enterprise app connections."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const { permission: orgPermission } = await permissionService.getOrgPermission(
|
const { permission: orgPermission } = await permissionService.getOrgPermission(
|
||||||
actor.type,
|
actor.type,
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import RE2 from "re2";
|
import RE2 from "re2";
|
||||||
|
|
||||||
|
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
||||||
import { OCI_VAULT_SYNC_LIST_OPTION, OCIVaultSyncFns } from "@app/ee/services/secret-sync/oci-vault";
|
import { OCI_VAULT_SYNC_LIST_OPTION, OCIVaultSyncFns } from "@app/ee/services/secret-sync/oci-vault";
|
||||||
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
import {
|
import {
|
||||||
AWS_PARAMETER_STORE_SYNC_LIST_OPTION,
|
AWS_PARAMETER_STORE_SYNC_LIST_OPTION,
|
||||||
AwsParameterStoreSyncFns
|
AwsParameterStoreSyncFns
|
||||||
@@ -12,7 +14,7 @@ import {
|
|||||||
} from "@app/services/secret-sync/aws-secrets-manager";
|
} from "@app/services/secret-sync/aws-secrets-manager";
|
||||||
import { DATABRICKS_SYNC_LIST_OPTION, databricksSyncFactory } from "@app/services/secret-sync/databricks";
|
import { DATABRICKS_SYNC_LIST_OPTION, databricksSyncFactory } from "@app/services/secret-sync/databricks";
|
||||||
import { GITHUB_SYNC_LIST_OPTION, GithubSyncFns } from "@app/services/secret-sync/github";
|
import { GITHUB_SYNC_LIST_OPTION, GithubSyncFns } from "@app/services/secret-sync/github";
|
||||||
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
import { SecretSync, SecretSyncPlanType } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
||||||
import {
|
import {
|
||||||
TSecretMap,
|
TSecretMap,
|
||||||
@@ -30,6 +32,7 @@ import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
|||||||
import { HC_VAULT_SYNC_LIST_OPTION, HCVaultSyncFns } from "./hc-vault";
|
import { HC_VAULT_SYNC_LIST_OPTION, HCVaultSyncFns } from "./hc-vault";
|
||||||
import { HUMANITEC_SYNC_LIST_OPTION } from "./humanitec";
|
import { HUMANITEC_SYNC_LIST_OPTION } from "./humanitec";
|
||||||
import { HumanitecSyncFns } from "./humanitec/humanitec-sync-fns";
|
import { HumanitecSyncFns } from "./humanitec/humanitec-sync-fns";
|
||||||
|
import { SECRET_SYNC_PLAN_MAP } from "./secret-sync-maps";
|
||||||
import { TEAMCITY_SYNC_LIST_OPTION, TeamCitySyncFns } from "./teamcity";
|
import { TEAMCITY_SYNC_LIST_OPTION, TeamCitySyncFns } from "./teamcity";
|
||||||
import { TERRAFORM_CLOUD_SYNC_LIST_OPTION, TerraformCloudSyncFns } from "./terraform-cloud";
|
import { TERRAFORM_CLOUD_SYNC_LIST_OPTION, TerraformCloudSyncFns } from "./terraform-cloud";
|
||||||
import { VERCEL_SYNC_LIST_OPTION, VercelSyncFns } from "./vercel";
|
import { VERCEL_SYNC_LIST_OPTION, VercelSyncFns } from "./vercel";
|
||||||
@@ -327,3 +330,18 @@ export const parseSyncErrorMessage = (err: unknown): string => {
|
|||||||
? errorMessage
|
? errorMessage
|
||||||
: `${errorMessage.substring(0, MAX_MESSAGE_LENGTH - 3)}...`;
|
: `${errorMessage.substring(0, MAX_MESSAGE_LENGTH - 3)}...`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const enterpriseSyncCheck = async (
|
||||||
|
licenseService: Pick<TLicenseServiceFactory, "getPlan">,
|
||||||
|
secretSync: SecretSync,
|
||||||
|
orgId: string,
|
||||||
|
errorMessage: string
|
||||||
|
) => {
|
||||||
|
if (SECRET_SYNC_PLAN_MAP[secretSync] === SecretSyncPlanType.Enterprise) {
|
||||||
|
const plan = await licenseService.getPlan(orgId);
|
||||||
|
if (!plan.enterpriseSecretSyncs)
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: errorMessage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { EventType } from "@app/ee/services/audit-log/audit-log-types";
|
|||||||
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
||||||
import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";
|
import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";
|
||||||
import { getConfig } from "@app/lib/config/env";
|
import { getConfig } from "@app/lib/config/env";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
|
||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
||||||
import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
|
import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
|
||||||
@@ -31,12 +30,11 @@ import { TSecretSyncDALFactory } from "@app/services/secret-sync/secret-sync-dal
|
|||||||
import {
|
import {
|
||||||
SecretSync,
|
SecretSync,
|
||||||
SecretSyncImportBehavior,
|
SecretSyncImportBehavior,
|
||||||
SecretSyncInitialSyncBehavior,
|
SecretSyncInitialSyncBehavior
|
||||||
SecretSyncPlanType
|
|
||||||
} from "@app/services/secret-sync/secret-sync-enums";
|
} from "@app/services/secret-sync/secret-sync-enums";
|
||||||
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
||||||
import { parseSyncErrorMessage, SecretSyncFns } from "@app/services/secret-sync/secret-sync-fns";
|
import { enterpriseSyncCheck, parseSyncErrorMessage, SecretSyncFns } from "@app/services/secret-sync/secret-sync-fns";
|
||||||
import { SECRET_SYNC_NAME_MAP, SECRET_SYNC_PLAN_MAP } from "@app/services/secret-sync/secret-sync-maps";
|
import { SECRET_SYNC_NAME_MAP } from "@app/services/secret-sync/secret-sync-maps";
|
||||||
import {
|
import {
|
||||||
SecretSyncAction,
|
SecretSyncAction,
|
||||||
SecretSyncStatus,
|
SecretSyncStatus,
|
||||||
@@ -336,14 +334,12 @@ export const secretSyncQueueFactory = ({
|
|||||||
connection: { orgId }
|
connection: { orgId }
|
||||||
} = secretSync;
|
} = secretSync;
|
||||||
|
|
||||||
// Enterprise Check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[destination] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(orgId);
|
destination,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
orgId,
|
||||||
throw new BadRequestError({
|
"Failed to import secrets due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
message: "Failed to import secrets due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!environment || !folder)
|
if (!environment || !folder)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -420,14 +416,12 @@ export const secretSyncQueueFactory = ({
|
|||||||
|
|
||||||
if (!secretSync) throw new Error(`Cannot find secret sync with ID ${syncId}`);
|
if (!secretSync) throw new Error(`Cannot find secret sync with ID ${syncId}`);
|
||||||
|
|
||||||
// Enterprise Check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[secretSync.destination as SecretSync] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(secretSync.connection.orgId);
|
secretSync.destination as SecretSync,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
secretSync.connection.orgId,
|
||||||
throw new BadRequestError({
|
"Failed to sync secrets due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
message: "Failed to sync secrets due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await secretSyncDAL.updateById(syncId, {
|
await secretSyncDAL.updateById(syncId, {
|
||||||
syncStatus: SecretSyncStatus.Running
|
syncStatus: SecretSyncStatus.Running
|
||||||
@@ -688,15 +682,12 @@ export const secretSyncQueueFactory = ({
|
|||||||
|
|
||||||
if (!secretSync) throw new Error(`Cannot find secret sync with ID ${syncId}`);
|
if (!secretSync) throw new Error(`Cannot find secret sync with ID ${syncId}`);
|
||||||
|
|
||||||
// Enterprise Check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[secretSync.destination as SecretSync] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(secretSync.connection.orgId);
|
secretSync.destination as SecretSync,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
secretSync.connection.orgId,
|
||||||
throw new BadRequestError({
|
"Failed to remove secrets due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
message:
|
);
|
||||||
"Failed to access secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await secretSyncDAL.updateById(syncId, {
|
await secretSyncDAL.updateById(syncId, {
|
||||||
removeStatus: SecretSyncStatus.Running
|
removeStatus: SecretSyncStatus.Running
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import { OrgServiceActor } from "@app/lib/types";
|
|||||||
import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";
|
import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";
|
||||||
import { TProjectBotServiceFactory } from "@app/services/project-bot/project-bot-service";
|
import { TProjectBotServiceFactory } from "@app/services/project-bot/project-bot-service";
|
||||||
import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-folder-dal";
|
import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-folder-dal";
|
||||||
import { SecretSync, SecretSyncPlanType } from "@app/services/secret-sync/secret-sync-enums";
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
import { listSecretSyncOptions } from "@app/services/secret-sync/secret-sync-fns";
|
import { enterpriseSyncCheck, listSecretSyncOptions } from "@app/services/secret-sync/secret-sync-fns";
|
||||||
import {
|
import {
|
||||||
SecretSyncStatus,
|
SecretSyncStatus,
|
||||||
TCreateSecretSyncDTO,
|
TCreateSecretSyncDTO,
|
||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
|
|
||||||
import { TSecretImportDALFactory } from "../secret-import/secret-import-dal";
|
import { TSecretImportDALFactory } from "../secret-import/secret-import-dal";
|
||||||
import { TSecretSyncDALFactory } from "./secret-sync-dal";
|
import { TSecretSyncDALFactory } from "./secret-sync-dal";
|
||||||
import { SECRET_SYNC_CONNECTION_MAP, SECRET_SYNC_NAME_MAP, SECRET_SYNC_PLAN_MAP } from "./secret-sync-maps";
|
import { SECRET_SYNC_CONNECTION_MAP, SECRET_SYNC_NAME_MAP } from "./secret-sync-maps";
|
||||||
import { TSecretSyncQueueFactory } from "./secret-sync-queue";
|
import { TSecretSyncQueueFactory } from "./secret-sync-queue";
|
||||||
|
|
||||||
type TSecretSyncServiceFactoryDep = {
|
type TSecretSyncServiceFactoryDep = {
|
||||||
@@ -194,15 +194,12 @@ export const secretSyncServiceFactory = ({
|
|||||||
{ projectId, secretPath, environment, ...params }: TCreateSecretSyncDTO,
|
{ projectId, secretPath, environment, ...params }: TCreateSecretSyncDTO,
|
||||||
actor: OrgServiceActor
|
actor: OrgServiceActor
|
||||||
) => {
|
) => {
|
||||||
// Enterprise check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[params.destination] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
params.destination,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to create secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
"Failed to create secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const { permission: projectPermission } = await permissionService.getProjectPermission({
|
const { permission: projectPermission } = await permissionService.getProjectPermission({
|
||||||
actor: actor.type,
|
actor: actor.type,
|
||||||
@@ -273,15 +270,12 @@ export const secretSyncServiceFactory = ({
|
|||||||
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID ${syncId}`
|
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID ${syncId}`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[secretSync.destination as SecretSync] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
secretSync.destination as SecretSync,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to update secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
"Failed to update secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor: actor.type,
|
actor: actor.type,
|
||||||
@@ -431,15 +425,12 @@ export const secretSyncServiceFactory = ({
|
|||||||
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID "${syncId}"`
|
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID "${syncId}"`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[secretSync.destination as SecretSync] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
secretSync.destination as SecretSync,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to trigger secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
"Failed to trigger secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor: actor.type,
|
actor: actor.type,
|
||||||
@@ -496,15 +487,12 @@ export const secretSyncServiceFactory = ({
|
|||||||
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID "${syncId}"`
|
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID "${syncId}"`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[secretSync.destination as SecretSync] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
secretSync.destination as SecretSync,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to trigger secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
"Failed to trigger secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor: actor.type,
|
actor: actor.type,
|
||||||
@@ -555,15 +543,12 @@ export const secretSyncServiceFactory = ({
|
|||||||
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID "${syncId}"`
|
message: `Could not find ${SECRET_SYNC_NAME_MAP[destination]} Sync with ID "${syncId}"`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enterprise check
|
await enterpriseSyncCheck(
|
||||||
if (SECRET_SYNC_PLAN_MAP[secretSync.destination as SecretSync] === SecretSyncPlanType.Enterprise) {
|
licenseService,
|
||||||
const plan = await licenseService.getPlan(actor.orgId);
|
secretSync.destination as SecretSync,
|
||||||
if (!plan.enterpriseSecretSyncs)
|
actor.orgId,
|
||||||
throw new BadRequestError({
|
|
||||||
message:
|
|
||||||
"Failed to trigger secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
"Failed to trigger secret sync due to plan restriction. Upgrade plan to access enterprise secret syncs."
|
||||||
});
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission({
|
const { permission } = await permissionService.getProjectPermission({
|
||||||
actor: actor.type,
|
actor: actor.type,
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ export const SecretSyncSelect = ({ onSelect }: Props) => {
|
|||||||
const { image, name } = SECRET_SYNC_MAP[destination];
|
const { image, name } = SECRET_SYNC_MAP[destination];
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
key={destination}
|
||||||
content={
|
content={
|
||||||
enterprise && !subscription.enterpriseSecretSyncs ? "Enterprise Plan Only" : undefined
|
enterprise && !subscription.enterpriseSecretSyncs ? "Enterprise Plan Only" : undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
key={destination}
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
enterprise && !subscription.enterpriseSecretSyncs
|
enterprise && !subscription.enterpriseSecretSyncs
|
||||||
? handlePopUpOpen("upgradePlan")
|
? handlePopUpOpen("upgradePlan")
|
||||||
|
|||||||
+1
-1
@@ -36,6 +36,7 @@ export const AppConnectionsSelect = ({ onSelect }: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
key={option.app}
|
||||||
content={
|
content={
|
||||||
enterprise && !subscription.enterpriseAppConnections
|
enterprise && !subscription.enterpriseAppConnections
|
||||||
? "Enterprise Plan Only"
|
? "Enterprise Plan Only"
|
||||||
@@ -44,7 +45,6 @@ export const AppConnectionsSelect = ({ onSelect }: Props) => {
|
|||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
key={option.app}
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
enterprise && !subscription.enterpriseAppConnections
|
enterprise && !subscription.enterpriseAppConnections
|
||||||
? handlePopUpOpen("upgradePlan")
|
? handlePopUpOpen("upgradePlan")
|
||||||
|
|||||||
Reference in New Issue
Block a user