mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 21:51:56 +00:00
Merge remote-tracking branch 'origin/main' into feat/add-render-app-connection-and-secret-sync
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||
import { TSecretSyncListItem } from "@app/services/secret-sync/secret-sync-types";
|
||||
|
||||
export const FLYIO_SYNC_LIST_OPTION: TSecretSyncListItem = {
|
||||
name: "Fly.io",
|
||||
destination: SecretSync.Flyio,
|
||||
connection: AppConnection.Flyio,
|
||||
canImportSecrets: false
|
||||
};
|
||||
@@ -0,0 +1,133 @@
|
||||
import { request } from "@app/lib/config/request";
|
||||
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||
import {
|
||||
TDeleteFlyioVariable,
|
||||
TFlyioListVariables,
|
||||
TFlyioSecret,
|
||||
TFlyioSyncWithCredentials,
|
||||
TPutFlyioVariable
|
||||
} from "@app/services/secret-sync/flyio/flyio-sync-types";
|
||||
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
||||
import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";
|
||||
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
||||
|
||||
import { SECRET_SYNC_NAME_MAP } from "../secret-sync-maps";
|
||||
|
||||
const listFlyioSecrets = async ({ accessToken, appId }: TFlyioListVariables) => {
|
||||
const { data } = await request.post<{ data: { app: { secrets: TFlyioSecret[] } } }>(
|
||||
IntegrationUrls.FLYIO_API_URL,
|
||||
{
|
||||
query: "query GetAppSecrets($appId: String!) { app(id: $appId) { id name secrets { name createdAt } } }",
|
||||
variables: { appId }
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return data.data.app.secrets.map((s) => s.name);
|
||||
};
|
||||
|
||||
const putFlyioSecrets = async ({ accessToken, appId, secretMap }: TPutFlyioVariable) => {
|
||||
return request.post(
|
||||
IntegrationUrls.FLYIO_API_URL,
|
||||
{
|
||||
query:
|
||||
"mutation SetAppSecrets($appId: ID!, $secrets: [SecretInput!]!) { setSecrets(input: { appId: $appId, secrets: $secrets }) { app { name } release { version } } }",
|
||||
variables: {
|
||||
appId,
|
||||
secrets: Object.entries(secretMap).map(([key, { value }]) => ({ key, value }))
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const deleteFlyioSecrets = async ({ accessToken, appId, keys }: TDeleteFlyioVariable) => {
|
||||
return request.post(
|
||||
IntegrationUrls.FLYIO_API_URL,
|
||||
{
|
||||
query:
|
||||
"mutation UnsetAppSecrets($appId: ID!, $keys: [String!]!) { unsetSecrets(input: { appId: $appId, keys: $keys }) { app { name } release { version } } }",
|
||||
variables: {
|
||||
appId,
|
||||
keys
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const FlyioSyncFns = {
|
||||
syncSecrets: async (secretSync: TFlyioSyncWithCredentials, secretMap: TSecretMap) => {
|
||||
const {
|
||||
connection,
|
||||
environment,
|
||||
destinationConfig: { appId }
|
||||
} = secretSync;
|
||||
|
||||
const { accessToken } = connection.credentials;
|
||||
|
||||
try {
|
||||
await putFlyioSecrets({ accessToken, appId, secretMap });
|
||||
} catch (error) {
|
||||
throw new SecretSyncError({
|
||||
error
|
||||
});
|
||||
}
|
||||
|
||||
if (secretSync.syncOptions.disableSecretDeletion) return;
|
||||
|
||||
const secrets = await listFlyioSecrets({ accessToken, appId });
|
||||
|
||||
const keys = secrets.filter(
|
||||
(secret) =>
|
||||
matchesSchema(secret, environment?.slug || "", secretSync.syncOptions.keySchema) && !(secret in secretMap)
|
||||
);
|
||||
|
||||
try {
|
||||
await deleteFlyioSecrets({ accessToken, appId, keys });
|
||||
} catch (error) {
|
||||
throw new SecretSyncError({
|
||||
error
|
||||
});
|
||||
}
|
||||
},
|
||||
removeSecrets: async (secretSync: TFlyioSyncWithCredentials, secretMap: TSecretMap) => {
|
||||
const {
|
||||
connection,
|
||||
destinationConfig: { appId }
|
||||
} = secretSync;
|
||||
|
||||
const { accessToken } = connection.credentials;
|
||||
|
||||
const secrets = await listFlyioSecrets({ accessToken, appId });
|
||||
|
||||
const keys = secrets.filter((secret) => secret in secretMap);
|
||||
|
||||
try {
|
||||
await deleteFlyioSecrets({ accessToken, appId, keys });
|
||||
} catch (error) {
|
||||
throw new SecretSyncError({
|
||||
error
|
||||
});
|
||||
}
|
||||
},
|
||||
getSecrets: async (secretSync: TFlyioSyncWithCredentials) => {
|
||||
throw new Error(`${SECRET_SYNC_NAME_MAP[secretSync.destination]} does not support importing secrets.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { SecretSyncs } from "@app/lib/api-docs";
|
||||
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||
import {
|
||||
BaseSecretSyncSchema,
|
||||
GenericCreateSecretSyncFieldsSchema,
|
||||
GenericUpdateSecretSyncFieldsSchema
|
||||
} from "@app/services/secret-sync/secret-sync-schemas";
|
||||
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
|
||||
|
||||
const FlyioSyncDestinationConfigSchema = z.object({
|
||||
appId: z.string().trim().min(1, "App required").max(255).describe(SecretSyncs.DESTINATION_CONFIG.FLYIO.appId)
|
||||
});
|
||||
|
||||
const FlyioSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: false };
|
||||
|
||||
export const FlyioSyncSchema = BaseSecretSyncSchema(SecretSync.Flyio, FlyioSyncOptionsConfig).extend({
|
||||
destination: z.literal(SecretSync.Flyio),
|
||||
destinationConfig: FlyioSyncDestinationConfigSchema
|
||||
});
|
||||
|
||||
export const CreateFlyioSyncSchema = GenericCreateSecretSyncFieldsSchema(
|
||||
SecretSync.Flyio,
|
||||
FlyioSyncOptionsConfig
|
||||
).extend({
|
||||
destinationConfig: FlyioSyncDestinationConfigSchema
|
||||
});
|
||||
|
||||
export const UpdateFlyioSyncSchema = GenericUpdateSecretSyncFieldsSchema(
|
||||
SecretSync.Flyio,
|
||||
FlyioSyncOptionsConfig
|
||||
).extend({
|
||||
destinationConfig: FlyioSyncDestinationConfigSchema.optional()
|
||||
});
|
||||
|
||||
export const FlyioSyncListItemSchema = z.object({
|
||||
name: z.literal("Fly.io"),
|
||||
connection: z.literal(AppConnection.Flyio),
|
||||
destination: z.literal(SecretSync.Flyio),
|
||||
canImportSecrets: z.literal(false)
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { TFlyioConnection } from "@app/services/app-connection/flyio";
|
||||
|
||||
import { CreateFlyioSyncSchema, FlyioSyncListItemSchema, FlyioSyncSchema } from "./flyio-sync-schemas";
|
||||
|
||||
export type TFlyioSync = z.infer<typeof FlyioSyncSchema>;
|
||||
|
||||
export type TFlyioSyncInput = z.infer<typeof CreateFlyioSyncSchema>;
|
||||
|
||||
export type TFlyioSyncListItem = z.infer<typeof FlyioSyncListItemSchema>;
|
||||
|
||||
export type TFlyioSyncWithCredentials = TFlyioSync & {
|
||||
connection: TFlyioConnection;
|
||||
};
|
||||
|
||||
export type TFlyioSecret = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type TFlyioListVariables = {
|
||||
accessToken: string;
|
||||
appId: string;
|
||||
};
|
||||
|
||||
export type TPutFlyioVariable = TFlyioListVariables & {
|
||||
secretMap: { [key: string]: { value: string } };
|
||||
};
|
||||
|
||||
export type TDeleteFlyioVariable = TFlyioListVariables & {
|
||||
keys: string[];
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./flyio-sync-constants";
|
||||
export * from "./flyio-sync-fns";
|
||||
export * from "./flyio-sync-schemas";
|
||||
export * from "./flyio-sync-types";
|
||||
@@ -16,7 +16,8 @@ export enum SecretSync {
|
||||
TeamCity = "teamcity",
|
||||
OCIVault = "oci-vault",
|
||||
OnePass = "1password",
|
||||
Render = "render"
|
||||
Render = "render",
|
||||
Flyio = "flyio"
|
||||
}
|
||||
|
||||
export enum SecretSyncInitialSyncBehavior {
|
||||
|
||||
@@ -29,6 +29,7 @@ import { AZURE_APP_CONFIGURATION_SYNC_LIST_OPTION, azureAppConfigurationSyncFact
|
||||
import { AZURE_DEVOPS_SYNC_LIST_OPTION, azureDevOpsSyncFactory } from "./azure-devops";
|
||||
import { AZURE_KEY_VAULT_SYNC_LIST_OPTION, azureKeyVaultSyncFactory } from "./azure-key-vault";
|
||||
import { CAMUNDA_SYNC_LIST_OPTION, camundaSyncFactory } from "./camunda";
|
||||
import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
|
||||
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
||||
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
||||
import { HC_VAULT_SYNC_LIST_OPTION, HCVaultSyncFns } from "./hc-vault";
|
||||
@@ -59,7 +60,8 @@ const SECRET_SYNC_LIST_OPTIONS: Record<SecretSync, TSecretSyncListItem> = {
|
||||
[SecretSync.TeamCity]: TEAMCITY_SYNC_LIST_OPTION,
|
||||
[SecretSync.OCIVault]: OCI_VAULT_SYNC_LIST_OPTION,
|
||||
[SecretSync.OnePass]: ONEPASS_SYNC_LIST_OPTION,
|
||||
[SecretSync.Render]: RENDER_SYNC_LIST_OPTION
|
||||
[SecretSync.Render]: RENDER_SYNC_LIST_OPTION,
|
||||
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION
|
||||
};
|
||||
|
||||
export const listSecretSyncOptions = () => {
|
||||
@@ -219,6 +221,8 @@ export const SecretSyncFns = {
|
||||
return OnePassSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||
case SecretSync.Render:
|
||||
return RenderSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||
case SecretSync.Flyio:
|
||||
return FlyioSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||
default:
|
||||
throw new Error(
|
||||
`Unhandled sync destination for sync secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||
@@ -299,6 +303,9 @@ export const SecretSyncFns = {
|
||||
case SecretSync.Render:
|
||||
secretMap = await RenderSyncFns.getSecrets(secretSync);
|
||||
break;
|
||||
case SecretSync.Flyio:
|
||||
secretMap = await FlyioSyncFns.getSecrets(secretSync);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Unhandled sync destination for get secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||
@@ -368,6 +375,8 @@ export const SecretSyncFns = {
|
||||
return OnePassSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||
case SecretSync.Render:
|
||||
return RenderSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||
case SecretSync.Flyio:
|
||||
return FlyioSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||
default:
|
||||
throw new Error(
|
||||
`Unhandled sync destination for remove secrets fns: ${(secretSync as TSecretSyncWithCredentials).destination}`
|
||||
|
||||
@@ -19,7 +19,8 @@ export const SECRET_SYNC_NAME_MAP: Record<SecretSync, string> = {
|
||||
[SecretSync.TeamCity]: "TeamCity",
|
||||
[SecretSync.OCIVault]: "OCI Vault",
|
||||
[SecretSync.OnePass]: "1Password",
|
||||
[SecretSync.Render]: "Render"
|
||||
[SecretSync.Render]: "Render",
|
||||
[SecretSync.Flyio]: "Fly.io"
|
||||
};
|
||||
|
||||
export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
||||
@@ -40,7 +41,8 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
||||
[SecretSync.TeamCity]: AppConnection.TeamCity,
|
||||
[SecretSync.OCIVault]: AppConnection.OCI,
|
||||
[SecretSync.OnePass]: AppConnection.OnePass,
|
||||
[SecretSync.Render]: AppConnection.Render
|
||||
[SecretSync.Render]: AppConnection.Render,
|
||||
[SecretSync.Flyio]: AppConnection.Flyio
|
||||
};
|
||||
|
||||
export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
||||
@@ -61,5 +63,6 @@ export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
||||
[SecretSync.TeamCity]: SecretSyncPlanType.Regular,
|
||||
[SecretSync.OCIVault]: SecretSyncPlanType.Enterprise,
|
||||
[SecretSync.OnePass]: SecretSyncPlanType.Regular,
|
||||
[SecretSync.Render]: SecretSyncPlanType.Regular
|
||||
[SecretSync.Render]: SecretSyncPlanType.Regular,
|
||||
[SecretSync.Flyio]: SecretSyncPlanType.Regular
|
||||
};
|
||||
|
||||
@@ -3,8 +3,7 @@ import { AxiosError } from "axios";
|
||||
import { Job } from "bullmq";
|
||||
|
||||
import { ProjectMembershipRole, SecretType } from "@app/db/schemas";
|
||||
import { TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-service";
|
||||
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
|
||||
import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
|
||||
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
||||
import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";
|
||||
import { getConfig } from "@app/lib/config/env";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ForbiddenError } from "@casl/ability";
|
||||
import { ForbiddenError, subject } from "@casl/ability";
|
||||
|
||||
import { ActionProjectType } from "@app/db/schemas";
|
||||
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
||||
import { throwIfMissingSecretReadValueOrDescribePermission } from "@app/ee/services/permission/permission-fns";
|
||||
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
|
||||
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
|
||||
import {
|
||||
ProjectPermissionSecretActions,
|
||||
ProjectPermissionSecretSyncActions,
|
||||
@@ -89,7 +89,17 @@ export const secretSyncServiceFactory = ({
|
||||
projectId
|
||||
});
|
||||
|
||||
return secretSyncs as TSecretSync[];
|
||||
return secretSyncs.filter((secretSync) =>
|
||||
permission.can(
|
||||
ProjectPermissionSecretSyncActions.Read,
|
||||
secretSync.environment && secretSync.folder
|
||||
? subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
: ProjectPermissionSub.SecretSyncs
|
||||
)
|
||||
) as TSecretSync[];
|
||||
};
|
||||
|
||||
const listSecretSyncsBySecretPath = async (
|
||||
@@ -105,7 +115,15 @@ export const secretSyncServiceFactory = ({
|
||||
projectId
|
||||
});
|
||||
|
||||
if (permission.cannot(ProjectPermissionSecretSyncActions.Read, ProjectPermissionSub.SecretSyncs)) {
|
||||
if (
|
||||
permission.cannot(
|
||||
ProjectPermissionSecretSyncActions.Read,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment,
|
||||
secretPath
|
||||
})
|
||||
)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -142,7 +160,12 @@ export const secretSyncServiceFactory = ({
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Read,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
secretSync.environment && secretSync.folder
|
||||
? subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
: ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
@@ -179,7 +202,12 @@ export const secretSyncServiceFactory = ({
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Read,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
secretSync.environment && secretSync.folder
|
||||
? subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
: ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
@@ -217,13 +245,17 @@ export const secretSyncServiceFactory = ({
|
||||
|
||||
ForbiddenError.from(projectPermission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Create,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
subject(ProjectPermissionSub.SecretSyncs, { environment, secretPath })
|
||||
);
|
||||
|
||||
throwIfMissingSecretReadValueOrDescribePermission(projectPermission, ProjectPermissionSecretActions.ReadValue, {
|
||||
environment,
|
||||
secretPath
|
||||
});
|
||||
throwIfMissingSecretReadValueOrDescribePermission(
|
||||
projectPermission,
|
||||
ProjectPermissionSecretActions.DescribeSecret,
|
||||
{
|
||||
environment,
|
||||
secretPath
|
||||
}
|
||||
);
|
||||
|
||||
const folder = await folderDAL.findBySecretPath(projectId, environment, secretPath);
|
||||
|
||||
@@ -286,10 +318,38 @@ export const secretSyncServiceFactory = ({
|
||||
projectId: secretSync.projectId
|
||||
});
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Edit,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
// we always check the permission against the existing environment / secret path
|
||||
// if no secret path / environment is present on the secret sync, we need to check without conditions
|
||||
if (secretSync.environment?.slug && secretSync.folder?.path) {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Edit,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
);
|
||||
} else {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Edit,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
}
|
||||
|
||||
// if the user is updating the secret path or environment, we need to check the permission against the new values
|
||||
if (secretPath || environment) {
|
||||
const environmentToCheck = environment || secretSync.environment?.slug || "";
|
||||
const secretPathToCheck = secretPath || secretSync.folder?.path || "";
|
||||
|
||||
if (environmentToCheck && secretPathToCheck) {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Edit,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: environmentToCheck,
|
||||
secretPath: secretPathToCheck
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
throw new BadRequestError({
|
||||
@@ -315,7 +375,7 @@ export const secretSyncServiceFactory = ({
|
||||
if (!updatedEnvironment || !updatedSecretPath)
|
||||
throw new BadRequestError({ message: "Must specify both source environment and secret path" });
|
||||
|
||||
throwIfMissingSecretReadValueOrDescribePermission(permission, ProjectPermissionSecretActions.ReadValue, {
|
||||
throwIfMissingSecretReadValueOrDescribePermission(permission, ProjectPermissionSecretActions.DescribeSecret, {
|
||||
environment: updatedEnvironment,
|
||||
secretPath: updatedSecretPath
|
||||
});
|
||||
@@ -374,10 +434,20 @@ export const secretSyncServiceFactory = ({
|
||||
projectId: secretSync.projectId
|
||||
});
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Delete,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
if (secretSync.environment?.slug && secretSync.folder?.path) {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Delete,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
);
|
||||
} else {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.Delete,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
}
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
throw new BadRequestError({
|
||||
@@ -441,10 +511,20 @@ export const secretSyncServiceFactory = ({
|
||||
projectId: secretSync.projectId
|
||||
});
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.SyncSecrets,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
if (secretSync.environment?.slug && secretSync.folder?.path) {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.SyncSecrets,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
);
|
||||
} else {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.SyncSecrets,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
}
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
throw new BadRequestError({
|
||||
@@ -503,10 +583,20 @@ export const secretSyncServiceFactory = ({
|
||||
projectId: secretSync.projectId
|
||||
});
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.ImportSecrets,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
if (secretSync.environment?.slug && secretSync.folder?.path) {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.ImportSecrets,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
);
|
||||
} else {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.ImportSecrets,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
}
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
throw new BadRequestError({
|
||||
@@ -559,10 +649,20 @@ export const secretSyncServiceFactory = ({
|
||||
projectId: secretSync.projectId
|
||||
});
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.RemoveSecrets,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
if (secretSync.environment?.slug && secretSync.folder?.path) {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.RemoveSecrets,
|
||||
subject(ProjectPermissionSub.SecretSyncs, {
|
||||
environment: secretSync.environment.slug,
|
||||
secretPath: secretSync.folder.path
|
||||
})
|
||||
);
|
||||
} else {
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionSecretSyncActions.RemoveSecrets,
|
||||
ProjectPermissionSub.SecretSyncs
|
||||
);
|
||||
}
|
||||
|
||||
if (secretSync.connection.app !== SECRET_SYNC_CONNECTION_MAP[destination])
|
||||
throw new BadRequestError({
|
||||
|
||||
@@ -72,6 +72,7 @@ import {
|
||||
TAzureKeyVaultSyncListItem,
|
||||
TAzureKeyVaultSyncWithCredentials
|
||||
} from "./azure-key-vault";
|
||||
import { TFlyioSync, TFlyioSyncInput, TFlyioSyncListItem, TFlyioSyncWithCredentials } from "./flyio/flyio-sync-types";
|
||||
import { TGcpSync, TGcpSyncInput, TGcpSyncListItem, TGcpSyncWithCredentials } from "./gcp";
|
||||
import {
|
||||
THCVaultSync,
|
||||
@@ -123,7 +124,8 @@ export type TSecretSync =
|
||||
| TTeamCitySync
|
||||
| TOCIVaultSync
|
||||
| TOnePassSync
|
||||
| TRenderSync;
|
||||
| TRenderSync
|
||||
| TFlyioSync;
|
||||
|
||||
export type TSecretSyncWithCredentials =
|
||||
| TAwsParameterStoreSyncWithCredentials
|
||||
@@ -143,7 +145,8 @@ export type TSecretSyncWithCredentials =
|
||||
| TTeamCitySyncWithCredentials
|
||||
| TOCIVaultSyncWithCredentials
|
||||
| TOnePassSyncWithCredentials
|
||||
| TRenderSyncWithCredentials;
|
||||
| TRenderSyncWithCredentials
|
||||
| TFlyioSyncWithCredentials;
|
||||
|
||||
export type TSecretSyncInput =
|
||||
| TAwsParameterStoreSyncInput
|
||||
@@ -163,7 +166,8 @@ export type TSecretSyncInput =
|
||||
| TTeamCitySyncInput
|
||||
| TOCIVaultSyncInput
|
||||
| TOnePassSyncInput
|
||||
| TRenderSyncInput;
|
||||
| TRenderSyncInput
|
||||
| TFlyioSyncInput;
|
||||
|
||||
export type TSecretSyncListItem =
|
||||
| TAwsParameterStoreSyncListItem
|
||||
@@ -183,7 +187,8 @@ export type TSecretSyncListItem =
|
||||
| TTeamCitySyncListItem
|
||||
| TOCIVaultSyncListItem
|
||||
| TOnePassSyncListItem
|
||||
| TRenderSyncListItem;
|
||||
| TRenderSyncListItem
|
||||
| TFlyioSyncListItem;
|
||||
|
||||
export type TSyncOptionsConfig = {
|
||||
canImportSecrets: boolean;
|
||||
|
||||
Reference in New Issue
Block a user