mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 09:26:14 +00:00
Update orgScope to orgId naming for org-level auth ref, rewire user invite saml block to org authEnforce field
This commit is contained in:
@@ -22,7 +22,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgPlansTableByBillCycle({
|
const data = await server.services.license.getOrgPlansTableByBillCycle({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
billingCycle: req.query.billingCycle
|
billingCycle: req.query.billingCycle
|
||||||
});
|
});
|
||||||
@@ -44,7 +44,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const plan = await server.services.license.getOrgPlan({
|
const plan = await server.services.license.getOrgPlan({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return { plan };
|
return { plan };
|
||||||
@@ -87,7 +87,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.startOrgTrial({
|
const data = await server.services.license.startOrgTrial({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
success_url: req.body.success_url
|
success_url: req.body.success_url
|
||||||
});
|
});
|
||||||
@@ -109,7 +109,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.createOrganizationPortalSession({
|
const data = await server.services.license.createOrganizationPortalSession({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -130,7 +130,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgBillingInfo({
|
const data = await server.services.license.getOrgBillingInfo({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -151,7 +151,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgPlanTable({
|
const data = await server.services.license.getOrgPlanTable({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -172,7 +172,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgBillingDetails({
|
const data = await server.services.license.getOrgBillingDetails({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -197,7 +197,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.updateOrgBillingDetails({
|
const data = await server.services.license.updateOrgBillingDetails({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
email: req.body.email
|
email: req.body.email
|
||||||
@@ -220,7 +220,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgPmtMethods({
|
const data = await server.services.license.getOrgPmtMethods({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -245,7 +245,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.addOrgPmtMethods({
|
const data = await server.services.license.addOrgPmtMethods({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
success_url: req.body.success_url,
|
success_url: req.body.success_url,
|
||||||
cancel_url: req.body.cancel_url
|
cancel_url: req.body.cancel_url
|
||||||
@@ -271,7 +271,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.delOrgPmtMethods({
|
const data = await server.services.license.delOrgPmtMethods({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
pmtMethodId: req.params.pmtMethodId
|
pmtMethodId: req.params.pmtMethodId
|
||||||
});
|
});
|
||||||
@@ -295,7 +295,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgTaxIds({
|
const data = await server.services.license.getOrgTaxIds({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -322,7 +322,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.addOrgTaxId({
|
const data = await server.services.license.addOrgTaxId({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
type: req.body.type,
|
type: req.body.type,
|
||||||
value: req.body.value
|
value: req.body.value
|
||||||
@@ -348,7 +348,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.delOrgTaxId({
|
const data = await server.services.license.delOrgTaxId({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
taxId: req.params.taxId
|
taxId: req.params.taxId
|
||||||
});
|
});
|
||||||
@@ -372,7 +372,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgTaxInvoices({
|
const data = await server.services.license.getOrgTaxInvoices({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
@@ -395,7 +395,7 @@ export const registerLicenseRouter = async (server: FastifyZodProvider) => {
|
|||||||
const data = await server.services.license.getOrgLicenses({
|
const data = await server.services.license.getOrgLicenses({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secretSnapshots = await server.services.snapshot.listSnapshots({
|
const secretSnapshots = await server.services.snapshot.listSnapshots({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
...req.query
|
...req.query
|
||||||
});
|
});
|
||||||
@@ -61,7 +61,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const count = await server.services.snapshot.projectSecretSnapshotCount({
|
const count = await server.services.snapshot.projectSecretSnapshotCount({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
environment: req.query.environment,
|
environment: req.query.environment,
|
||||||
path: req.query.path
|
path: req.query.path
|
||||||
@@ -114,7 +114,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const auditLogs = await server.services.auditLog.listProjectAuditLogs({
|
const auditLogs = await server.services.auditLog.listProjectAuditLogs({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
...req.query,
|
...req.query,
|
||||||
auditLogActor: req.query.actor,
|
auditLogActor: req.query.actor,
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
|
|||||||
const saml = await server.services.saml.getSaml({
|
const saml = await server.services.saml.getSaml({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.query.organizationId,
|
orgId: req.query.organizationId,
|
||||||
type: "org"
|
type: "org"
|
||||||
});
|
});
|
||||||
@@ -254,7 +254,7 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
|
|||||||
const saml = await server.services.saml.createSamlCfg({
|
const saml = await server.services.saml.createSamlCfg({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.body.organizationId,
|
orgId: req.body.organizationId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -285,7 +285,7 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
|
|||||||
const saml = await server.services.saml.updateSamlCfg({
|
const saml = await server.services.saml.updateSamlCfg({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.body.organizationId,
|
orgId: req.body.organizationId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
const approval = await server.services.secretApprovalPolicy.createSecretApprovalPolicy({
|
const approval = await server.services.secretApprovalPolicy.createSecretApprovalPolicy({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
...req.body,
|
...req.body,
|
||||||
name: req.body.name ?? `${req.body.environment}-${nanoid(3)}`
|
name: req.body.name ?? `${req.body.environment}-${nanoid(3)}`
|
||||||
@@ -72,7 +72,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
const approval = await server.services.secretApprovalPolicy.updateSecretApprovalPolicy({
|
const approval = await server.services.secretApprovalPolicy.updateSecretApprovalPolicy({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
secretPolicyId: req.params.sapId
|
secretPolicyId: req.params.sapId
|
||||||
});
|
});
|
||||||
@@ -98,7 +98,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
const approval = await server.services.secretApprovalPolicy.deleteSecretApprovalPolicy({
|
const approval = await server.services.secretApprovalPolicy.deleteSecretApprovalPolicy({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPolicyId: req.params.sapId
|
secretPolicyId: req.params.sapId
|
||||||
});
|
});
|
||||||
return { approval };
|
return { approval };
|
||||||
@@ -123,7 +123,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
const approvals = await server.services.secretApprovalPolicy.getSecretApprovalPolicyByProjectId({
|
const approvals = await server.services.secretApprovalPolicy.getSecretApprovalPolicyByProjectId({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
return { approvals };
|
return { approvals };
|
||||||
@@ -150,7 +150,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
|
|||||||
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.query.workspaceId,
|
projectId: req.query.workspaceId,
|
||||||
...req.query
|
...req.query
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export const registerSecretApprovalRequestRouter = async (server: FastifyZodProv
|
|||||||
const approvals = await server.services.secretApprovalRequest.getSecretApprovals({
|
const approvals = await server.services.secretApprovalRequest.getSecretApprovals({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.query,
|
...req.query,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
@@ -81,7 +81,7 @@ export const registerSecretApprovalRequestRouter = async (server: FastifyZodProv
|
|||||||
const approvals = await server.services.secretApprovalRequest.requestCount({
|
const approvals = await server.services.secretApprovalRequest.requestCount({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
return { approvals };
|
return { approvals };
|
||||||
@@ -106,7 +106,7 @@ export const registerSecretApprovalRequestRouter = async (server: FastifyZodProv
|
|||||||
const { approval } = await server.services.secretApprovalRequest.mergeSecretApprovalRequest({
|
const { approval } = await server.services.secretApprovalRequest.mergeSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
approvalId: req.params.id
|
approvalId: req.params.id
|
||||||
});
|
});
|
||||||
return { approval };
|
return { approval };
|
||||||
@@ -134,7 +134,7 @@ export const registerSecretApprovalRequestRouter = async (server: FastifyZodProv
|
|||||||
const review = await server.services.secretApprovalRequest.reviewApproval({
|
const review = await server.services.secretApprovalRequest.reviewApproval({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
approvalId: req.params.id,
|
approvalId: req.params.id,
|
||||||
status: req.body.status
|
status: req.body.status
|
||||||
});
|
});
|
||||||
@@ -163,7 +163,7 @@ export const registerSecretApprovalRequestRouter = async (server: FastifyZodProv
|
|||||||
const approval = await server.services.secretApprovalRequest.updateApprovalStatus({
|
const approval = await server.services.secretApprovalRequest.updateApprovalStatus({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
approvalId: req.params.id,
|
approvalId: req.params.id,
|
||||||
status: req.body.status
|
status: req.body.status
|
||||||
});
|
});
|
||||||
@@ -271,7 +271,7 @@ export const registerSecretApprovalRequestRouter = async (server: FastifyZodProv
|
|||||||
const approval = await server.services.secretApprovalRequest.getSecretApprovalDetails({
|
const approval = await server.services.secretApprovalRequest.getSecretApprovalDetails({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.id
|
id: req.params.id
|
||||||
});
|
});
|
||||||
return { approval };
|
return { approval };
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const registerSecretRotationProviderRouter = async (server: FastifyZodPro
|
|||||||
const providers = await server.services.secretRotation.getProviderTemplates({
|
const providers = await server.services.secretRotation.getProviderTemplates({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return providers;
|
return providers;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export const registerSecretRotationRouter = async (server: FastifyZodProvider) =
|
|||||||
const secretRotation = await server.services.secretRotation.createRotation({
|
const secretRotation = await server.services.secretRotation.createRotation({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId
|
projectId: req.body.workspaceId
|
||||||
});
|
});
|
||||||
@@ -74,7 +74,7 @@ export const registerSecretRotationRouter = async (server: FastifyZodProvider) =
|
|||||||
const secretRotation = await server.services.secretRotation.restartById({
|
const secretRotation = await server.services.secretRotation.restartById({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
rotationId: req.body.id
|
rotationId: req.body.id
|
||||||
});
|
});
|
||||||
return { secretRotation };
|
return { secretRotation };
|
||||||
@@ -125,7 +125,7 @@ export const registerSecretRotationRouter = async (server: FastifyZodProvider) =
|
|||||||
const secretRotations = await server.services.secretRotation.getByProjectId({
|
const secretRotations = await server.services.secretRotation.getByProjectId({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
return { secretRotations };
|
return { secretRotations };
|
||||||
@@ -158,7 +158,7 @@ export const registerSecretRotationRouter = async (server: FastifyZodProvider) =
|
|||||||
const secretRotation = await server.services.secretRotation.deleteById({
|
const secretRotation = await server.services.secretRotation.deleteById({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
rotationId: req.params.id
|
rotationId: req.params.id
|
||||||
});
|
});
|
||||||
return { secretRotation };
|
return { secretRotation };
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const registerSecretScanningRouter = async (server: FastifyZodProvider) =
|
|||||||
const session = await server.services.secretScanning.createInstallationSession({
|
const session = await server.services.secretScanning.createInstallationSession({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.body.organizationId
|
orgId: req.body.organizationId
|
||||||
});
|
});
|
||||||
return session;
|
return session;
|
||||||
@@ -46,7 +46,7 @@ export const registerSecretScanningRouter = async (server: FastifyZodProvider) =
|
|||||||
const { installatedApp } = await server.services.secretScanning.linkInstallationToOrg({
|
const { installatedApp } = await server.services.secretScanning.linkInstallationToOrg({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
return installatedApp;
|
return installatedApp;
|
||||||
@@ -67,7 +67,7 @@ export const registerSecretScanningRouter = async (server: FastifyZodProvider) =
|
|||||||
const appInstallationCompleted = await server.services.secretScanning.getOrgInstallationStatus({
|
const appInstallationCompleted = await server.services.secretScanning.getOrgInstallationStatus({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return { appInstallationCompleted };
|
return { appInstallationCompleted };
|
||||||
@@ -88,7 +88,7 @@ export const registerSecretScanningRouter = async (server: FastifyZodProvider) =
|
|||||||
const { risks } = await server.services.secretScanning.getRisksByOrg({
|
const { risks } = await server.services.secretScanning.getRisksByOrg({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
return { risks };
|
return { risks };
|
||||||
@@ -110,7 +110,7 @@ export const registerSecretScanningRouter = async (server: FastifyZodProvider) =
|
|||||||
const { risk } = await server.services.secretScanning.updateRiskStatus({
|
const { risk } = await server.services.secretScanning.updateRiskStatus({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
riskId: req.params.riskId,
|
riskId: req.params.riskId,
|
||||||
...req.body
|
...req.body
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const registerSecretVersionRouter = async (server: FastifyZodProvider) =>
|
|||||||
const secretVersions = await server.services.secret.getSecretVersions({
|
const secretVersions = await server.services.secret.getSecretVersions({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
limit: req.query.limit,
|
limit: req.query.limit,
|
||||||
offset: req.query.offset,
|
offset: req.query.offset,
|
||||||
secretId: req.params.secretId
|
secretId: req.params.secretId
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const registerSnapshotRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secretSnapshot = await server.services.snapshot.getSnapshotData({
|
const secretSnapshot = await server.services.snapshot.getSnapshotData({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.secretSnapshotId
|
id: req.params.secretSnapshotId
|
||||||
});
|
});
|
||||||
return { secretSnapshot };
|
return { secretSnapshot };
|
||||||
@@ -71,7 +71,7 @@ export const registerSnapshotRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secretSnapshot = await server.services.snapshot.rollbackSnapshot({
|
const secretSnapshot = await server.services.snapshot.rollbackSnapshot({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.secretSnapshotId
|
id: req.params.secretSnapshotId
|
||||||
});
|
});
|
||||||
return { secretSnapshot };
|
return { secretSnapshot };
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const registerTrustedIpRouter = async (server: FastifyZodProvider) => {
|
|||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return { trustedIps };
|
return { trustedIps };
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ export const registerTrustedIpRouter = async (server: FastifyZodProvider) => {
|
|||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
@@ -99,7 +99,7 @@ export const registerTrustedIpRouter = async (server: FastifyZodProvider) => {
|
|||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
trustedIpId: req.params.trustedIpId,
|
trustedIpId: req.params.trustedIpId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -140,7 +140,7 @@ export const registerTrustedIpRouter = async (server: FastifyZodProvider) => {
|
|||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
trustedIpId: req.params.trustedIpId
|
trustedIpId: req.params.trustedIpId
|
||||||
});
|
});
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ export const auditLogServiceFactory = ({
|
|||||||
startDate,
|
startDate,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
auditLogActor
|
auditLogActor
|
||||||
}: TListProjectAuditLogDTO) => {
|
}: TListProjectAuditLogDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.AuditLogs);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.AuditLogs);
|
||||||
const auditLogs = await auditLogDAL.find({
|
const auditLogs = await auditLogDAL.find({
|
||||||
startDate,
|
startDate,
|
||||||
|
|||||||
@@ -175,8 +175,14 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// below all are api calls
|
// below all are api calls
|
||||||
const getOrgPlansTableByBillCycle = async ({ orgId, actor, actorId, actorOrgScope, billingCycle }: TOrgPlansTableDTO) => {
|
const getOrgPlansTableByBillCycle = async ({
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
orgId,
|
||||||
|
actor,
|
||||||
|
actorId,
|
||||||
|
actorOrgId,
|
||||||
|
billingCycle
|
||||||
|
}: TOrgPlansTableDTO) => {
|
||||||
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
const { data } = await licenseServerCloudApi.request.get(
|
const { data } = await licenseServerCloudApi.request.get(
|
||||||
`/api/license-server/v1/cloud-products?billing-cycle=${billingCycle}`
|
`/api/license-server/v1/cloud-products?billing-cycle=${billingCycle}`
|
||||||
@@ -184,15 +190,15 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgPlan = async ({ orgId, actor, actorId, actorOrgScope, projectId }: TOrgPlanDTO) => {
|
const getOrgPlan = async ({ orgId, actor, actorId, actorOrgId, projectId }: TOrgPlanDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
const plan = await getPlan(orgId, projectId);
|
const plan = await getPlan(orgId, projectId);
|
||||||
return plan;
|
return plan;
|
||||||
};
|
};
|
||||||
|
|
||||||
const startOrgTrial = async ({ orgId, actorId, actor, actorOrgScope, success_url }: TStartOrgTrialDTO) => {
|
const startOrgTrial = async ({ orgId, actorId, actor, actorOrgId, success_url }: TStartOrgTrialDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Billing);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
@@ -213,8 +219,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return { url };
|
return { url };
|
||||||
};
|
};
|
||||||
|
|
||||||
const createOrganizationPortalSession = async ({ orgId, actorId, actor, actorOrgScope }: TCreateOrgPortalSession) => {
|
const createOrganizationPortalSession = async ({ orgId, actorId, actor, actorOrgId }: TCreateOrgPortalSession) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Billing);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
@@ -260,8 +266,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return { url };
|
return { url };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgBillingInfo = async ({ orgId, actor, actorId, actorOrgScope }: TGetOrgBillInfoDTO) => {
|
const getOrgBillingInfo = async ({ orgId, actor, actorId, actorOrgId }: TGetOrgBillInfoDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -277,8 +283,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// returns org current plan feature table
|
// returns org current plan feature table
|
||||||
const getOrgPlanTable = async ({ orgId, actor, actorId, actorOrgScope }: TGetOrgBillInfoDTO) => {
|
const getOrgPlanTable = async ({ orgId, actor, actorId, actorOrgId }: TGetOrgBillInfoDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -293,8 +299,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgBillingDetails = async ({ orgId, actor, actorId, actorOrgScope }: TGetOrgBillInfoDTO) => {
|
const getOrgBillingDetails = async ({ orgId, actor, actorId, actorOrgId }: TGetOrgBillInfoDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -310,8 +316,15 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateOrgBillingDetails = async ({ actorId, actor, actorOrgScope, orgId, name, email }: TUpdateOrgBillingDetailsDTO) => {
|
const updateOrgBillingDetails = async ({
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
actorId,
|
||||||
|
actor,
|
||||||
|
actorOrgId,
|
||||||
|
orgId,
|
||||||
|
name,
|
||||||
|
email
|
||||||
|
}: TUpdateOrgBillingDetailsDTO) => {
|
||||||
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -330,8 +343,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgPmtMethods = async ({ orgId, actor, actorId, actorOrgScope }: TOrgPmtMethodsDTO) => {
|
const getOrgPmtMethods = async ({ orgId, actor, actorId, actorOrgId }: TOrgPmtMethodsDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -349,8 +362,15 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return pmtMethods;
|
return pmtMethods;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addOrgPmtMethods = async ({ orgId, actor, actorId, actorOrgScope, success_url, cancel_url }: TAddOrgPmtMethodDTO) => {
|
const addOrgPmtMethods = async ({
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
orgId,
|
||||||
|
actor,
|
||||||
|
actorId,
|
||||||
|
actorOrgId,
|
||||||
|
success_url,
|
||||||
|
cancel_url
|
||||||
|
}: TAddOrgPmtMethodDTO) => {
|
||||||
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -371,8 +391,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return { url };
|
return { url };
|
||||||
};
|
};
|
||||||
|
|
||||||
const delOrgPmtMethods = async ({ actorId, actor, actorOrgScope, orgId, pmtMethodId }: TDelOrgPmtMethodDTO) => {
|
const delOrgPmtMethods = async ({ actorId, actor, actorOrgId, orgId, pmtMethodId }: TDelOrgPmtMethodDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -388,8 +408,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgTaxIds = async ({ orgId, actor, actorId, actorOrgScope }: TGetOrgTaxIdDTO) => {
|
const getOrgTaxIds = async ({ orgId, actor, actorId, actorOrgId }: TGetOrgTaxIdDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -406,8 +426,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return taxIds;
|
return taxIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
const addOrgTaxId = async ({ actorId, actor, actorOrgScope, orgId, type, value }: TAddOrgTaxIdDTO) => {
|
const addOrgTaxId = async ({ actorId, actor, actorOrgId, orgId, type, value }: TAddOrgTaxIdDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -427,8 +447,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const delOrgTaxId = async ({ orgId, actor, actorId, actorOrgScope, taxId }: TDelOrgTaxIdDTO) => {
|
const delOrgTaxId = async ({ orgId, actor, actorId, actorOrgId, taxId }: TDelOrgTaxIdDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -444,8 +464,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgTaxInvoices = async ({ actorId, actor, actorOrgScope, orgId }: TOrgInvoiceDTO) => {
|
const getOrgTaxInvoices = async ({ actorId, actor, actorOrgId, orgId }: TOrgInvoiceDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
@@ -461,8 +481,8 @@ export const licenseServiceFactory = ({ orgDAL, permissionService, licenseDAL }:
|
|||||||
return invoices;
|
return invoices;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgLicenses = async ({ orgId, actor, actorId, actorOrgScope }: TOrgLicensesDTO) => {
|
const getOrgLicenses = async ({ orgId, actor, actorId, actorOrgId }: TOrgLicensesDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Billing);
|
||||||
|
|
||||||
const organization = await orgDAL.findOrgById(orgId);
|
const organization = await orgDAL.findOrgById(orgId);
|
||||||
|
|||||||
@@ -94,13 +94,13 @@ export const permissionServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* Get user permission in an organization
|
* Get user permission in an organization
|
||||||
* */
|
* */
|
||||||
const getUserOrgPermission = async (userId: string, orgId: string, orgScope?: string) => {
|
const getUserOrgPermission = async (userId: string, orgId: string, userOrgId?: string) => {
|
||||||
const membership = await permissionDAL.getOrgPermission(userId, orgId);
|
const membership = await permissionDAL.getOrgPermission(userId, orgId);
|
||||||
if (!membership) throw new UnauthorizedError({ name: "User not in org" });
|
if (!membership) throw new UnauthorizedError({ name: "User not in org" });
|
||||||
if (membership.role === OrgMembershipRole.Custom && !membership.permissions) {
|
if (membership.role === OrgMembershipRole.Custom && !membership.permissions) {
|
||||||
throw new BadRequestError({ name: "Custom permission not found" });
|
throw new BadRequestError({ name: "Custom permission not found" });
|
||||||
}
|
}
|
||||||
if (membership.orgAuthEnforced && membership.orgId !== orgScope) {
|
if (membership.orgAuthEnforced && membership.orgId !== userOrgId) {
|
||||||
throw new BadRequestError({ name: "Cannot access org-scoped resource" });
|
throw new BadRequestError({ name: "Cannot access org-scoped resource" });
|
||||||
}
|
}
|
||||||
return { permission: buildOrgPermission(membership.role, membership.permissions), membership };
|
return { permission: buildOrgPermission(membership.role, membership.permissions), membership };
|
||||||
@@ -115,10 +115,10 @@ export const permissionServiceFactory = ({
|
|||||||
return { permission: buildOrgPermission(membership.role, membership.permissions), membership };
|
return { permission: buildOrgPermission(membership.role, membership.permissions), membership };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgPermission = async (type: ActorType, id: string, orgId: string, orgScope?: string) => {
|
const getOrgPermission = async (type: ActorType, id: string, orgId: string, actorOrgId?: string) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ActorType.USER:
|
case ActorType.USER:
|
||||||
return getUserOrgPermission(id, orgId, orgScope);
|
return getUserOrgPermission(id, orgId, actorOrgId);
|
||||||
case ActorType.IDENTITY:
|
case ActorType.IDENTITY:
|
||||||
return getIdentityOrgPermission(id, orgId);
|
return getIdentityOrgPermission(id, orgId);
|
||||||
default:
|
default:
|
||||||
@@ -145,14 +145,14 @@ export const permissionServiceFactory = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// user permission for a project in an organization
|
// user permission for a project in an organization
|
||||||
const getUserProjectPermission = async (userId: string, projectId: string, orgScope?: string) => {
|
const getUserProjectPermission = async (userId: string, projectId: string, userOrgId?: string) => {
|
||||||
const membership = await permissionDAL.getProjectPermission(userId, projectId);
|
const membership = await permissionDAL.getProjectPermission(userId, projectId);
|
||||||
if (!membership) throw new UnauthorizedError({ name: "User not in project" });
|
if (!membership) throw new UnauthorizedError({ name: "User not in project" });
|
||||||
if (membership.role === ProjectMembershipRole.Custom && !membership.permissions) {
|
if (membership.role === ProjectMembershipRole.Custom && !membership.permissions) {
|
||||||
throw new BadRequestError({ name: "Custom permission not found" });
|
throw new BadRequestError({ name: "Custom permission not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (membership.orgAuthEnforced && membership.orgId !== orgScope) {
|
if (membership.orgAuthEnforced && membership.orgId !== userOrgId) {
|
||||||
throw new BadRequestError({ name: "Cannot access org-scoped resource" });
|
throw new BadRequestError({ name: "Cannot access org-scoped resource" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,11 +203,11 @@ export const permissionServiceFactory = ({
|
|||||||
type: T,
|
type: T,
|
||||||
id: string,
|
id: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
orgScope?: string
|
actorOrgId?: string
|
||||||
): Promise<TProjectPermissionRT<T>> => {
|
): Promise<TProjectPermissionRT<T>> => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ActorType.USER:
|
case ActorType.USER:
|
||||||
return getUserProjectPermission(id, projectId, orgScope) as Promise<TProjectPermissionRT<T>>;
|
return getUserProjectPermission(id, projectId, actorOrgId) as Promise<TProjectPermissionRT<T>>;
|
||||||
case ActorType.SERVICE:
|
case ActorType.SERVICE:
|
||||||
return getServiceTokenProjectPermission(id, projectId) as Promise<TProjectPermissionRT<T>>;
|
return getServiceTokenProjectPermission(id, projectId) as Promise<TProjectPermissionRT<T>>;
|
||||||
case ActorType.IDENTITY:
|
case ActorType.IDENTITY:
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const samlConfigServiceFactory = ({
|
|||||||
const createSamlCfg = async ({
|
const createSamlCfg = async ({
|
||||||
cert,
|
cert,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
orgId,
|
orgId,
|
||||||
issuer,
|
issuer,
|
||||||
actorId,
|
actorId,
|
||||||
@@ -62,7 +62,7 @@ export const samlConfigServiceFactory = ({
|
|||||||
entryPoint,
|
entryPoint,
|
||||||
authProvider
|
authProvider
|
||||||
}: TCreateSamlCfgDTO) => {
|
}: TCreateSamlCfgDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Sso);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Sso);
|
||||||
|
|
||||||
const plan = await licenseService.getPlan(orgId);
|
const plan = await licenseService.getPlan(orgId);
|
||||||
@@ -145,7 +145,7 @@ export const samlConfigServiceFactory = ({
|
|||||||
const updateSamlCfg = async ({
|
const updateSamlCfg = async ({
|
||||||
orgId,
|
orgId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
cert,
|
cert,
|
||||||
actorId,
|
actorId,
|
||||||
issuer,
|
issuer,
|
||||||
@@ -153,7 +153,7 @@ export const samlConfigServiceFactory = ({
|
|||||||
entryPoint,
|
entryPoint,
|
||||||
authProvider
|
authProvider
|
||||||
}: TUpdateSamlCfgDTO) => {
|
}: TUpdateSamlCfgDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso);
|
||||||
const plan = await licenseService.getPlan(orgId);
|
const plan = await licenseService.getPlan(orgId);
|
||||||
if (!plan.samlSSO)
|
if (!plan.samlSSO)
|
||||||
@@ -237,7 +237,7 @@ export const samlConfigServiceFactory = ({
|
|||||||
dto.actor,
|
dto.actor,
|
||||||
dto.actorId,
|
dto.actorId,
|
||||||
ssoConfig.orgId,
|
ssoConfig.orgId,
|
||||||
dto.actorOrgScope
|
dto.actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Sso);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Sso);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ export type TUpdateSamlCfgDTO = Partial<{
|
|||||||
}> &
|
}> &
|
||||||
TOrgPermission;
|
TOrgPermission;
|
||||||
|
|
||||||
export type TGetSamlCfgDTO =
|
export type TGetSamlCfgDTO =
|
||||||
| { type: "org"; orgId: string; actor: ActorType; actorId: string, actorOrgScope?: string }
|
| { type: "org"; orgId: string; actor: ActorType; actorId: string; actorOrgId?: string }
|
||||||
| {
|
| {
|
||||||
type: "orgSlug",
|
type: "orgSlug";
|
||||||
orgSlug: string;
|
orgSlug: string;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
name,
|
name,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
approvals,
|
approvals,
|
||||||
approvers,
|
approvers,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -54,7 +54,7 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
if (approvals > approvers.length)
|
if (approvals > approvers.length)
|
||||||
throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
|
throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
ProjectPermissionSub.SecretApproval
|
ProjectPermissionSub.SecretApproval
|
||||||
@@ -97,7 +97,7 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
name,
|
name,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
approvals,
|
approvals,
|
||||||
secretPolicyId
|
secretPolicyId
|
||||||
}: TUpdateSapDTO) => {
|
}: TUpdateSapDTO) => {
|
||||||
@@ -108,7 +108,7 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
secretApprovalPolicy.projectId,
|
secretApprovalPolicy.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretApproval);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretApproval);
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteSecretApprovalPolicy = async ({ secretPolicyId, actor, actorId, actorOrgScope }: TDeleteSapDTO) => {
|
const deleteSecretApprovalPolicy = async ({ secretPolicyId, actor, actorId, actorOrgId }: TDeleteSapDTO) => {
|
||||||
const sapPolicy = await secretApprovalPolicyDAL.findById(secretPolicyId);
|
const sapPolicy = await secretApprovalPolicyDAL.findById(secretPolicyId);
|
||||||
if (!sapPolicy) throw new BadRequestError({ message: "Secret approval policy not found" });
|
if (!sapPolicy) throw new BadRequestError({ message: "Secret approval policy not found" });
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
sapPolicy.projectId,
|
sapPolicy.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Delete,
|
ProjectPermissionActions.Delete,
|
||||||
@@ -171,8 +171,8 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
return sapPolicy;
|
return sapPolicy;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSecretApprovalPolicyByProjectId = async ({ actorId, actor, actorOrgScope, projectId }: TListSapDTO) => {
|
const getSecretApprovalPolicyByProjectId = async ({ actorId, actor, actorOrgId, projectId }: TListSapDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval);
|
||||||
|
|
||||||
const sapPolicies = await secretApprovalPolicyDAL.find({ projectId });
|
const sapPolicies = await secretApprovalPolicyDAL.find({ projectId });
|
||||||
@@ -200,11 +200,11 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
secretPath
|
secretPath
|
||||||
}: TGetBoardSapDTO) => {
|
}: TGetBoardSapDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
subject(ProjectPermissionSub.Secrets, { secretPath, environment })
|
subject(ProjectPermissionSub.Secrets, { secretPath, environment })
|
||||||
|
|||||||
+14
-19
@@ -73,14 +73,14 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
secretVersionDAL,
|
secretVersionDAL,
|
||||||
secretQueueService
|
secretQueueService
|
||||||
}: TSecretApprovalRequestServiceFactoryDep) => {
|
}: TSecretApprovalRequestServiceFactoryDep) => {
|
||||||
const requestCount = async ({ projectId, actor, actorId, actorOrgScope }: TApprovalRequestCountDTO) => {
|
const requestCount = async ({ projectId, actor, actorId, actorOrgId }: TApprovalRequestCountDTO) => {
|
||||||
if (actor === ActorType.SERVICE) throw new BadRequestError({ message: "Cannot use service token" });
|
if (actor === ActorType.SERVICE) throw new BadRequestError({ message: "Cannot use service token" });
|
||||||
|
|
||||||
const { membership } = await permissionService.getProjectPermission(
|
const { membership } = await permissionService.getProjectPermission(
|
||||||
actor as ActorType.USER,
|
actor as ActorType.USER,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
|
|
||||||
const count = await secretApprovalRequestDAL.findProjectRequestCount(projectId, membership.id);
|
const count = await secretApprovalRequestDAL.findProjectRequestCount(projectId, membership.id);
|
||||||
@@ -91,7 +91,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
status,
|
status,
|
||||||
environment,
|
environment,
|
||||||
committer,
|
committer,
|
||||||
@@ -100,7 +100,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
}: TListApprovalsDTO) => {
|
}: TListApprovalsDTO) => {
|
||||||
if (actor === ActorType.SERVICE) throw new BadRequestError({ message: "Cannot use service token" });
|
if (actor === ActorType.SERVICE) throw new BadRequestError({ message: "Cannot use service token" });
|
||||||
|
|
||||||
const { membership } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { membership } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
const approvals = await secretApprovalRequestDAL.findByProjectId({
|
const approvals = await secretApprovalRequestDAL.findByProjectId({
|
||||||
projectId,
|
projectId,
|
||||||
committer,
|
committer,
|
||||||
@@ -113,7 +113,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
return approvals;
|
return approvals;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSecretApprovalDetails = async ({ actor, actorId, actorOrgScope, id }: TSecretApprovalDetailsDTO) => {
|
const getSecretApprovalDetails = async ({ actor, actorId, actorOrgId, id }: TSecretApprovalDetailsDTO) => {
|
||||||
if (actor === ActorType.SERVICE) throw new BadRequestError({ message: "Cannot use service token" });
|
if (actor === ActorType.SERVICE) throw new BadRequestError({ message: "Cannot use service token" });
|
||||||
|
|
||||||
const secretApprovalRequest = await secretApprovalRequestDAL.findById(id);
|
const secretApprovalRequest = await secretApprovalRequestDAL.findById(id);
|
||||||
@@ -124,7 +124,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
secretApprovalRequest.projectId,
|
secretApprovalRequest.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
membership.role !== ProjectMembershipRole.Admin &&
|
membership.role !== ProjectMembershipRole.Admin &&
|
||||||
@@ -141,7 +141,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
return { ...secretApprovalRequest, secretPath: secretPath?.[0]?.path || "/", commits: secrets };
|
return { ...secretApprovalRequest, secretPath: secretPath?.[0]?.path || "/", commits: secrets };
|
||||||
};
|
};
|
||||||
|
|
||||||
const reviewApproval = async ({ approvalId, actor, status, actorId, actorOrgScope }: TReviewRequestDTO) => {
|
const reviewApproval = async ({ approvalId, actor, status, actorId, actorOrgId }: TReviewRequestDTO) => {
|
||||||
const secretApprovalRequest = await secretApprovalRequestDAL.findById(approvalId);
|
const secretApprovalRequest = await secretApprovalRequestDAL.findById(approvalId);
|
||||||
if (!secretApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
|
if (!secretApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
|
||||||
if (actor !== ActorType.USER) throw new BadRequestError({ message: "Must be a user" });
|
if (actor !== ActorType.USER) throw new BadRequestError({ message: "Must be a user" });
|
||||||
@@ -151,7 +151,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
ActorType.USER,
|
ActorType.USER,
|
||||||
actorId,
|
actorId,
|
||||||
secretApprovalRequest.projectId,
|
secretApprovalRequest.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
membership.role !== ProjectMembershipRole.Admin &&
|
membership.role !== ProjectMembershipRole.Admin &&
|
||||||
@@ -183,7 +183,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
return reviewStatus;
|
return reviewStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateApprovalStatus = async ({ actorId, status, approvalId, actor, actorOrgScope }: TStatusChangeDTO) => {
|
const updateApprovalStatus = async ({ actorId, status, approvalId, actor, actorOrgId }: TStatusChangeDTO) => {
|
||||||
const secretApprovalRequest = await secretApprovalRequestDAL.findById(approvalId);
|
const secretApprovalRequest = await secretApprovalRequestDAL.findById(approvalId);
|
||||||
if (!secretApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
|
if (!secretApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
|
||||||
if (actor !== ActorType.USER) throw new BadRequestError({ message: "Must be a user" });
|
if (actor !== ActorType.USER) throw new BadRequestError({ message: "Must be a user" });
|
||||||
@@ -193,7 +193,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
ActorType.USER,
|
ActorType.USER,
|
||||||
actorId,
|
actorId,
|
||||||
secretApprovalRequest.projectId,
|
secretApprovalRequest.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
membership.role !== ProjectMembershipRole.Admin &&
|
membership.role !== ProjectMembershipRole.Admin &&
|
||||||
@@ -220,19 +220,14 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
approvalId,
|
approvalId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TMergeSecretApprovalRequestDTO) => {
|
}: TMergeSecretApprovalRequestDTO) => {
|
||||||
const secretApprovalRequest = await secretApprovalRequestDAL.findById(approvalId);
|
const secretApprovalRequest = await secretApprovalRequestDAL.findById(approvalId);
|
||||||
if (!secretApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
|
if (!secretApprovalRequest) throw new BadRequestError({ message: "Secret approval request not found" });
|
||||||
if (actor !== ActorType.USER) throw new BadRequestError({ message: "Must be a user" });
|
if (actor !== ActorType.USER) throw new BadRequestError({ message: "Must be a user" });
|
||||||
|
|
||||||
const { policy, folderId, projectId } = secretApprovalRequest;
|
const { policy, folderId, projectId } = secretApprovalRequest;
|
||||||
const { membership } = await permissionService.getProjectPermission(
|
const { membership } = await permissionService.getProjectPermission(ActorType.USER, actorId, projectId, actorOrgId);
|
||||||
ActorType.USER,
|
|
||||||
actorId,
|
|
||||||
projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
membership.role !== ProjectMembershipRole.Admin &&
|
membership.role !== ProjectMembershipRole.Admin &&
|
||||||
secretApprovalRequest.committerId !== membership.id &&
|
secretApprovalRequest.committerId !== membership.id &&
|
||||||
@@ -420,7 +415,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
data,
|
data,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
policy,
|
policy,
|
||||||
projectId,
|
projectId,
|
||||||
secretPath,
|
secretPath,
|
||||||
@@ -432,7 +427,7 @@ export const secretApprovalRequestServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ export const secretRotationServiceFactory = ({
|
|||||||
folderDAL,
|
folderDAL,
|
||||||
secretDAL
|
secretDAL
|
||||||
}: TSecretRotationServiceFactoryDep) => {
|
}: TSecretRotationServiceFactoryDep) => {
|
||||||
const getProviderTemplates = async ({ actor, actorId, actorOrgScope, projectId }: TProjectPermission) => {
|
const getProviderTemplates = async ({ actor, actorId, actorOrgId, projectId }: TProjectPermission) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -53,7 +53,7 @@ export const secretRotationServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
interval,
|
interval,
|
||||||
@@ -61,7 +61,7 @@ export const secretRotationServiceFactory = ({
|
|||||||
secretPath,
|
secretPath,
|
||||||
environment
|
environment
|
||||||
}: TCreateSecretRotationDTO) => {
|
}: TCreateSecretRotationDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
ProjectPermissionSub.SecretRotation
|
ProjectPermissionSub.SecretRotation
|
||||||
@@ -139,14 +139,14 @@ export const secretRotationServiceFactory = ({
|
|||||||
return secretRotation;
|
return secretRotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getByProjectId = async ({ actorId, projectId, actor, actorOrgScope }: TListByProjectIdDTO) => {
|
const getByProjectId = async ({ actorId, projectId, actor, actorOrgId }: TListByProjectIdDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRotation);
|
||||||
const doc = await secretRotationDAL.find({ projectId });
|
const doc = await secretRotationDAL.find({ projectId });
|
||||||
return doc;
|
return doc;
|
||||||
};
|
};
|
||||||
|
|
||||||
const restartById = async ({ actor, actorId, actorOrgScope, rotationId }: TRestartDTO) => {
|
const restartById = async ({ actor, actorId, actorOrgId, rotationId }: TRestartDTO) => {
|
||||||
const doc = await secretRotationDAL.findById(rotationId);
|
const doc = await secretRotationDAL.findById(rotationId);
|
||||||
if (!doc) throw new BadRequestError({ message: "Rotation not found" });
|
if (!doc) throw new BadRequestError({ message: "Rotation not found" });
|
||||||
|
|
||||||
@@ -157,18 +157,18 @@ export const secretRotationServiceFactory = ({
|
|||||||
message: "Failed to add secret rotation due to plan restriction. Upgrade plan to add secret rotation."
|
message: "Failed to add secret rotation due to plan restriction. Upgrade plan to add secret rotation."
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, doc.projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, doc.projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretRotation);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.SecretRotation);
|
||||||
await secretRotationQueue.removeFromQueue(doc.id, doc.interval);
|
await secretRotationQueue.removeFromQueue(doc.id, doc.interval);
|
||||||
await secretRotationQueue.addToQueue(doc.id, doc.interval);
|
await secretRotationQueue.addToQueue(doc.id, doc.interval);
|
||||||
return doc;
|
return doc;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteById = async ({ actor, actorId, actorOrgScope, rotationId }: TDeleteDTO) => {
|
const deleteById = async ({ actor, actorId, actorOrgId, rotationId }: TDeleteDTO) => {
|
||||||
const doc = await secretRotationDAL.findById(rotationId);
|
const doc = await secretRotationDAL.findById(rotationId);
|
||||||
if (!doc) throw new BadRequestError({ message: "Rotation not found" });
|
if (!doc) throw new BadRequestError({ message: "Rotation not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, doc.projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, doc.projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Delete,
|
ProjectPermissionActions.Delete,
|
||||||
ProjectPermissionSub.SecretRotation
|
ProjectPermissionSub.SecretRotation
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ export const secretScanningServiceFactory = ({
|
|||||||
permissionService,
|
permissionService,
|
||||||
secretScanningQueue
|
secretScanningQueue
|
||||||
}: TSecretScanningServiceFactoryDep) => {
|
}: TSecretScanningServiceFactoryDep) => {
|
||||||
const createInstallationSession = async ({ actor, orgId, actorId, actorOrgScope }: TInstallAppSessionDTO) => {
|
const createInstallationSession = async ({ actor, orgId, actorId, actorOrgId }: TInstallAppSessionDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);
|
||||||
|
|
||||||
const sessionId = crypto.randomBytes(16).toString("hex");
|
const sessionId = crypto.randomBytes(16).toString("hex");
|
||||||
@@ -48,11 +48,17 @@ export const secretScanningServiceFactory = ({
|
|||||||
return { sessionId };
|
return { sessionId };
|
||||||
};
|
};
|
||||||
|
|
||||||
const linkInstallationToOrg = async ({ sessionId, actorId, installationId, actor, actorOrgScope }: TLinkInstallSessionDTO) => {
|
const linkInstallationToOrg = async ({
|
||||||
|
sessionId,
|
||||||
|
actorId,
|
||||||
|
installationId,
|
||||||
|
actor,
|
||||||
|
actorOrgId
|
||||||
|
}: TLinkInstallSessionDTO) => {
|
||||||
const session = await gitAppInstallSessionDAL.findOne({ sessionId });
|
const session = await gitAppInstallSessionDAL.findOne({ sessionId });
|
||||||
if (!session) throw new UnauthorizedError({ message: "Session not found" });
|
if (!session) throw new UnauthorizedError({ message: "Session not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, session.orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, session.orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);
|
||||||
const installatedApp = await gitAppOrgDAL.transaction(async (tx) => {
|
const installatedApp = await gitAppOrgDAL.transaction(async (tx) => {
|
||||||
await gitAppInstallSessionDAL.deleteById(session.id, tx);
|
await gitAppInstallSessionDAL.deleteById(session.id, tx);
|
||||||
@@ -83,23 +89,23 @@ export const secretScanningServiceFactory = ({
|
|||||||
return { installatedApp };
|
return { installatedApp };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOrgInstallationStatus = async ({ actorId, orgId, actor, actorOrgScope }: TGetOrgInstallStatusDTO) => {
|
const getOrgInstallationStatus = async ({ actorId, orgId, actor, actorOrgId }: TGetOrgInstallStatusDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
|
||||||
|
|
||||||
const appInstallation = await gitAppOrgDAL.findOne({ orgId });
|
const appInstallation = await gitAppOrgDAL.findOne({ orgId });
|
||||||
return Boolean(appInstallation);
|
return Boolean(appInstallation);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRisksByOrg = async ({ actor, orgId, actorId, actorOrgScope }: TGetOrgRisksDTO) => {
|
const getRisksByOrg = async ({ actor, orgId, actorId, actorOrgId }: TGetOrgRisksDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
|
||||||
const risks = await secretScanningDAL.find({ orgId }, { sort: [["createdAt", "desc"]] });
|
const risks = await secretScanningDAL.find({ orgId }, { sort: [["createdAt", "desc"]] });
|
||||||
return { risks };
|
return { risks };
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateRiskStatus = async ({ actorId, orgId, actor, actorOrgScope, riskId, status }: TUpdateRiskStatusDTO) => {
|
const updateRiskStatus = async ({ actorId, orgId, actor, actorOrgId, riskId, status }: TUpdateRiskStatusDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.SecretScanning);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.SecretScanning);
|
||||||
|
|
||||||
const isRiskResolved = Boolean(
|
const isRiskResolved = Boolean(
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
path
|
path
|
||||||
}: TProjectSnapshotCountDTO) => {
|
}: TProjectSnapshotCountDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
||||||
|
|
||||||
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
||||||
@@ -76,12 +76,12 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
path,
|
path,
|
||||||
limit = 20,
|
limit = 20,
|
||||||
offset = 0
|
offset = 0
|
||||||
}: TProjectSnapshotListDTO) => {
|
}: TProjectSnapshotListDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
||||||
|
|
||||||
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
||||||
@@ -91,15 +91,10 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
return snapshots;
|
return snapshots;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSnapshotData = async ({ actorId, actor, actorOrgScope, id }: TGetSnapshotDataDTO) => {
|
const getSnapshotData = async ({ actorId, actor, actorOrgId, id }: TGetSnapshotDataDTO) => {
|
||||||
const snapshot = await snapshotDAL.findSecretSnapshotDataById(id);
|
const snapshot = await snapshotDAL.findSecretSnapshotDataById(id);
|
||||||
if (!snapshot) throw new BadRequestError({ message: "Snapshot not found" });
|
if (!snapshot) throw new BadRequestError({ message: "Snapshot not found" });
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, snapshot.projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
snapshot.projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
||||||
return snapshot;
|
return snapshot;
|
||||||
};
|
};
|
||||||
@@ -150,16 +145,11 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const rollbackSnapshot = async ({ id: snapshotId, actor, actorId, actorOrgScope }: TRollbackSnapshotDTO) => {
|
const rollbackSnapshot = async ({ id: snapshotId, actor, actorId, actorOrgId }: TRollbackSnapshotDTO) => {
|
||||||
const snapshot = await snapshotDAL.findById(snapshotId);
|
const snapshot = await snapshotDAL.findById(snapshotId);
|
||||||
if (!snapshot) throw new BadRequestError({ message: "Snapshot not found" });
|
if (!snapshot) throw new BadRequestError({ message: "Snapshot not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, snapshot.projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
snapshot.projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
ProjectPermissionSub.SecretRollback
|
ProjectPermissionSub.SecretRollback
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ export const trustedIpServiceFactory = ({
|
|||||||
licenseService,
|
licenseService,
|
||||||
projectDAL
|
projectDAL
|
||||||
}: TTrustedIpServiceFactoryDep) => {
|
}: TTrustedIpServiceFactoryDep) => {
|
||||||
const listIpsByProjectId = async ({ projectId, actor, actorId, actorOrgScope }: TProjectPermission) => {
|
const listIpsByProjectId = async ({ projectId, actor, actorId, actorOrgId }: TProjectPermission) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.IpAllowList);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.IpAllowList);
|
||||||
const trustedIps = await trustedIpDAL.find({
|
const trustedIps = await trustedIpDAL.find({
|
||||||
projectId
|
projectId
|
||||||
@@ -39,12 +39,12 @@ export const trustedIpServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
ipAddress: ip,
|
ipAddress: ip,
|
||||||
comment,
|
comment,
|
||||||
isActive
|
isActive
|
||||||
}: TCreateIpDTO) => {
|
}: TCreateIpDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.IpAllowList);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.IpAllowList);
|
||||||
|
|
||||||
const project = await projectDAL.findById(projectId);
|
const project = await projectDAL.findById(projectId);
|
||||||
@@ -77,12 +77,12 @@ export const trustedIpServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
ipAddress: ip,
|
ipAddress: ip,
|
||||||
comment,
|
comment,
|
||||||
trustedIpId
|
trustedIpId
|
||||||
}: TUpdateIpDTO) => {
|
}: TUpdateIpDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.IpAllowList);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.IpAllowList);
|
||||||
|
|
||||||
const project = await projectDAL.findById(projectId);
|
const project = await projectDAL.findById(projectId);
|
||||||
@@ -113,8 +113,8 @@ export const trustedIpServiceFactory = ({
|
|||||||
return { trustedIp, project }; // for audit log
|
return { trustedIp, project }; // for audit log
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteProjectIp = async ({ projectId, actorId, actor, actorOrgScope, trustedIpId }: TDeleteIpDTO) => {
|
const deleteProjectIp = async ({ projectId, actorId, actor, actorOrgId, trustedIpId }: TDeleteIpDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.IpAllowList);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.IpAllowList);
|
||||||
|
|
||||||
const project = await projectDAL.findById(projectId);
|
const project = await projectDAL.findById(projectId);
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ export type TOrgPermission = {
|
|||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TProjectPermission = {
|
export type TProjectPermission = {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RequiredKeys<T> = {
|
export type RequiredKeys<T> = {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const registerProjectBotRouter = async (server: FastifyZodProvider) => {
|
|||||||
const bot = await server.services.projectBot.findBotByProjectId({
|
const bot = await server.services.projectBot.findBotByProjectId({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.projectId
|
projectId: req.params.projectId
|
||||||
});
|
});
|
||||||
return { bot };
|
return { bot };
|
||||||
@@ -69,7 +69,7 @@ export const registerProjectBotRouter = async (server: FastifyZodProvider) => {
|
|||||||
const bot = await server.services.projectBot.setBotActiveState({
|
const bot = await server.services.projectBot.setBotActiveState({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
botId: req.params.botId,
|
botId: req.params.botId,
|
||||||
botKey: req.body.botKey,
|
botKey: req.body.botKey,
|
||||||
isActive: req.body.isActive
|
isActive: req.body.isActive
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identity = await server.services.identity.createIdentity({
|
const identity = await server.services.identity.createIdentity({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
orgId: req.body.organizationId
|
orgId: req.body.organizationId
|
||||||
});
|
});
|
||||||
@@ -69,7 +69,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identity = await server.services.identity.updateIdentity({
|
const identity = await server.services.identity.updateIdentity({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.identityId,
|
id: req.params.identityId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -108,7 +108,7 @@ export const registerIdentityRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identity = await server.services.identity.deleteIdentity({
|
const identity = await server.services.identity.deleteIdentity({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.identityId
|
id: req.params.identityId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identityUniversalAuth = await server.services.identityUa.attachUa({
|
const identityUniversalAuth = await server.services.identityUa.attachUa({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
identityId: req.params.identityId
|
identityId: req.params.identityId
|
||||||
});
|
});
|
||||||
@@ -179,7 +179,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identityUniversalAuth = await server.services.identityUa.updateUa({
|
const identityUniversalAuth = await server.services.identityUa.updateUa({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
identityId: req.params.identityId
|
identityId: req.params.identityId
|
||||||
});
|
});
|
||||||
@@ -222,7 +222,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identityUniversalAuth = await server.services.identityUa.getIdentityUa({
|
const identityUniversalAuth = await server.services.identityUa.getIdentityUa({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId
|
identityId: req.params.identityId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { clientSecret, clientSecretData, orgId } = await server.services.identityUa.createUaClientSecret({
|
const { clientSecret, clientSecretData, orgId } = await server.services.identityUa.createUaClientSecret({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId,
|
identityId: req.params.identityId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -304,7 +304,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { clientSecrets: clientSecretData, orgId } = await server.services.identityUa.getUaClientSecrets({
|
const { clientSecrets: clientSecretData, orgId } = await server.services.identityUa.getUaClientSecrets({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId
|
identityId: req.params.identityId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ export const registerIdentityUaRouter = async (server: FastifyZodProvider) => {
|
|||||||
const clientSecretData = await server.services.identityUa.revokeUaClientSecret({
|
const clientSecretData = await server.services.identityUa.revokeUaClientSecret({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId,
|
identityId: req.params.identityId,
|
||||||
clientSecretId: req.params.clientSecretId
|
clientSecretId: req.params.clientSecretId
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const integrationAuth = await server.services.integrationAuth.getIntegrationAuth({
|
const integrationAuth = await server.services.integrationAuth.getIntegrationAuth({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId
|
id: req.params.integrationAuthId
|
||||||
});
|
});
|
||||||
return { integrationAuth };
|
return { integrationAuth };
|
||||||
@@ -79,7 +79,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuths({
|
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuths({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
integration: req.query.integration,
|
integration: req.query.integration,
|
||||||
projectId: req.query.projectId
|
projectId: req.query.projectId
|
||||||
});
|
});
|
||||||
@@ -117,7 +117,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuthById({
|
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuthById({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId
|
id: req.params.integrationAuthId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const integrationAuth = await server.services.integrationAuth.oauthExchange({
|
const integrationAuth = await server.services.integrationAuth.oauthExchange({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -200,7 +200,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const integrationAuth = await server.services.integrationAuth.saveIntegrationToken({
|
const integrationAuth = await server.services.integrationAuth.saveIntegrationToken({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -247,7 +247,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const apps = await server.services.integrationAuth.getIntegrationApps({
|
const apps = await server.services.integrationAuth.getIntegrationApps({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
...req.query
|
...req.query
|
||||||
});
|
});
|
||||||
@@ -278,7 +278,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const teams = await server.services.integrationAuth.getIntegrationAuthTeams({
|
const teams = await server.services.integrationAuth.getIntegrationAuthTeams({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId
|
id: req.params.integrationAuthId
|
||||||
});
|
});
|
||||||
return { teams };
|
return { teams };
|
||||||
@@ -306,7 +306,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const branches = await server.services.integrationAuth.getVercelBranches({
|
const branches = await server.services.integrationAuth.getVercelBranches({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
appId: req.query.appId
|
appId: req.query.appId
|
||||||
});
|
});
|
||||||
@@ -335,7 +335,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const groups = await server.services.integrationAuth.getChecklyGroups({
|
const groups = await server.services.integrationAuth.getChecklyGroups({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
accountId: req.query.accountId
|
accountId: req.query.accountId
|
||||||
});
|
});
|
||||||
@@ -361,7 +361,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const orgs = await server.services.integrationAuth.getQoveryOrgs({
|
const orgs = await server.services.integrationAuth.getQoveryOrgs({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId
|
id: req.params.integrationAuthId
|
||||||
});
|
});
|
||||||
return { orgs };
|
return { orgs };
|
||||||
@@ -389,7 +389,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const projects = await server.services.integrationAuth.getQoveryProjects({
|
const projects = await server.services.integrationAuth.getQoveryProjects({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
orgId: req.query.orgId
|
orgId: req.query.orgId
|
||||||
});
|
});
|
||||||
@@ -418,7 +418,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const environments = await server.services.integrationAuth.getQoveryEnvs({
|
const environments = await server.services.integrationAuth.getQoveryEnvs({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
projectId: req.query.projectId
|
projectId: req.query.projectId
|
||||||
});
|
});
|
||||||
@@ -447,7 +447,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const apps = await server.services.integrationAuth.getQoveryApps({
|
const apps = await server.services.integrationAuth.getQoveryApps({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
environmentId: req.query.environmentId
|
environmentId: req.query.environmentId
|
||||||
});
|
});
|
||||||
@@ -476,7 +476,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const containers = await server.services.integrationAuth.getQoveryContainers({
|
const containers = await server.services.integrationAuth.getQoveryContainers({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
environmentId: req.query.environmentId
|
environmentId: req.query.environmentId
|
||||||
});
|
});
|
||||||
@@ -505,7 +505,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const jobs = await server.services.integrationAuth.getQoveryJobs({
|
const jobs = await server.services.integrationAuth.getQoveryJobs({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
environmentId: req.query.environmentId
|
environmentId: req.query.environmentId
|
||||||
});
|
});
|
||||||
@@ -534,7 +534,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const environments = await server.services.integrationAuth.getRailwayEnvironments({
|
const environments = await server.services.integrationAuth.getRailwayEnvironments({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
appId: req.query.appId
|
appId: req.query.appId
|
||||||
});
|
});
|
||||||
@@ -563,7 +563,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const services = await server.services.integrationAuth.getRailwayServices({
|
const services = await server.services.integrationAuth.getRailwayServices({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
appId: req.query.appId
|
appId: req.query.appId
|
||||||
});
|
});
|
||||||
@@ -599,7 +599,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const workspaces = await server.services.integrationAuth.getBitbucketWorkspaces({
|
const workspaces = await server.services.integrationAuth.getBitbucketWorkspaces({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId
|
id: req.params.integrationAuthId
|
||||||
});
|
});
|
||||||
return { workspaces };
|
return { workspaces };
|
||||||
@@ -632,7 +632,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const secretGroups = await server.services.integrationAuth.getNorthFlankSecretGroups({
|
const secretGroups = await server.services.integrationAuth.getNorthFlankSecretGroups({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
appId: req.query.appId
|
appId: req.query.appId
|
||||||
});
|
});
|
||||||
@@ -666,7 +666,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
|||||||
const buildConfigs = await server.services.integrationAuth.getTeamcityBuildConfigs({
|
const buildConfigs = await server.services.integrationAuth.getTeamcityBuildConfigs({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationAuthId,
|
id: req.params.integrationAuthId,
|
||||||
appId: req.query.appId
|
appId: req.query.appId
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { integration, integrationAuth } = await server.services.integration.createIntegration({
|
const { integration, integrationAuth } = await server.services.integration.createIntegration({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
@@ -108,7 +108,7 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
|
|||||||
const integration = await server.services.integration.updateIntegration({
|
const integration = await server.services.integration.updateIntegration({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationId,
|
id: req.params.integrationId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -134,7 +134,7 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => {
|
|||||||
const integration = await server.services.integration.deleteIntegration({
|
const integration = await server.services.integration.deleteIntegration({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.integrationId
|
id: req.params.integrationId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const registerInviteOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
orgId: req.body.organizationId,
|
orgId: req.body.organizationId,
|
||||||
userId: req.permission.id,
|
userId: req.permission.id,
|
||||||
inviteeEmail: req.body.inviteeEmail,
|
inviteeEmail: req.body.inviteeEmail,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
const organization = await server.services.org.updateOrg({
|
const organization = await server.services.org.updateOrg({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
data: req.body
|
data: req.body
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
|
|||||||
const environment = await server.services.projectEnv.createEnvironment({
|
const environment = await server.services.projectEnv.createEnvironment({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -80,7 +80,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { environment, old } = await server.services.projectEnv.updateEnvironment({
|
const { environment, old } = await server.services.projectEnv.updateEnvironment({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
id: req.params.id,
|
id: req.params.id,
|
||||||
...req.body
|
...req.body
|
||||||
@@ -131,7 +131,7 @@ export const registerProjectEnvRouter = async (server: FastifyZodProvider) => {
|
|||||||
const environment = await server.services.projectEnv.deleteEnvironment({
|
const environment = await server.services.projectEnv.deleteEnvironment({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
id: req.params.id
|
id: req.params.id
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const registerProjectKeyRouter = async (server: FastifyZodProvider) => {
|
|||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
nonce: req.body.key.nonce,
|
nonce: req.body.key.nonce,
|
||||||
receiverId: req.body.key.userId,
|
receiverId: req.body.key.userId,
|
||||||
encryptedKey: req.body.key.encryptedKey
|
encryptedKey: req.body.key.encryptedKey
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
|
|||||||
const memberships = await server.services.projectMembership.getProjectMemberships({
|
const memberships = await server.services.projectMembership.getProjectMemberships({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { memberships };
|
return { memberships };
|
||||||
@@ -71,7 +71,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
|
|||||||
const data = await server.services.projectMembership.addUsersToProject({
|
const data = await server.services.projectMembership.addUsersToProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
members: req.body.members
|
members: req.body.members
|
||||||
});
|
});
|
||||||
@@ -114,7 +114,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
|
|||||||
const membership = await server.services.projectMembership.updateProjectMembership({
|
const membership = await server.services.projectMembership.updateProjectMembership({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
membershipId: req.params.membershipId,
|
membershipId: req.params.membershipId,
|
||||||
role: req.body.role
|
role: req.body.role
|
||||||
@@ -156,7 +156,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
|
|||||||
const membership = await server.services.projectMembership.deleteProjectMembership({
|
const membership = await server.services.projectMembership.deleteProjectMembership({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
membershipId: req.params.membershipId
|
membershipId: req.params.membershipId
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const publicKeys = await server.services.projectKey.getProjectPublicKeys({
|
const publicKeys = await server.services.projectKey.getProjectPublicKeys({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { publicKeys };
|
return { publicKeys };
|
||||||
@@ -83,7 +83,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return { users };
|
return { users };
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspace = await server.services.project.getAProject({
|
const workspace = await server.services.project.getAProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { workspace };
|
return { workspace };
|
||||||
@@ -151,7 +151,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
orgId: req.body.organizationId,
|
orgId: req.body.organizationId,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
workspaceName: req.body.workspaceName
|
workspaceName: req.body.workspaceName
|
||||||
});
|
});
|
||||||
return { workspace };
|
return { workspace };
|
||||||
@@ -176,7 +176,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspace = await server.services.project.deleteProject({
|
const workspace = await server.services.project.deleteProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { workspace };
|
return { workspace };
|
||||||
@@ -205,7 +205,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspace = await server.services.project.updateName({
|
const workspace = await server.services.project.updateName({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
name: req.body.name
|
name: req.body.name
|
||||||
});
|
});
|
||||||
@@ -238,7 +238,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspace = await server.services.project.toggleAutoCapitalization({
|
const workspace = await server.services.project.toggleAutoCapitalization({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
autoCapitalization: req.body.autoCapitalization
|
autoCapitalization: req.body.autoCapitalization
|
||||||
});
|
});
|
||||||
@@ -271,7 +271,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { invitee, latestKey } = await server.services.projectMembership.inviteUserToProject({
|
const { invitee, latestKey } = await server.services.projectMembership.inviteUserToProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
email: req.body.email
|
email: req.body.email
|
||||||
});
|
});
|
||||||
@@ -317,7 +317,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const integrations = await server.services.integration.listIntegrationByProject({
|
const integrations = await server.services.integration.listIntegrationByProject({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { integrations };
|
return { integrations };
|
||||||
@@ -342,7 +342,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const authorizations = await server.services.integrationAuth.listIntegrationAuthByProjectId({
|
const authorizations = await server.services.integrationAuth.listIntegrationAuthByProjectId({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { authorizations };
|
return { authorizations };
|
||||||
@@ -367,7 +367,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
const serviceTokenData = await server.services.serviceToken.getProjectServiceTokens({
|
const serviceTokenData = await server.services.serviceToken.getProjectServiceTokens({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.workspaceId
|
projectId: req.params.workspaceId
|
||||||
});
|
});
|
||||||
return { serviceTokenData };
|
return { serviceTokenData };
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
|
|||||||
const folder = await server.services.folder.createFolder({
|
const folder = await server.services.folder.createFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
path
|
path
|
||||||
@@ -81,7 +81,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
|
|||||||
const { folder, old } = await server.services.folder.updateFolder({
|
const { folder, old } = await server.services.folder.updateFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
id: req.params.folderId,
|
id: req.params.folderId,
|
||||||
@@ -131,7 +131,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
|
|||||||
const folder = await server.services.folder.deleteFolder({
|
const folder = await server.services.folder.deleteFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
id: req.params.folderId,
|
id: req.params.folderId,
|
||||||
@@ -177,7 +177,7 @@ export const registerSecretFolderRouter = async (server: FastifyZodProvider) =>
|
|||||||
const folders = await server.services.folder.getFolders({
|
const folders = await server.services.folder.getFolders({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.query,
|
...req.query,
|
||||||
projectId: req.query.workspaceId,
|
projectId: req.query.workspaceId,
|
||||||
path
|
path
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
|||||||
const secretImport = await server.services.secretImport.createImport({
|
const secretImport = await server.services.secretImport.createImport({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
data: req.body.import
|
data: req.body.import
|
||||||
@@ -98,7 +98,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
|||||||
const secretImport = await server.services.secretImport.updateImport({
|
const secretImport = await server.services.secretImport.updateImport({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.secretImportId,
|
id: req.params.secretImportId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
@@ -152,7 +152,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
|||||||
const secretImport = await server.services.secretImport.deleteImport({
|
const secretImport = await server.services.secretImport.deleteImport({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.secretImportId,
|
id: req.params.secretImportId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId
|
projectId: req.body.workspaceId
|
||||||
@@ -204,7 +204,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
|||||||
const secretImports = await server.services.secretImport.getImports({
|
const secretImports = await server.services.secretImport.getImports({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.query,
|
...req.query,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
@@ -257,7 +257,7 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
|||||||
const importedSecrets = await server.services.secretImport.getSecretsFromImports({
|
const importedSecrets = await server.services.secretImport.getSecretsFromImports({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.query,
|
...req.query,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspaceTags = await server.services.secretTag.getProjectTags({
|
const workspaceTags = await server.services.secretTag.getProjectTags({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.projectId
|
projectId: req.params.projectId
|
||||||
});
|
});
|
||||||
return { workspaceTags };
|
return { workspaceTags };
|
||||||
@@ -53,7 +53,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspaceTag = await server.services.secretTag.createTag({
|
const workspaceTag = await server.services.secretTag.createTag({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.projectId,
|
projectId: req.params.projectId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -80,7 +80,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspaceTag = await server.services.secretTag.deleteTag({
|
const workspaceTag = await server.services.secretTag.deleteTag({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.tagId
|
id: req.params.tagId
|
||||||
});
|
});
|
||||||
return { workspaceTag };
|
return { workspaceTag };
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export const registerWebhookRouter = async (server: FastifyZodProvider) => {
|
|||||||
const webhook = await server.services.webhook.createWebhook({
|
const webhook = await server.services.webhook.createWebhook({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
...req.body
|
...req.body
|
||||||
});
|
});
|
||||||
@@ -93,7 +93,7 @@ export const registerWebhookRouter = async (server: FastifyZodProvider) => {
|
|||||||
const webhook = await server.services.webhook.updateWebhook({
|
const webhook = await server.services.webhook.updateWebhook({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.webhookId,
|
id: req.params.webhookId,
|
||||||
isDisabled: req.body.isDisabled
|
isDisabled: req.body.isDisabled
|
||||||
});
|
});
|
||||||
@@ -130,7 +130,7 @@ export const registerWebhookRouter = async (server: FastifyZodProvider) => {
|
|||||||
const webhook = await server.services.webhook.deleteWebhook({
|
const webhook = await server.services.webhook.deleteWebhook({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.webhookId
|
id: req.params.webhookId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ export const registerWebhookRouter = async (server: FastifyZodProvider) => {
|
|||||||
const webhook = await server.services.webhook.testWebhook({
|
const webhook = await server.services.webhook.testWebhook({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.webhookId
|
id: req.params.webhookId
|
||||||
});
|
});
|
||||||
return { message: "Successfully tested webhook", webhook };
|
return { message: "Successfully tested webhook", webhook };
|
||||||
@@ -204,7 +204,7 @@ export const registerWebhookRouter = async (server: FastifyZodProvider) => {
|
|||||||
const webhooks = await server.services.webhook.listWebhooks({
|
const webhooks = await server.services.webhook.listWebhooks({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.query,
|
...req.query,
|
||||||
projectId: req.query.workspaceId
|
projectId: req.query.workspaceId
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const registerIdentityOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
const identityMemberships = await server.services.identity.listOrgIdentities({
|
const identityMemberships = await server.services.identity.listOrgIdentities({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.orgId
|
orgId: req.params.orgId
|
||||||
});
|
});
|
||||||
return { identityMemberships };
|
return { identityMemberships };
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
|
|||||||
const identityMembership = await server.services.identityProject.createProjectIdentity({
|
const identityMembership = await server.services.identityProject.createProjectIdentity({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId,
|
identityId: req.params.identityId,
|
||||||
projectId: req.params.projectId,
|
projectId: req.params.projectId,
|
||||||
role: req.body.role
|
role: req.body.role
|
||||||
@@ -63,7 +63,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
|
|||||||
const identityMembership = await server.services.identityProject.updateProjectIdentity({
|
const identityMembership = await server.services.identityProject.updateProjectIdentity({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId,
|
identityId: req.params.identityId,
|
||||||
projectId: req.params.projectId,
|
projectId: req.params.projectId,
|
||||||
role: req.body.role
|
role: req.body.role
|
||||||
@@ -91,7 +91,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
|
|||||||
const identityMembership = await server.services.identityProject.deleteProjectIdentity({
|
const identityMembership = await server.services.identityProject.deleteProjectIdentity({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
identityId: req.params.identityId,
|
identityId: req.params.identityId,
|
||||||
projectId: req.params.projectId
|
projectId: req.params.projectId
|
||||||
});
|
});
|
||||||
@@ -128,7 +128,7 @@ export const registerIdentityProjectRouter = async (server: FastifyZodProvider)
|
|||||||
const identityMemberships = await server.services.identityProject.listProjectIdentities({
|
const identityMemberships = await server.services.identityProject.listProjectIdentities({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
projectId: req.params.projectId
|
projectId: req.params.projectId
|
||||||
});
|
});
|
||||||
return { identityMemberships };
|
return { identityMemberships };
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
if (req.auth.actor !== ActorType.USER) return;
|
if (req.auth.actor !== ActorType.USER) return;
|
||||||
|
|
||||||
const users = await server.services.org.findAllOrgMembers(
|
const users = await server.services.org.findAllOrgMembers(
|
||||||
req.permission.id,
|
req.permission.id,
|
||||||
req.params.organizationId,
|
req.params.organizationId,
|
||||||
req.permission.orgId
|
req.permission.orgId
|
||||||
);
|
);
|
||||||
@@ -72,7 +72,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
const workspaces = await server.services.org.findAllWorkspaces({
|
const workspaces = await server.services.org.findAllWorkspaces({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
orgId: req.params.organizationId
|
orgId: req.params.organizationId
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
role: req.body.role,
|
role: req.body.role,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
membershipId: req.params.membershipId,
|
membershipId: req.params.membershipId,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return { membership };
|
return { membership };
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
userId: req.permission.id,
|
userId: req.permission.id,
|
||||||
orgId: req.params.organizationId,
|
orgId: req.params.organizationId,
|
||||||
membershipId: req.params.membershipId,
|
membershipId: req.params.membershipId,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return { membership };
|
return { membership };
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
if (req.auth.actor !== ActorType.USER) return;
|
if (req.auth.actor !== ActorType.USER) return;
|
||||||
|
|
||||||
const organization = await server.services.org.deleteOrganizationById(
|
const organization = await server.services.org.deleteOrganizationById(
|
||||||
req.permission.id,
|
req.permission.id,
|
||||||
req.params.organizationId,
|
req.params.organizationId,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
projectId: req.params.workspaceId,
|
projectId: req.params.workspaceId,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.services.auditLog.createAuditLog({
|
await server.services.auditLog.createAuditLog({
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export const registerServiceTokenRouter = async (server: FastifyZodProvider) =>
|
|||||||
const { serviceToken, token } = await server.services.serviceToken.createServiceToken({
|
const { serviceToken, token } = await server.services.serviceToken.createServiceToken({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
...req.body,
|
...req.body,
|
||||||
projectId: req.body.workspaceId
|
projectId: req.body.workspaceId
|
||||||
});
|
});
|
||||||
@@ -130,7 +130,7 @@ export const registerServiceTokenRouter = async (server: FastifyZodProvider) =>
|
|||||||
const serviceTokenData = await server.services.serviceToken.deleteServiceToken({
|
const serviceTokenData = await server.services.serviceToken.deleteServiceToken({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
id: req.params.serviceTokenId
|
id: req.params.serviceTokenId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const registerSecretBlindIndexRouter = async (server: FastifyZodProvider)
|
|||||||
projectId: req.params.projectId,
|
projectId: req.params.projectId,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return count === 0;
|
return count === 0;
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ export const registerSecretBlindIndexRouter = async (server: FastifyZodProvider)
|
|||||||
projectId: req.params.projectId,
|
projectId: req.params.projectId,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return { secrets };
|
return { secrets };
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ export const registerSecretBlindIndexRouter = async (server: FastifyZodProvider)
|
|||||||
secretsToUpdate: req.body.secretsToUpdate,
|
secretsToUpdate: req.body.secretsToUpdate,
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId
|
actorOrgId: req.permission.orgId
|
||||||
});
|
});
|
||||||
return { message: "Successfully named workspace secrets" };
|
return { message: "Successfully named workspace secrets" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { secrets, imports } = await server.services.secret.getSecretsRaw({
|
const { secrets, imports } = await server.services.secret.getSecretsRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment,
|
environment,
|
||||||
projectId: workspaceId,
|
projectId: workspaceId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
@@ -159,7 +159,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.getSecretByNameRaw({
|
const secret = await server.services.secret.getSecretByNameRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment,
|
environment,
|
||||||
projectId: workspaceId,
|
projectId: workspaceId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
@@ -227,7 +227,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.createSecretRaw({
|
const secret = await server.services.secret.createSecretRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment: req.body.environment,
|
environment: req.body.environment,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
secretPath: req.body.secretPath,
|
secretPath: req.body.secretPath,
|
||||||
@@ -296,7 +296,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.updateSecretRaw({
|
const secret = await server.services.secret.updateSecretRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment: req.body.environment,
|
environment: req.body.environment,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
secretPath: req.body.secretPath,
|
secretPath: req.body.secretPath,
|
||||||
@@ -361,7 +361,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.deleteSecretRaw({
|
const secret = await server.services.secret.deleteSecretRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment: req.body.environment,
|
environment: req.body.environment,
|
||||||
projectId: req.body.workspaceId,
|
projectId: req.body.workspaceId,
|
||||||
secretPath: req.body.secretPath,
|
secretPath: req.body.secretPath,
|
||||||
@@ -456,7 +456,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const { secrets, imports } = await server.services.secret.getSecrets({
|
const { secrets, imports } = await server.services.secret.getSecrets({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment: req.query.environment,
|
environment: req.query.environment,
|
||||||
projectId: req.query.workspaceId,
|
projectId: req.query.workspaceId,
|
||||||
path: req.query.secretPath,
|
path: req.query.secretPath,
|
||||||
@@ -542,7 +542,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.getSecretByName({
|
const secret = await server.services.secret.getSecretByName({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
environment: req.query.environment,
|
environment: req.query.environment,
|
||||||
projectId: req.query.workspaceId,
|
projectId: req.query.workspaceId,
|
||||||
path: req.query.secretPath,
|
path: req.query.secretPath,
|
||||||
@@ -653,7 +653,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -696,7 +696,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.createSecret({
|
const secret = await server.services.secret.createSecret({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
type,
|
type,
|
||||||
environment: req.body.environment,
|
environment: req.body.environment,
|
||||||
@@ -820,7 +820,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId
|
projectId
|
||||||
@@ -829,7 +829,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -874,7 +874,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.updateSecret({
|
const secret = await server.services.secret.updateSecret({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
type,
|
type,
|
||||||
environment,
|
environment,
|
||||||
@@ -964,7 +964,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId
|
projectId
|
||||||
@@ -973,7 +973,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -1006,7 +1006,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secret = await server.services.secret.deleteSecret({
|
const secret = await server.services.secret.deleteSecret({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
type,
|
type,
|
||||||
environment,
|
environment,
|
||||||
@@ -1089,7 +1089,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId
|
projectId
|
||||||
@@ -1098,7 +1098,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -1127,7 +1127,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secrets = await server.services.secret.createManySecret({
|
const secrets = await server.services.secret.createManySecret({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -1210,7 +1210,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId
|
projectId
|
||||||
@@ -1219,7 +1219,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -1247,7 +1247,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secrets = await server.services.secret.updateManySecret({
|
const secrets = await server.services.secret.updateManySecret({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -1319,7 +1319,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
const policy = await server.services.secretApprovalPolicy.getSecretApprovalPolicyOfFolder({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId
|
projectId
|
||||||
@@ -1328,7 +1328,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
const approval = await server.services.secretApprovalRequest.generateSecretApprovalRequest({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
secretPath,
|
secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -1355,7 +1355,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
const secrets = await server.services.secret.deleteManySecret({
|
const secrets = await server.services.secret.deleteManySecret({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
actorOrgScope: req.permission.orgId,
|
actorOrgId: req.permission.orgId,
|
||||||
path: req.body.secretPath,
|
path: req.body.secretPath,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ export const identityProjectServiceFactory = ({
|
|||||||
identityId,
|
identityId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
role
|
role
|
||||||
}: TCreateProjectIdentityDTO) => {
|
}: TCreateProjectIdentityDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Identity);
|
||||||
|
|
||||||
const existingIdentity = await identityProjectDAL.findOne({ identityId, projectId });
|
const existingIdentity = await identityProjectDAL.findOne({ identityId, projectId });
|
||||||
@@ -85,9 +85,9 @@ export const identityProjectServiceFactory = ({
|
|||||||
role,
|
role,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TUpdateProjectIdentityDTO) => {
|
}: TUpdateProjectIdentityDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Identity);
|
||||||
|
|
||||||
const projectIdentity = await identityProjectDAL.findOne({ identityId, projectId });
|
const projectIdentity = await identityProjectDAL.findOne({ identityId, projectId });
|
||||||
@@ -100,7 +100,7 @@ export const identityProjectServiceFactory = ({
|
|||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
projectIdentity.identityId,
|
projectIdentity.identityId,
|
||||||
projectIdentity.projectId,
|
projectIdentity.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
|
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
|
||||||
if (!hasRequiredPriviledges)
|
if (!hasRequiredPriviledges)
|
||||||
@@ -134,7 +134,7 @@ export const identityProjectServiceFactory = ({
|
|||||||
identityId,
|
identityId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId
|
projectId
|
||||||
}: TDeleteProjectIdentityDTO) => {
|
}: TDeleteProjectIdentityDTO) => {
|
||||||
const identityProjectMembership = await identityProjectDAL.findOne({ identityId, projectId });
|
const identityProjectMembership = await identityProjectDAL.findOne({ identityId, projectId });
|
||||||
@@ -145,14 +145,14 @@ export const identityProjectServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityProjectMembership.projectId,
|
identityProjectMembership.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Identity);
|
||||||
const { permission: identityRolePermission } = await permissionService.getProjectPermission(
|
const { permission: identityRolePermission } = await permissionService.getProjectPermission(
|
||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
identityId,
|
identityId,
|
||||||
identityProjectMembership.projectId,
|
identityProjectMembership.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
|
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
|
||||||
if (!hasRequiredPriviledges)
|
if (!hasRequiredPriviledges)
|
||||||
@@ -162,8 +162,8 @@ export const identityProjectServiceFactory = ({
|
|||||||
return deletedIdentity;
|
return deletedIdentity;
|
||||||
};
|
};
|
||||||
|
|
||||||
const listProjectIdentities = async ({ projectId, actor, actorId, actorOrgScope }: TListProjectIdentityDTO) => {
|
const listProjectIdentities = async ({ projectId, actor, actorId, actorOrgId }: TListProjectIdentityDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Identity);
|
||||||
|
|
||||||
const identityMemberhips = await identityProjectDAL.findByProjectId(projectId);
|
const identityMemberhips = await identityProjectDAL.findByProjectId(projectId);
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ export const identityUaServiceFactory = ({
|
|||||||
clientSecretTrustedIps,
|
clientSecretTrustedIps,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TAttachUaDTO) => {
|
}: TAttachUaDTO) => {
|
||||||
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
||||||
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
||||||
@@ -157,7 +157,7 @@ export const identityUaServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ export const identityUaServiceFactory = ({
|
|||||||
clientSecretTrustedIps,
|
clientSecretTrustedIps,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TUpdateUaDTO) => {
|
}: TUpdateUaDTO) => {
|
||||||
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
||||||
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
||||||
@@ -251,7 +251,7 @@ export const identityUaServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ export const identityUaServiceFactory = ({
|
|||||||
return { ...updatedUaAuth, orgId: identityMembershipOrg.orgId };
|
return { ...updatedUaAuth, orgId: identityMembershipOrg.orgId };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getIdentityUa = async ({ identityId, actorId, actor, actorOrgScope }: TGetUaDTO) => {
|
const getIdentityUa = async ({ identityId, actorId, actor, actorOrgId }: TGetUaDTO) => {
|
||||||
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
||||||
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
||||||
if (identityMembershipOrg.identity?.authMethod !== IdentityAuthMethod.Univeral)
|
if (identityMembershipOrg.identity?.authMethod !== IdentityAuthMethod.Univeral)
|
||||||
@@ -317,7 +317,7 @@ export const identityUaServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
||||||
return { ...uaIdentityAuth, orgId: identityMembershipOrg.orgId };
|
return { ...uaIdentityAuth, orgId: identityMembershipOrg.orgId };
|
||||||
@@ -326,7 +326,7 @@ export const identityUaServiceFactory = ({
|
|||||||
const createUaClientSecret = async ({
|
const createUaClientSecret = async ({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
identityId,
|
identityId,
|
||||||
ttl,
|
ttl,
|
||||||
description,
|
description,
|
||||||
@@ -342,7 +342,7 @@ export const identityUaServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ export const identityUaServiceFactory = ({
|
|||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
identityMembershipOrg.identityId,
|
identityMembershipOrg.identityId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
||||||
if (!hasPriviledge)
|
if (!hasPriviledge)
|
||||||
@@ -383,7 +383,7 @@ export const identityUaServiceFactory = ({
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUaClientSecrets = async ({ actor, actorId, actorOrgScope, identityId }: TGetUaClientSecretsDTO) => {
|
const getUaClientSecrets = async ({ actor, actorId, actorOrgId, identityId }: TGetUaClientSecretsDTO) => {
|
||||||
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
||||||
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
if (!identityMembershipOrg) throw new BadRequestError({ message: "Failed to find identity" });
|
||||||
if (identityMembershipOrg.identity?.authMethod !== IdentityAuthMethod.Univeral)
|
if (identityMembershipOrg.identity?.authMethod !== IdentityAuthMethod.Univeral)
|
||||||
@@ -394,7 +394,7 @@ export const identityUaServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ export const identityUaServiceFactory = ({
|
|||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
identityMembershipOrg.identityId,
|
identityMembershipOrg.identityId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
||||||
if (!hasPriviledge)
|
if (!hasPriviledge)
|
||||||
@@ -425,7 +425,7 @@ export const identityUaServiceFactory = ({
|
|||||||
identityId,
|
identityId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
clientSecretId
|
clientSecretId
|
||||||
}: TRevokeUaClientSecretDTO) => {
|
}: TRevokeUaClientSecretDTO) => {
|
||||||
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
const identityMembershipOrg = await identityOrgMembershipDAL.findOne({ identityId });
|
||||||
@@ -438,7 +438,7 @@ export const identityUaServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ export const identityUaServiceFactory = ({
|
|||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
identityMembershipOrg.identityId,
|
identityMembershipOrg.identityId,
|
||||||
identityMembershipOrg.orgId,
|
identityMembershipOrg.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
|
||||||
if (!hasPriviledge)
|
if (!hasPriviledge)
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ export const identityServiceFactory = ({
|
|||||||
identityOrgMembershipDAL,
|
identityOrgMembershipDAL,
|
||||||
permissionService
|
permissionService
|
||||||
}: TIdentityServiceFactoryDep) => {
|
}: TIdentityServiceFactoryDep) => {
|
||||||
const createIdentity = async ({ name, role, actor, orgId, actorId, actorOrgScope }: TCreateIdentityDTO) => {
|
const createIdentity = async ({ name, role, actor, orgId, actorId, actorOrgId }: TCreateIdentityDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
const { permission: rolePermission, role: customRole } = await permissionService.getOrgPermissionByRole(
|
const { permission: rolePermission, role: customRole } = await permissionService.getOrgPermissionByRole(
|
||||||
@@ -54,18 +54,23 @@ export const identityServiceFactory = ({
|
|||||||
return identity;
|
return identity;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateIdentity = async ({ id, role, name, actor, actorId, actorOrgScope }: TUpdateIdentityDTO) => {
|
const updateIdentity = async ({ id, role, name, actor, actorId, actorOrgId }: TUpdateIdentityDTO) => {
|
||||||
const identityOrgMembership = await identityOrgMembershipDAL.findOne({ identityId: id });
|
const identityOrgMembership = await identityOrgMembershipDAL.findOne({ identityId: id });
|
||||||
if (!identityOrgMembership) throw new BadRequestError({ message: `Failed to find identity with id ${id}` });
|
if (!identityOrgMembership) throw new BadRequestError({ message: `Failed to find identity with id ${id}` });
|
||||||
|
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, identityOrgMembership.orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(
|
||||||
|
actor,
|
||||||
|
actorId,
|
||||||
|
identityOrgMembership.orgId,
|
||||||
|
actorOrgId
|
||||||
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
const { permission: identityRolePermission } = await permissionService.getOrgPermission(
|
const { permission: identityRolePermission } = await permissionService.getOrgPermission(
|
||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
id,
|
id,
|
||||||
identityOrgMembership.orgId,
|
identityOrgMembership.orgId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
|
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
|
||||||
if (!hasRequiredPriviledges)
|
if (!hasRequiredPriviledges)
|
||||||
@@ -103,11 +108,16 @@ export const identityServiceFactory = ({
|
|||||||
return { ...identity, orgId: identityOrgMembership.orgId };
|
return { ...identity, orgId: identityOrgMembership.orgId };
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteIdentity = async ({ actorId, actor, actorOrgScope, id }: TDeleteIdentityDTO) => {
|
const deleteIdentity = async ({ actorId, actor, actorOrgId, id }: TDeleteIdentityDTO) => {
|
||||||
const identityOrgMembership = await identityOrgMembershipDAL.findOne({ identityId: id });
|
const identityOrgMembership = await identityOrgMembershipDAL.findOne({ identityId: id });
|
||||||
if (!identityOrgMembership) throw new BadRequestError({ message: `Failed to find identity with id ${id}` });
|
if (!identityOrgMembership) throw new BadRequestError({ message: `Failed to find identity with id ${id}` });
|
||||||
|
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, identityOrgMembership.orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(
|
||||||
|
actor,
|
||||||
|
actorId,
|
||||||
|
identityOrgMembership.orgId,
|
||||||
|
actorOrgId
|
||||||
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Identity);
|
||||||
const { permission: identityRolePermission } = await permissionService.getOrgPermission(
|
const { permission: identityRolePermission } = await permissionService.getOrgPermission(
|
||||||
ActorType.IDENTITY,
|
ActorType.IDENTITY,
|
||||||
@@ -122,8 +132,8 @@ export const identityServiceFactory = ({
|
|||||||
return { ...deletedIdentity, orgId: identityOrgMembership.orgId };
|
return { ...deletedIdentity, orgId: identityOrgMembership.orgId };
|
||||||
};
|
};
|
||||||
|
|
||||||
const listOrgIdentities = async ({ orgId, actor, actorId, actorOrgScope }: TOrgPermission) => {
|
const listOrgIdentities = async ({ orgId, actor, actorId, actorOrgId }: TOrgPermission) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Identity);
|
||||||
|
|
||||||
const identityMemberhips = await identityOrgMembershipDAL.findByOrgId(orgId);
|
const identityMemberhips = await identityOrgMembershipDAL.findByOrgId(orgId);
|
||||||
|
|||||||
@@ -59,14 +59,14 @@ export const integrationAuthServiceFactory = ({
|
|||||||
projectBotDAL,
|
projectBotDAL,
|
||||||
projectBotService
|
projectBotService
|
||||||
}: TIntegrationAuthServiceFactoryDep) => {
|
}: TIntegrationAuthServiceFactoryDep) => {
|
||||||
const listIntegrationAuthByProjectId = async ({ actorId, actor, actorOrgScope, projectId }: TProjectPermission) => {
|
const listIntegrationAuthByProjectId = async ({ actorId, actor, actorOrgId, projectId }: TProjectPermission) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const authorizations = await integrationAuthDAL.find({ projectId });
|
const authorizations = await integrationAuthDAL.find({ projectId });
|
||||||
return authorizations;
|
return authorizations;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getIntegrationAuth = async ({ actor, id, actorId, actorOrgScope }: TGetIntegrationAuthDTO) => {
|
const getIntegrationAuth = async ({ actor, id, actorId, actorOrgId }: TGetIntegrationAuthDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
return integrationAuth;
|
return integrationAuth;
|
||||||
@@ -84,7 +84,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
integration,
|
integration,
|
||||||
url,
|
url,
|
||||||
code
|
code
|
||||||
@@ -92,7 +92,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
if (!Object.values(Integrations).includes(integration as Integrations))
|
if (!Object.values(Integrations).includes(integration as Integrations))
|
||||||
throw new BadRequestError({ message: "Invalid integration" });
|
throw new BadRequestError({ message: "Invalid integration" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
const bot = await projectBotDAL.findOne({ isActive: true, projectId });
|
const bot = await projectBotDAL.findOne({ isActive: true, projectId });
|
||||||
@@ -147,7 +147,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
integration,
|
integration,
|
||||||
url,
|
url,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
accessId,
|
accessId,
|
||||||
namespace,
|
namespace,
|
||||||
accessToken
|
accessToken
|
||||||
@@ -155,7 +155,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
if (!Object.values(Integrations).includes(integration as Integrations))
|
if (!Object.values(Integrations).includes(integration as Integrations))
|
||||||
throw new BadRequestError({ message: "Invalid integration" });
|
throw new BadRequestError({ message: "Invalid integration" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
const bot = await projectBotDAL.findOne({ isActive: true, projectId });
|
const bot = await projectBotDAL.findOne({ isActive: true, projectId });
|
||||||
@@ -271,7 +271,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
const getIntegrationApps = async ({
|
const getIntegrationApps = async ({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
teamId,
|
teamId,
|
||||||
id,
|
id,
|
||||||
workspaceSlug
|
workspaceSlug
|
||||||
@@ -283,7 +283,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return apps;
|
return apps;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getIntegrationAuthTeams = async ({ actor, actorId, actorOrgScope, id }: TIntegrationAuthTeamsDTO) => {
|
const getIntegrationAuthTeams = async ({ actor, actorId, actorOrgId, id }: TIntegrationAuthTeamsDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return teams;
|
return teams;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getVercelBranches = async ({ appId, id, actor, actorId, actorOrgScope }: TIntegrationAuthVercelBranchesDTO) => {
|
const getVercelBranches = async ({ appId, id, actor, actorId, actorOrgId }: TIntegrationAuthVercelBranchesDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -355,13 +355,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getChecklyGroups = async ({
|
const getChecklyGroups = async ({ actorId, actor, actorOrgId, id, accountId }: TIntegrationAuthChecklyGroupsDTO) => {
|
||||||
actorId,
|
|
||||||
actor,
|
|
||||||
actorOrgScope,
|
|
||||||
id,
|
|
||||||
accountId
|
|
||||||
}: TIntegrationAuthChecklyGroupsDTO) => {
|
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -369,7 +363,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -387,7 +381,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getQoveryOrgs = async ({ actorId, actor, actorOrgScope, id }: TIntegrationAuthQoveryOrgsDTO) => {
|
const getQoveryOrgs = async ({ actorId, actor, actorOrgId, id }: TIntegrationAuthQoveryOrgsDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -395,7 +389,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -413,7 +407,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return data.results.map(({ name, id: orgId }) => ({ name, orgId }));
|
return data.results.map(({ name, id: orgId }) => ({ name, orgId }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const getQoveryProjects = async ({ actorId, actor, actorOrgScope, id, orgId }: TIntegrationAuthQoveryProjectDTO) => {
|
const getQoveryProjects = async ({ actorId, actor, actorOrgId, id, orgId }: TIntegrationAuthQoveryProjectDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -421,7 +415,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -446,7 +440,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
id,
|
id,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TIntegrationAuthQoveryEnvironmentsDTO) => {
|
}: TIntegrationAuthQoveryEnvironmentsDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
@@ -455,7 +449,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -480,13 +474,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getQoveryApps = async ({
|
const getQoveryApps = async ({ id, actor, actorId, actorOrgId, environmentId }: TIntegrationAuthQoveryScopesDTO) => {
|
||||||
id,
|
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
actorOrgScope,
|
|
||||||
environmentId
|
|
||||||
}: TIntegrationAuthQoveryScopesDTO) => {
|
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -494,7 +482,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -522,7 +510,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
id,
|
id,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environmentId
|
environmentId
|
||||||
}: TIntegrationAuthQoveryScopesDTO) => {
|
}: TIntegrationAuthQoveryScopesDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
@@ -532,7 +520,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -556,13 +544,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getQoveryJobs = async ({
|
const getQoveryJobs = async ({ id, actor, actorId, actorOrgId, environmentId }: TIntegrationAuthQoveryScopesDTO) => {
|
||||||
id,
|
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
actorOrgScope,
|
|
||||||
environmentId
|
|
||||||
}: TIntegrationAuthQoveryScopesDTO) => {
|
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -570,7 +552,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -594,13 +576,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRailwayEnvironments = async ({
|
const getRailwayEnvironments = async ({ id, actor, actorId, actorOrgId, appId }: TIntegrationAuthRailwayEnvDTO) => {
|
||||||
id,
|
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
actorOrgScope,
|
|
||||||
appId
|
|
||||||
}: TIntegrationAuthRailwayEnvDTO) => {
|
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -608,7 +584,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -660,13 +636,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRailwayServices = async ({
|
const getRailwayServices = async ({ id, actor, actorId, actorOrgId, appId }: TIntegrationAuthRailwayServicesDTO) => {
|
||||||
id,
|
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
actorOrgScope,
|
|
||||||
appId
|
|
||||||
}: TIntegrationAuthRailwayServicesDTO) => {
|
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -674,7 +644,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -744,12 +714,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBitbucketWorkspaces = async ({
|
const getBitbucketWorkspaces = async ({ actorId, actor, actorOrgId, id }: TIntegrationAuthBitbucketWorkspaceDTO) => {
|
||||||
actorId,
|
|
||||||
actor,
|
|
||||||
actorOrgScope,
|
|
||||||
id
|
|
||||||
}: TIntegrationAuthBitbucketWorkspaceDTO) => {
|
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -757,7 +722,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -796,7 +761,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
id,
|
id,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
appId
|
appId
|
||||||
}: TIntegrationAuthNorthflankSecretGroupDTO) => {
|
}: TIntegrationAuthNorthflankSecretGroupDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
@@ -806,7 +771,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -862,7 +827,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
appId,
|
appId,
|
||||||
id,
|
id,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
actor
|
actor
|
||||||
}: TGetIntegrationAuthTeamCityBuildConfigDTO) => {
|
}: TGetIntegrationAuthTeamCityBuildConfigDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
@@ -872,7 +837,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
const botKey = await projectBotService.getBotKey(integrationAuth.projectId);
|
||||||
@@ -903,16 +868,16 @@ export const integrationAuthServiceFactory = ({
|
|||||||
integration,
|
integration,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TDeleteIntegrationAuthsDTO) => {
|
}: TDeleteIntegrationAuthsDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
const integrations = await integrationAuthDAL.delete({ integration, projectId });
|
const integrations = await integrationAuthDAL.delete({ integration, projectId });
|
||||||
return integrations;
|
return integrations;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteIntegrationAuthById = async ({ id, actorId, actor, actorOrgScope }: TDeleteIntegrationAuthByIdDTO) => {
|
const deleteIntegrationAuthById = async ({ id, actorId, actor, actorOrgId }: TDeleteIntegrationAuthByIdDTO) => {
|
||||||
const integrationAuth = await integrationAuthDAL.findById(id);
|
const integrationAuth = await integrationAuthDAL.findById(id);
|
||||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||||
|
|
||||||
@@ -920,7 +885,7 @@ export const integrationAuthServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const integrationServiceFactory = ({
|
|||||||
const createIntegration = async ({
|
const createIntegration = async ({
|
||||||
app,
|
app,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
path,
|
path,
|
||||||
appId,
|
appId,
|
||||||
owner,
|
owner,
|
||||||
@@ -55,7 +55,7 @@ export const integrationServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integrationAuth.projectId,
|
integrationAuth.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ export const integrationServiceFactory = ({
|
|||||||
const updateIntegration = async ({
|
const updateIntegration = async ({
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
targetEnvironment,
|
targetEnvironment,
|
||||||
app,
|
app,
|
||||||
id,
|
id,
|
||||||
@@ -109,7 +109,7 @@ export const integrationServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integration.projectId,
|
integration.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ export const integrationServiceFactory = ({
|
|||||||
return updatedIntegration;
|
return updatedIntegration;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteIntegration = async ({ actorId, id, actor, actorOrgScope }: TDeleteIntegrationDTO) => {
|
const deleteIntegration = async ({ actorId, id, actor, actorOrgId }: TDeleteIntegrationDTO) => {
|
||||||
const integration = await integrationDAL.findById(id);
|
const integration = await integrationDAL.findById(id);
|
||||||
if (!integration) throw new BadRequestError({ message: "Integration auth not found" });
|
if (!integration) throw new BadRequestError({ message: "Integration auth not found" });
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ export const integrationServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
integration.projectId,
|
integration.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
@@ -145,8 +145,8 @@ export const integrationServiceFactory = ({
|
|||||||
return { ...integration, ...deletedIntegration };
|
return { ...integration, ...deletedIntegration };
|
||||||
};
|
};
|
||||||
|
|
||||||
const listIntegrationByProject = async ({ actor, actorId, actorOrgScope, projectId }: TProjectPermission) => {
|
const listIntegrationByProject = async ({ actor, actorId, actorOrgId, projectId }: TProjectPermission) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
const integrations = await integrationDAL.findByProjectId(projectId);
|
const integrations = await integrationDAL.findByProjectId(projectId);
|
||||||
|
|||||||
@@ -22,8 +22,13 @@ type TOrgRoleServiceFactoryDep = {
|
|||||||
export type TOrgRoleServiceFactory = ReturnType<typeof orgRoleServiceFactory>;
|
export type TOrgRoleServiceFactory = ReturnType<typeof orgRoleServiceFactory>;
|
||||||
|
|
||||||
export const orgRoleServiceFactory = ({ orgRoleDAL, permissionService }: TOrgRoleServiceFactoryDep) => {
|
export const orgRoleServiceFactory = ({ orgRoleDAL, permissionService }: TOrgRoleServiceFactoryDep) => {
|
||||||
const createRole = async (userId: string, orgId: string, data: Omit<TOrgRolesInsert, "orgId">, actorOrgScope?: string) => {
|
const createRole = async (
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
userId: string,
|
||||||
|
orgId: string,
|
||||||
|
data: Omit<TOrgRolesInsert, "orgId">,
|
||||||
|
actorOrgId?: string
|
||||||
|
) => {
|
||||||
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Role);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Role);
|
||||||
const existingRole = await orgRoleDAL.findOne({ slug: data.slug, orgId });
|
const existingRole = await orgRoleDAL.findOne({ slug: data.slug, orgId });
|
||||||
if (existingRole) throw new BadRequestError({ name: "Create Role", message: "Duplicate role" });
|
if (existingRole) throw new BadRequestError({ name: "Create Role", message: "Duplicate role" });
|
||||||
@@ -35,8 +40,14 @@ export const orgRoleServiceFactory = ({ orgRoleDAL, permissionService }: TOrgRol
|
|||||||
return role;
|
return role;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateRole = async (userId: string, orgId: string, roleId: string, data: Omit<TOrgRolesUpdate, "orgId">, actorOrgScope?: string) => {
|
const updateRole = async (
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
userId: string,
|
||||||
|
orgId: string,
|
||||||
|
roleId: string,
|
||||||
|
data: Omit<TOrgRolesUpdate, "orgId">,
|
||||||
|
actorOrgId?: string
|
||||||
|
) => {
|
||||||
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Role);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Role);
|
||||||
if (data?.slug) {
|
if (data?.slug) {
|
||||||
const existingRole = await orgRoleDAL.findOne({ slug: data.slug, orgId });
|
const existingRole = await orgRoleDAL.findOne({ slug: data.slug, orgId });
|
||||||
@@ -51,8 +62,8 @@ export const orgRoleServiceFactory = ({ orgRoleDAL, permissionService }: TOrgRol
|
|||||||
return updatedRole;
|
return updatedRole;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteRole = async (userId: string, orgId: string, roleId: string, actorOrgScope?: string) => {
|
const deleteRole = async (userId: string, orgId: string, roleId: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Role);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Role);
|
||||||
const [deletedRole] = await orgRoleDAL.delete({ id: roleId, orgId });
|
const [deletedRole] = await orgRoleDAL.delete({ id: roleId, orgId });
|
||||||
if (!deleteRole) throw new BadRequestError({ message: "Role not found", name: "Update role" });
|
if (!deleteRole) throw new BadRequestError({ message: "Role not found", name: "Update role" });
|
||||||
@@ -60,8 +71,8 @@ export const orgRoleServiceFactory = ({ orgRoleDAL, permissionService }: TOrgRol
|
|||||||
return deletedRole;
|
return deletedRole;
|
||||||
};
|
};
|
||||||
|
|
||||||
const listRoles = async (userId: string, orgId: string, actorOrgScope?: string) => {
|
const listRoles = async (userId: string, orgId: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Role);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Role);
|
||||||
const customRoles = await orgRoleDAL.find({ orgId });
|
const customRoles = await orgRoleDAL.find({ orgId });
|
||||||
const roles = [
|
const roles = [
|
||||||
@@ -104,8 +115,8 @@ export const orgRoleServiceFactory = ({ orgRoleDAL, permissionService }: TOrgRol
|
|||||||
return roles;
|
return roles;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserPermission = async (userId: string, orgId: string, actorOrgScope?: string) => {
|
const getUserPermission = async (userId: string, orgId: string, actorOrgId?: string) => {
|
||||||
const { permission, membership } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission, membership } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
return { permissions: packRules(permission.rules), membership };
|
return { permissions: packRules(permission.rules), membership };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ export const orgServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* Get organization details by the organization id
|
* Get organization details by the organization id
|
||||||
* */
|
* */
|
||||||
const findOrganizationById = async (userId: string, orgId: string, actorOrgScope?: string) => {
|
const findOrganizationById = async (userId: string, orgId: string, actorOrgId?: string) => {
|
||||||
await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
const org = await orgDAL.findOrgById(orgId);
|
const org = await orgDAL.findOrgById(orgId);
|
||||||
if (!org) throw new BadRequestError({ name: "Org not found", message: "Organization not found" });
|
if (!org) throw new BadRequestError({ name: "Org not found", message: "Organization not found" });
|
||||||
return org;
|
return org;
|
||||||
@@ -85,16 +85,16 @@ export const orgServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* Get all workspace members
|
* Get all workspace members
|
||||||
* */
|
* */
|
||||||
const findAllOrgMembers = async (userId: string, orgId: string, actorOrgScope?: string) => {
|
const findAllOrgMembers = async (userId: string, orgId: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
|
||||||
|
|
||||||
const members = await orgDAL.findAllOrgMembers(orgId);
|
const members = await orgDAL.findAllOrgMembers(orgId);
|
||||||
return members;
|
return members;
|
||||||
};
|
};
|
||||||
|
|
||||||
const findAllWorkspaces = async ({ actor, actorId, actorOrgScope, orgId }: TFindAllWorkspacesDTO) => {
|
const findAllWorkspaces = async ({ actor, actorId, actorOrgId, orgId }: TFindAllWorkspacesDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Workspace);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Workspace);
|
||||||
|
|
||||||
const organizationWorkspaceIds = new Set((await projectDAL.find({ orgId })).map((workspace) => workspace.id));
|
const organizationWorkspaceIds = new Set((await projectDAL.find({ orgId })).map((workspace) => workspace.id));
|
||||||
@@ -124,11 +124,11 @@ export const orgServiceFactory = ({
|
|||||||
const updateOrg = async ({
|
const updateOrg = async ({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
orgId,
|
orgId,
|
||||||
data: { name, slug, authEnforced }
|
data: { name, slug, authEnforced }
|
||||||
}: TUpdateOrgDTO) => {
|
}: TUpdateOrgDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
|
||||||
|
|
||||||
if (authEnforced) {
|
if (authEnforced) {
|
||||||
@@ -212,8 +212,8 @@ export const orgServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* Delete organization by id
|
* Delete organization by id
|
||||||
* */
|
* */
|
||||||
const deleteOrganizationById = async (userId: string, orgId: string, actorOrgScope?: string) => {
|
const deleteOrganizationById = async (userId: string, orgId: string, actorOrgId?: string) => {
|
||||||
const { membership } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { membership } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
if ((membership.role as OrgMembershipRole) !== OrgMembershipRole.Admin)
|
if ((membership.role as OrgMembershipRole) !== OrgMembershipRole.Admin)
|
||||||
throw new UnauthorizedError({ name: "Delete org by id", message: "Not an admin" });
|
throw new UnauthorizedError({ name: "Delete org by id", message: "Not an admin" });
|
||||||
|
|
||||||
@@ -227,8 +227,8 @@ export const orgServiceFactory = ({
|
|||||||
* Org membership management
|
* Org membership management
|
||||||
* Not another service because it has close ties with how an org works doesn't make sense to seperate them
|
* Not another service because it has close ties with how an org works doesn't make sense to seperate them
|
||||||
* */
|
* */
|
||||||
const updateOrgMembership = async ({ role, orgId, userId, membershipId, actorOrgScope }: TUpdateOrgMembershipDTO) => {
|
const updateOrgMembership = async ({ role, orgId, userId, membershipId, actorOrgId }: TUpdateOrgMembershipDTO) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
|
||||||
|
|
||||||
const isCustomRole = !Object.values(OrgMembershipRole).includes(role as OrgMembershipRole);
|
const isCustomRole = !Object.values(OrgMembershipRole).includes(role as OrgMembershipRole);
|
||||||
@@ -258,16 +258,18 @@ export const orgServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* Invite user to organization
|
* Invite user to organization
|
||||||
*/
|
*/
|
||||||
const inviteUserToOrganization = async ({ orgId, userId, inviteeEmail, actorOrgScope }: TInviteUserToOrgDTO) => {
|
const inviteUserToOrganization = async ({ orgId, userId, inviteeEmail, actorOrgId }: TInviteUserToOrgDTO) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Member);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Member);
|
||||||
|
|
||||||
const samlCfg = await samlConfigDAL.findOne({ orgId });
|
const org = await orgDAL.findOrgById(orgId);
|
||||||
if (samlCfg && samlCfg.isActive) {
|
|
||||||
|
if (org?.authEnforced) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: "Failed to invite member due to SAML SSO configured for organization"
|
message: "Failed to invite user due to org-level auth enforced for organization"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const plan = await licenseService.getPlan(orgId);
|
const plan = await licenseService.getPlan(orgId);
|
||||||
if (plan.memberLimit !== null && plan.membersUsed >= plan.memberLimit) {
|
if (plan.memberLimit !== null && plan.membersUsed >= plan.memberLimit) {
|
||||||
// case: limit imposed on number of members allowed
|
// case: limit imposed on number of members allowed
|
||||||
@@ -338,7 +340,6 @@ export const orgServiceFactory = ({
|
|||||||
orgId
|
orgId
|
||||||
});
|
});
|
||||||
|
|
||||||
const org = await orgDAL.findOrgById(orgId);
|
|
||||||
const user = await userDAL.findById(userId);
|
const user = await userDAL.findById(userId);
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
await smtpService.sendMail({
|
await smtpService.sendMail({
|
||||||
@@ -415,8 +416,8 @@ export const orgServiceFactory = ({
|
|||||||
return { token, user };
|
return { token, user };
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteOrgMembership = async ({ orgId, userId, membershipId, actorOrgScope }: TDeleteOrgMembershipDTO) => {
|
const deleteOrgMembership = async ({ orgId, userId, membershipId, actorOrgId }: TDeleteOrgMembershipDTO) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Member);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Member);
|
||||||
|
|
||||||
const membership = await orgDAL.deleteMembershipById(membershipId, orgId);
|
const membership = await orgDAL.deleteMembershipById(membershipId, orgId);
|
||||||
@@ -428,15 +429,15 @@ export const orgServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* CRUD operations of incident contacts
|
* CRUD operations of incident contacts
|
||||||
* */
|
* */
|
||||||
const findIncidentContacts = async (userId: string, orgId: string, actorOrgScope?: string) => {
|
const findIncidentContacts = async (userId: string, orgId: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.IncidentAccount);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.IncidentAccount);
|
||||||
const incidentContacts = await incidentContactDAL.findByOrgId(orgId);
|
const incidentContacts = await incidentContactDAL.findByOrgId(orgId);
|
||||||
return incidentContacts;
|
return incidentContacts;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createIncidentContact = async (userId: string, orgId: string, email: string, actorOrgScope?: string) => {
|
const createIncidentContact = async (userId: string, orgId: string, email: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.IncidentAccount);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.IncidentAccount);
|
||||||
const doesIncidentContactExist = await incidentContactDAL.findOne(orgId, { email });
|
const doesIncidentContactExist = await incidentContactDAL.findOne(orgId, { email });
|
||||||
if (doesIncidentContactExist) {
|
if (doesIncidentContactExist) {
|
||||||
@@ -450,8 +451,8 @@ export const orgServiceFactory = ({
|
|||||||
return incidentContact;
|
return incidentContact;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteIncidentContact = async (userId: string, orgId: string, id: string, actorOrgScope?: string) => {
|
const deleteIncidentContact = async (userId: string, orgId: string, id: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.IncidentAccount);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.IncidentAccount);
|
||||||
|
|
||||||
const incidentContact = await incidentContactDAL.deleteById(id, orgId);
|
const incidentContact = await incidentContactDAL.deleteById(id, orgId);
|
||||||
|
|||||||
@@ -7,20 +7,20 @@ export type TUpdateOrgMembershipDTO = {
|
|||||||
orgId: string;
|
orgId: string;
|
||||||
membershipId: string;
|
membershipId: string;
|
||||||
role: string;
|
role: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TDeleteOrgMembershipDTO = {
|
export type TDeleteOrgMembershipDTO = {
|
||||||
userId: string;
|
userId: string;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
membershipId: string;
|
membershipId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TInviteUserToOrgDTO = {
|
export type TInviteUserToOrgDTO = {
|
||||||
userId: string;
|
userId: string;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
inviteeEmail: string;
|
inviteeEmail: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ export type TVerifyUserToOrgDTO = {
|
|||||||
export type TFindAllWorkspacesDTO = {
|
export type TFindAllWorkspacesDTO = {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ export const projectBotServiceFactory = ({ projectBotDAL, permissionService }: T
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const findBotByProjectId = async ({ actorId, actor, actorOrgScope, projectId }: TProjectPermission) => {
|
const findBotByProjectId = async ({ actorId, actor, actorOrgId, projectId }: TProjectPermission) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Integrations);
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
|
|
||||||
@@ -120,11 +120,11 @@ export const projectBotServiceFactory = ({ projectBotDAL, permissionService }: T
|
|||||||
return bot;
|
return bot;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setBotActiveState = async ({ actor, botId, botKey, actorId, actorOrgScope, isActive }: TSetActiveStateDTO) => {
|
const setBotActiveState = async ({ actor, botId, botKey, actorId, actorOrgId, isActive }: TSetActiveStateDTO) => {
|
||||||
const bot = await projectBotDAL.findById(botId);
|
const bot = await projectBotDAL.findById(botId);
|
||||||
if (!bot) throw new BadRequestError({ message: "Bot not found" });
|
if (!bot) throw new BadRequestError({ message: "Bot not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, bot.projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, bot.projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Integrations);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Integrations);
|
||||||
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export const projectEnvServiceFactory = ({
|
|||||||
projectDAL,
|
projectDAL,
|
||||||
folderDAL
|
folderDAL
|
||||||
}: TProjectEnvServiceFactoryDep) => {
|
}: TProjectEnvServiceFactoryDep) => {
|
||||||
const createEnvironment = async ({ projectId, actorId, actor, actorOrgScope, name, slug }: TCreateEnvDTO) => {
|
const createEnvironment = async ({ projectId, actorId, actor, actorOrgId, name, slug }: TCreateEnvDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Environments);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Environments);
|
||||||
|
|
||||||
const envs = await projectEnvDAL.find({ projectId });
|
const envs = await projectEnvDAL.find({ projectId });
|
||||||
@@ -64,12 +64,12 @@ export const projectEnvServiceFactory = ({
|
|||||||
slug,
|
slug,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
name,
|
name,
|
||||||
id,
|
id,
|
||||||
position
|
position
|
||||||
}: TUpdateEnvDTO) => {
|
}: TUpdateEnvDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Environments);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Environments);
|
||||||
|
|
||||||
const oldEnv = await projectEnvDAL.findOne({ id, projectId });
|
const oldEnv = await projectEnvDAL.findOne({ id, projectId });
|
||||||
@@ -94,8 +94,8 @@ export const projectEnvServiceFactory = ({
|
|||||||
return { environment: env, old: oldEnv };
|
return { environment: env, old: oldEnv };
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteEnvironment = async ({ projectId, actor, actorId, actorOrgScope, id }: TDeleteEnvDTO) => {
|
const deleteEnvironment = async ({ projectId, actor, actorId, actorOrgId, id }: TDeleteEnvDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Environments);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Environments);
|
||||||
|
|
||||||
const env = await projectEnvDAL.transaction(async (tx) => {
|
const env = await projectEnvDAL.transaction(async (tx) => {
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ export const projectKeyServiceFactory = ({
|
|||||||
receiverId,
|
receiverId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
nonce,
|
nonce,
|
||||||
encryptedKey
|
encryptedKey
|
||||||
}: TUploadProjectKeyDTO) => {
|
}: TUploadProjectKeyDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
const receiverMembership = await projectMembershipDAL.findOne({
|
const receiverMembership = await projectMembershipDAL.findOne({
|
||||||
@@ -46,14 +46,14 @@ export const projectKeyServiceFactory = ({
|
|||||||
await projectKeyDAL.create({ projectId, receiverId, encryptedKey, nonce, senderId: actorId });
|
await projectKeyDAL.create({ projectId, receiverId, encryptedKey, nonce, senderId: actorId });
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLatestProjectKey = async ({ actorId, projectId, actor, actorOrgScope }: TGetLatestProjectKeyDTO) => {
|
const getLatestProjectKey = async ({ actorId, projectId, actor, actorOrgId }: TGetLatestProjectKeyDTO) => {
|
||||||
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
const latestKey = await projectKeyDAL.findLatestProjectKey(actorId, projectId);
|
const latestKey = await projectKeyDAL.findLatestProjectKey(actorId, projectId);
|
||||||
return latestKey;
|
return latestKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProjectPublicKeys = async ({ actor, actorId, actorOrgScope, projectId }: TGetLatestProjectKeyDTO) => {
|
const getProjectPublicKeys = async ({ actor, actorId, actorOrgId, projectId }: TGetLatestProjectKeyDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Member);
|
||||||
return projectKeyDAL.findAllProjectUserPubKeys(projectId);
|
return projectKeyDAL.findAllProjectUserPubKeys(projectId);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,15 +48,15 @@ export const projectMembershipServiceFactory = ({
|
|||||||
projectKeyDAL,
|
projectKeyDAL,
|
||||||
licenseService
|
licenseService
|
||||||
}: TProjectMembershipServiceFactoryDep) => {
|
}: TProjectMembershipServiceFactoryDep) => {
|
||||||
const getProjectMemberships = async ({ actorId, actor, actorOrgScope, projectId }: TGetProjectMembershipDTO) => {
|
const getProjectMemberships = async ({ actorId, actor, actorOrgId, projectId }: TGetProjectMembershipDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
return projectMembershipDAL.findAllProjectMembers(projectId);
|
return projectMembershipDAL.findAllProjectMembers(projectId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const inviteUserToProject = async ({ actorId, actor, actorOrgScope, projectId, email }: TInviteUserToProjectDTO) => {
|
const inviteUserToProject = async ({ actorId, actor, actorOrgId, projectId, email }: TInviteUserToProjectDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
const invitee = await userDAL.findOne({ email });
|
const invitee = await userDAL.findOne({ email });
|
||||||
@@ -112,11 +112,11 @@ export const projectMembershipServiceFactory = ({
|
|||||||
return { invitee, latestKey };
|
return { invitee, latestKey };
|
||||||
};
|
};
|
||||||
|
|
||||||
const addUsersToProject = async ({ projectId, actorId, actor, actorOrgScope, members }: TAddUsersToWorkspaceDTO) => {
|
const addUsersToProject = async ({ projectId, actorId, actor, actorOrgId, members }: TAddUsersToWorkspaceDTO) => {
|
||||||
const project = await projectDAL.findById(projectId);
|
const project = await projectDAL.findById(projectId);
|
||||||
if (!project) throw new BadRequestError({ message: "Project not found" });
|
if (!project) throw new BadRequestError({ message: "Project not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Member);
|
||||||
const orgMembers = await orgDAL.findMembership({
|
const orgMembers = await orgDAL.findMembership({
|
||||||
orgId: project.orgId,
|
orgId: project.orgId,
|
||||||
@@ -172,12 +172,12 @@ export const projectMembershipServiceFactory = ({
|
|||||||
const updateProjectMembership = async ({
|
const updateProjectMembership = async ({
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
membershipId,
|
membershipId,
|
||||||
role
|
role
|
||||||
}: TUpdateProjectMembershipDTO) => {
|
}: TUpdateProjectMembershipDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
const isCustomRole = !Object.values(ProjectMembershipRole).includes(role as ProjectMembershipRole);
|
const isCustomRole = !Object.values(ProjectMembershipRole).includes(role as ProjectMembershipRole);
|
||||||
@@ -208,11 +208,11 @@ export const projectMembershipServiceFactory = ({
|
|||||||
const deleteProjectMembership = async ({
|
const deleteProjectMembership = async ({
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
membershipId
|
membershipId
|
||||||
}: TDeleteProjectMembershipDTO) => {
|
}: TDeleteProjectMembershipDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
const membership = await projectMembershipDAL.transaction(async (tx) => {
|
const membership = await projectMembershipDAL.transaction(async (tx) => {
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ export const projectRoleServiceFactory = ({ projectRoleDAL, permissionService }:
|
|||||||
actorId: string,
|
actorId: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
data: Omit<TProjectRolesInsert, "projectId">,
|
data: Omit<TProjectRolesInsert, "projectId">,
|
||||||
actorOrgScope?: string
|
actorOrgId?: string
|
||||||
) => {
|
) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Role);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Role);
|
||||||
const existingRole = await projectRoleDAL.findOne({ slug: data.slug, projectId });
|
const existingRole = await projectRoleDAL.findOne({ slug: data.slug, projectId });
|
||||||
if (existingRole) throw new BadRequestError({ name: "Create Role", message: "Duplicate role" });
|
if (existingRole) throw new BadRequestError({ name: "Create Role", message: "Duplicate role" });
|
||||||
@@ -49,9 +49,9 @@ export const projectRoleServiceFactory = ({ projectRoleDAL, permissionService }:
|
|||||||
projectId: string,
|
projectId: string,
|
||||||
roleId: string,
|
roleId: string,
|
||||||
data: Omit<TOrgRolesUpdate, "orgId">,
|
data: Omit<TOrgRolesUpdate, "orgId">,
|
||||||
actorOrgScope?: string
|
actorOrgId?: string
|
||||||
) => {
|
) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Role);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Role);
|
||||||
if (data?.slug) {
|
if (data?.slug) {
|
||||||
const existingRole = await projectRoleDAL.findOne({ slug: data.slug, projectId });
|
const existingRole = await projectRoleDAL.findOne({ slug: data.slug, projectId });
|
||||||
@@ -71,9 +71,9 @@ export const projectRoleServiceFactory = ({ projectRoleDAL, permissionService }:
|
|||||||
actorId: string,
|
actorId: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
roleId: string,
|
roleId: string,
|
||||||
actorOrgScope?: string
|
actorOrgId?: string
|
||||||
) => {
|
) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Role);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Role);
|
||||||
const [deletedRole] = await projectRoleDAL.delete({ id: roleId, projectId });
|
const [deletedRole] = await projectRoleDAL.delete({ id: roleId, projectId });
|
||||||
if (!deleteRole) throw new BadRequestError({ message: "Role not found", name: "Update role" });
|
if (!deleteRole) throw new BadRequestError({ message: "Role not found", name: "Update role" });
|
||||||
@@ -81,8 +81,8 @@ export const projectRoleServiceFactory = ({ projectRoleDAL, permissionService }:
|
|||||||
return deletedRole;
|
return deletedRole;
|
||||||
};
|
};
|
||||||
|
|
||||||
const listRoles = async (actor: ActorType, actorId: string, projectId: string, actorOrgScope?: string) => {
|
const listRoles = async (actor: ActorType, actorId: string, projectId: string, actorOrgId?: string) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Role);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Role);
|
||||||
const customRoles = await projectRoleDAL.find({ projectId });
|
const customRoles = await projectRoleDAL.find({ projectId });
|
||||||
const roles = [
|
const roles = [
|
||||||
@@ -135,12 +135,8 @@ export const projectRoleServiceFactory = ({ projectRoleDAL, permissionService }:
|
|||||||
return roles;
|
return roles;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserPermission = async (userId: string, projectId: string, actorOrgScope?: string) => {
|
const getUserPermission = async (userId: string, projectId: string, actorOrgId?: string) => {
|
||||||
const { permission, membership } = await permissionService.getUserProjectPermission(
|
const { permission, membership } = await permissionService.getUserProjectPermission(userId, projectId, actorOrgId);
|
||||||
userId,
|
|
||||||
projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
return { permissions: packRules(permission.rules), membership };
|
return { permissions: packRules(permission.rules), membership };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export const projectServiceFactory = ({
|
|||||||
/*
|
/*
|
||||||
* Create workspace. Make user the admin
|
* Create workspace. Make user the admin
|
||||||
* */
|
* */
|
||||||
const createProject = async ({ orgId, actor, actorId, actorOrgScope, workspaceName }: TCreateProjectDTO) => {
|
const createProject = async ({ orgId, actor, actorId, actorOrgId, workspaceName }: TCreateProjectDTO) => {
|
||||||
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgScope);
|
const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Workspace);
|
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Workspace);
|
||||||
|
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
@@ -106,8 +106,8 @@ export const projectServiceFactory = ({
|
|||||||
return newProject;
|
return newProject;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteProject = async ({ actor, actorId, actorOrgScope, projectId }: TDeleteProjectDTO) => {
|
const deleteProject = async ({ actor, actorId, actorOrgId, projectId }: TDeleteProjectDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Project);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Project);
|
||||||
|
|
||||||
const deletedProject = await projectDAL.deleteById(projectId);
|
const deletedProject = await projectDAL.deleteById(projectId);
|
||||||
@@ -119,8 +119,8 @@ export const projectServiceFactory = ({
|
|||||||
return workspaces;
|
return workspaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAProject = async ({ actorId, actorOrgScope, projectId, actor }: TGetProjectDTO) => {
|
const getAProject = async ({ actorId, actorOrgId, projectId, actor }: TGetProjectDTO) => {
|
||||||
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
return projectDAL.findProjectById(projectId);
|
return projectDAL.findProjectById(projectId);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,18 +128,18 @@ export const projectServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
autoCapitalization
|
autoCapitalization
|
||||||
}: TGetProjectDTO & { autoCapitalization: boolean }) => {
|
}: TGetProjectDTO & { autoCapitalization: boolean }) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings);
|
||||||
|
|
||||||
const updatedProject = await projectDAL.updateById(projectId, { autoCapitalization });
|
const updatedProject = await projectDAL.updateById(projectId, { autoCapitalization });
|
||||||
return updatedProject;
|
return updatedProject;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateName = async ({ projectId, actor, actorId, actorOrgScope, name }: TGetProjectDTO & { name: string }) => {
|
const updateName = async ({ projectId, actor, actorId, actorOrgId, name }: TGetProjectDTO & { name: string }) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Settings);
|
||||||
|
|
||||||
const updatedProject = await projectDAL.updateById(projectId, { name });
|
const updatedProject = await projectDAL.updateById(projectId, { name });
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { ActorType } from "../auth/auth-type";
|
|||||||
export type TCreateProjectDTO = {
|
export type TCreateProjectDTO = {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
workspaceName: string;
|
workspaceName: string;
|
||||||
};
|
};
|
||||||
@@ -11,13 +11,13 @@ export type TCreateProjectDTO = {
|
|||||||
export type TDeleteProjectDTO = {
|
export type TDeleteProjectDTO = {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TGetProjectDTO = {
|
export type TGetProjectDTO = {
|
||||||
actor: ActorType;
|
actor: ActorType;
|
||||||
actorId: string;
|
actorId: string;
|
||||||
actorOrgScope?: string;
|
actorOrgId?: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ export const secretBlindIndexServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TGetProjectBlindIndexStatusDTO) => {
|
}: TGetProjectBlindIndexStatusDTO) => {
|
||||||
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
|
|
||||||
const secretCount = await secretBlindIndexDAL.countOfSecretsWithNullSecretBlindIndex(projectId);
|
const secretCount = await secretBlindIndexDAL.countOfSecretsWithNullSecretBlindIndex(projectId);
|
||||||
return Number(secretCount);
|
return Number(secretCount);
|
||||||
@@ -50,10 +50,10 @@ export const secretBlindIndexServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
secretsToUpdate
|
secretsToUpdate
|
||||||
}: TUpdateProjectSecretNameDTO) => {
|
}: TUpdateProjectSecretNameDTO) => {
|
||||||
const { membership } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { membership } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
if (membership?.role !== ProjectMembershipRole.Admin) {
|
if (membership?.role !== ProjectMembershipRole.Admin) {
|
||||||
throw new UnauthorizedError({ message: "User must be admin" });
|
throw new UnauthorizedError({ message: "User must be admin" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ export const secretFolderServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
name,
|
name,
|
||||||
environment,
|
environment,
|
||||||
path: secretPath
|
path: secretPath
|
||||||
}: TCreateFolderDTO) => {
|
}: TCreateFolderDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
||||||
@@ -113,13 +113,13 @@ export const secretFolderServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
name,
|
name,
|
||||||
environment,
|
environment,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
id
|
id
|
||||||
}: TUpdateFolderDTO) => {
|
}: TUpdateFolderDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Edit,
|
ProjectPermissionActions.Edit,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
||||||
@@ -161,12 +161,12 @@ export const secretFolderServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
path: secretPath,
|
path: secretPath,
|
||||||
id
|
id
|
||||||
}: TDeleteFolderDTO) => {
|
}: TDeleteFolderDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Delete,
|
ProjectPermissionActions.Delete,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
||||||
@@ -192,13 +192,13 @@ export const secretFolderServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
path: secretPath
|
path: secretPath
|
||||||
}: TGetFolderDTO) => {
|
}: TGetFolderDTO) => {
|
||||||
// folder list is allowed to be read by anyone
|
// folder list is allowed to be read by anyone
|
||||||
// permission to check does user has access
|
// permission to check does user has access
|
||||||
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
|
|
||||||
const env = await projectEnvDAL.findOne({ projectId, slug: environment });
|
const env = await projectEnvDAL.findOne({ projectId, slug: environment });
|
||||||
if (!env) throw new BadRequestError({ message: "Environment not found", name: "get folders" });
|
if (!env) throw new BadRequestError({ message: "Environment not found", name: "get folders" });
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ export const secretImportServiceFactory = ({
|
|||||||
data,
|
data,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
path
|
path
|
||||||
}: TCreateSecretImportDTO) => {
|
}: TCreateSecretImportDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
|
|
||||||
// check if user has permission to import into destination path
|
// check if user has permission to import into destination path
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
@@ -91,11 +91,11 @@ export const secretImportServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
data,
|
data,
|
||||||
id
|
id
|
||||||
}: TUpdateSecretImportDTO) => {
|
}: TUpdateSecretImportDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Edit,
|
ProjectPermissionActions.Edit,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -138,10 +138,10 @@ export const secretImportServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
id
|
id
|
||||||
}: TDeleteSecretImportDTO) => {
|
}: TDeleteSecretImportDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Delete,
|
ProjectPermissionActions.Delete,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -162,8 +162,8 @@ export const secretImportServiceFactory = ({
|
|||||||
return secImport;
|
return secImport;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getImports = async ({ path, environment, projectId, actor, actorId, actorOrgScope }: TGetSecretImportsDTO) => {
|
const getImports = async ({ path, environment, projectId, actor, actorId, actorOrgId }: TGetSecretImportsDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -182,9 +182,9 @@ export const secretImportServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TGetSecretsFromImportDTO) => {
|
}: TGetSecretsFromImportDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ type TSecretTagServiceFactoryDep = {
|
|||||||
export type TSecretTagServiceFactory = ReturnType<typeof secretTagServiceFactory>;
|
export type TSecretTagServiceFactory = ReturnType<typeof secretTagServiceFactory>;
|
||||||
|
|
||||||
export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSecretTagServiceFactoryDep) => {
|
export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSecretTagServiceFactoryDep) => {
|
||||||
const createTag = async ({ name, slug, actor, color, actorId, actorOrgScope, projectId }: TCreateTagDTO) => {
|
const createTag = async ({ name, slug, actor, color, actorId, actorOrgId, projectId }: TCreateTagDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Tags);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Tags);
|
||||||
|
|
||||||
const existingTag = await secretTagDAL.findOne({ slug });
|
const existingTag = await secretTagDAL.findOne({ slug });
|
||||||
@@ -32,19 +32,19 @@ export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSe
|
|||||||
return newTag;
|
return newTag;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteTag = async ({ actorId, actor, actorOrgScope, id }: TDeleteTagDTO) => {
|
const deleteTag = async ({ actorId, actor, actorOrgId, id }: TDeleteTagDTO) => {
|
||||||
const tag = await secretTagDAL.findById(id);
|
const tag = await secretTagDAL.findById(id);
|
||||||
if (!tag) throw new BadRequestError({ message: "Tag doesn't exist" });
|
if (!tag) throw new BadRequestError({ message: "Tag doesn't exist" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, tag.projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, tag.projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Tags);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Tags);
|
||||||
|
|
||||||
const deletedTag = await secretTagDAL.deleteById(tag.id);
|
const deletedTag = await secretTagDAL.deleteById(tag.id);
|
||||||
return deletedTag;
|
return deletedTag;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProjectTags = async ({ actor, actorId, actorOrgScope, projectId }: TListProjectTagsDTO) => {
|
const getProjectTags = async ({ actor, actorId, actorOrgId, projectId }: TListProjectTagsDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
|
||||||
|
|
||||||
const tags = await secretTagDAL.find({ projectId }, { sort: [["createdAt", "asc"]] });
|
const tags = await secretTagDAL.find({ projectId }, { sort: [["createdAt", "asc"]] });
|
||||||
|
|||||||
@@ -270,12 +270,12 @@ export const secretServiceFactory = ({
|
|||||||
path,
|
path,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
...inputSecret
|
...inputSecret
|
||||||
}: TCreateSecretDTO) => {
|
}: TCreateSecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -348,12 +348,12 @@ export const secretServiceFactory = ({
|
|||||||
path,
|
path,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
...inputSecret
|
...inputSecret
|
||||||
}: TUpdateSecretDTO) => {
|
}: TUpdateSecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Edit,
|
ProjectPermissionActions.Edit,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -448,12 +448,12 @@ export const secretServiceFactory = ({
|
|||||||
path,
|
path,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
...inputSecret
|
...inputSecret
|
||||||
}: TDeleteSecretDTO) => {
|
}: TDeleteSecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Delete,
|
ProjectPermissionActions.Delete,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -505,10 +505,10 @@ export const secretServiceFactory = ({
|
|||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
includeImports
|
includeImports
|
||||||
}: TGetSecretsDTO) => {
|
}: TGetSecretsDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -549,7 +549,7 @@ export const secretServiceFactory = ({
|
|||||||
const getSecretByName = async ({
|
const getSecretByName = async ({
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
environment,
|
environment,
|
||||||
path,
|
path,
|
||||||
@@ -558,7 +558,7 @@ export const secretServiceFactory = ({
|
|||||||
version,
|
version,
|
||||||
includeImports
|
includeImports
|
||||||
}: TGetASecretDTO) => {
|
}: TGetASecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Read,
|
ProjectPermissionActions.Read,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -639,12 +639,12 @@ export const secretServiceFactory = ({
|
|||||||
path,
|
path,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
secrets: inputSecrets
|
secrets: inputSecrets
|
||||||
}: TCreateBulkSecretDTO) => {
|
}: TCreateBulkSecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -694,12 +694,12 @@ export const secretServiceFactory = ({
|
|||||||
path,
|
path,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
secrets: inputSecrets
|
secrets: inputSecrets
|
||||||
}: TUpdateBulkSecretDTO) => {
|
}: TUpdateBulkSecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -768,9 +768,9 @@ export const secretServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
}: TDeleteBulkSecretDTO) => {
|
}: TDeleteBulkSecretDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(
|
ForbiddenError.from(permission).throwUnlessCan(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath: path })
|
||||||
@@ -814,7 +814,7 @@ export const secretServiceFactory = ({
|
|||||||
path,
|
path,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
environment,
|
environment,
|
||||||
includeImports
|
includeImports
|
||||||
}: TGetSecretsRawDTO) => {
|
}: TGetSecretsRawDTO) => {
|
||||||
@@ -826,7 +826,7 @@ export const secretServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
environment,
|
environment,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
path,
|
path,
|
||||||
includeImports
|
includeImports
|
||||||
});
|
});
|
||||||
@@ -849,7 +849,7 @@ export const secretServiceFactory = ({
|
|||||||
environment,
|
environment,
|
||||||
projectId,
|
projectId,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
secretName,
|
secretName,
|
||||||
includeImports,
|
includeImports,
|
||||||
version
|
version
|
||||||
@@ -862,7 +862,7 @@ export const secretServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
environment,
|
environment,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
path,
|
path,
|
||||||
secretName,
|
secretName,
|
||||||
type,
|
type,
|
||||||
@@ -878,7 +878,7 @@ export const secretServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
environment,
|
environment,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
type,
|
type,
|
||||||
secretPath,
|
secretPath,
|
||||||
secretValue,
|
secretValue,
|
||||||
@@ -900,7 +900,7 @@ export const secretServiceFactory = ({
|
|||||||
path: secretPath,
|
path: secretPath,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
secretKeyCiphertext: secretKeyEncrypted.ciphertext,
|
secretKeyCiphertext: secretKeyEncrypted.ciphertext,
|
||||||
secretKeyIV: secretKeyEncrypted.iv,
|
secretKeyIV: secretKeyEncrypted.iv,
|
||||||
secretKeyTag: secretKeyEncrypted.tag,
|
secretKeyTag: secretKeyEncrypted.tag,
|
||||||
@@ -925,7 +925,7 @@ export const secretServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
environment,
|
environment,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
type,
|
type,
|
||||||
secretPath,
|
secretPath,
|
||||||
secretValue,
|
secretValue,
|
||||||
@@ -944,7 +944,7 @@ export const secretServiceFactory = ({
|
|||||||
path: secretPath,
|
path: secretPath,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
secretValueCiphertext: secretValueEncrypted.ciphertext,
|
secretValueCiphertext: secretValueEncrypted.ciphertext,
|
||||||
secretValueIV: secretValueEncrypted.iv,
|
secretValueIV: secretValueEncrypted.iv,
|
||||||
secretValueTag: secretValueEncrypted.tag,
|
secretValueTag: secretValueEncrypted.tag,
|
||||||
@@ -963,7 +963,7 @@ export const secretServiceFactory = ({
|
|||||||
projectId,
|
projectId,
|
||||||
environment,
|
environment,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
type,
|
type,
|
||||||
secretPath
|
secretPath
|
||||||
}: TDeleteSecretRawDTO) => {
|
}: TDeleteSecretRawDTO) => {
|
||||||
@@ -978,7 +978,7 @@ export const secretServiceFactory = ({
|
|||||||
path: secretPath,
|
path: secretPath,
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
});
|
});
|
||||||
|
|
||||||
await snapshotService.performSnapshot(secret.folderId);
|
await snapshotService.performSnapshot(secret.folderId);
|
||||||
@@ -990,7 +990,7 @@ export const secretServiceFactory = ({
|
|||||||
const getSecretVersions = async ({
|
const getSecretVersions = async ({
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
limit = 20,
|
limit = 20,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
secretId
|
secretId
|
||||||
@@ -1001,12 +1001,7 @@ export const secretServiceFactory = ({
|
|||||||
const folder = await folderDAL.findById(secret.folderId);
|
const folder = await folderDAL.findById(secret.folderId);
|
||||||
if (!folder) throw new BadRequestError({ message: "Failed to find secret" });
|
if (!folder) throw new BadRequestError({ message: "Failed to find secret" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, folder.projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
folder.projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.SecretRollback);
|
||||||
|
|
||||||
const secretVersions = await secretVersionDAL.find({ secretId }, { offset, limit, sort: [["createdAt", "desc"]] });
|
const secretVersions = await secretVersionDAL.find({ secretId }, { offset, limit, sort: [["createdAt", "desc"]] });
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const serviceTokenServiceFactory = ({
|
|||||||
tag,
|
tag,
|
||||||
name,
|
name,
|
||||||
actor,
|
actor,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
scopes,
|
scopes,
|
||||||
actorId,
|
actorId,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -47,7 +47,7 @@ export const serviceTokenServiceFactory = ({
|
|||||||
permissions,
|
permissions,
|
||||||
encryptedKey
|
encryptedKey
|
||||||
}: TCreateServiceTokenDTO) => {
|
}: TCreateServiceTokenDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.ServiceTokens);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.ServiceTokens);
|
||||||
|
|
||||||
scopes.forEach(({ environment, secretPath }) => {
|
scopes.forEach(({ environment, secretPath }) => {
|
||||||
@@ -91,7 +91,7 @@ export const serviceTokenServiceFactory = ({
|
|||||||
return { token, serviceToken };
|
return { token, serviceToken };
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteServiceToken = async ({ actorId, actor, actorOrgScope, id }: TDeleteServiceTokenDTO) => {
|
const deleteServiceToken = async ({ actorId, actor, actorOrgId, id }: TDeleteServiceTokenDTO) => {
|
||||||
const serviceToken = await serviceTokenDAL.findById(id);
|
const serviceToken = await serviceTokenDAL.findById(id);
|
||||||
if (!serviceToken) throw new BadRequestError({ message: "Token not found" });
|
if (!serviceToken) throw new BadRequestError({ message: "Token not found" });
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ export const serviceTokenServiceFactory = ({
|
|||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
serviceToken.projectId,
|
serviceToken.projectId,
|
||||||
actorOrgScope
|
actorOrgId
|
||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.ServiceTokens);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.ServiceTokens);
|
||||||
|
|
||||||
@@ -119,8 +119,8 @@ export const serviceTokenServiceFactory = ({
|
|||||||
return { serviceToken, user: serviceTokenUser };
|
return { serviceToken, user: serviceTokenUser };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProjectServiceTokens = async ({ actorId, actor, actorOrgScope, projectId }: TProjectServiceTokensDTO) => {
|
const getProjectServiceTokens = async ({ actorId, actor, actorOrgId, projectId }: TProjectServiceTokensDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.ServiceTokens);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.ServiceTokens);
|
||||||
|
|
||||||
const tokens = await serviceTokenDAL.find({ projectId }, { sort: [["createdAt", "desc"]] });
|
const tokens = await serviceTokenDAL.find({ projectId }, { sort: [["createdAt", "desc"]] });
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ export const webhookServiceFactory = ({ webhookDAL, projectEnvDAL, permissionSer
|
|||||||
const createWebhook = async ({
|
const createWebhook = async ({
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
actorOrgScope,
|
actorOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
webhookUrl,
|
webhookUrl,
|
||||||
environment,
|
environment,
|
||||||
secretPath,
|
secretPath,
|
||||||
webhookSecretKey
|
webhookSecretKey
|
||||||
}: TCreateWebhookDTO) => {
|
}: TCreateWebhookDTO) => {
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Webhooks);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Webhooks);
|
||||||
const env = await projectEnvDAL.findOne({ projectId, slug: environment });
|
const env = await projectEnvDAL.findOne({ projectId, slug: environment });
|
||||||
if (!env) throw new BadRequestError({ message: "Env not found" });
|
if (!env) throw new BadRequestError({ message: "Env not found" });
|
||||||
@@ -73,48 +73,33 @@ export const webhookServiceFactory = ({ webhookDAL, projectEnvDAL, permissionSer
|
|||||||
return { ...webhook, projectId, environment: env };
|
return { ...webhook, projectId, environment: env };
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateWebhook = async ({ actorId, actor, actorOrgScope, id, isDisabled }: TUpdateWebhookDTO) => {
|
const updateWebhook = async ({ actorId, actor, actorOrgId, id, isDisabled }: TUpdateWebhookDTO) => {
|
||||||
const webhook = await webhookDAL.findById(id);
|
const webhook = await webhookDAL.findById(id);
|
||||||
if (!webhook) throw new BadRequestError({ message: "Webhook not found" });
|
if (!webhook) throw new BadRequestError({ message: "Webhook not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, webhook.projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
webhook.projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Webhooks);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Webhooks);
|
||||||
|
|
||||||
const updatedWebhook = await webhookDAL.updateById(id, { isDisabled });
|
const updatedWebhook = await webhookDAL.updateById(id, { isDisabled });
|
||||||
return { ...webhook, ...updatedWebhook };
|
return { ...webhook, ...updatedWebhook };
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteWebhook = async ({ id, actor, actorId, actorOrgScope }: TDeleteWebhookDTO) => {
|
const deleteWebhook = async ({ id, actor, actorId, actorOrgId }: TDeleteWebhookDTO) => {
|
||||||
const webhook = await webhookDAL.findById(id);
|
const webhook = await webhookDAL.findById(id);
|
||||||
if (!webhook) throw new BadRequestError({ message: "Webhook not found" });
|
if (!webhook) throw new BadRequestError({ message: "Webhook not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, webhook.projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
webhook.projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Webhooks);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Webhooks);
|
||||||
|
|
||||||
const deletedWebhook = await webhookDAL.deleteById(id);
|
const deletedWebhook = await webhookDAL.deleteById(id);
|
||||||
return { ...webhook, ...deletedWebhook };
|
return { ...webhook, ...deletedWebhook };
|
||||||
};
|
};
|
||||||
|
|
||||||
const testWebhook = async ({ id, actor, actorId, actorOrgScope }: TTestWebhookDTO) => {
|
const testWebhook = async ({ id, actor, actorId, actorOrgId }: TTestWebhookDTO) => {
|
||||||
const webhook = await webhookDAL.findById(id);
|
const webhook = await webhookDAL.findById(id);
|
||||||
if (!webhook) throw new BadRequestError({ message: "Webhook not found" });
|
if (!webhook) throw new BadRequestError({ message: "Webhook not found" });
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, webhook.projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorId,
|
|
||||||
webhook.projectId,
|
|
||||||
actorOrgScope
|
|
||||||
);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Webhooks);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Webhooks);
|
||||||
|
|
||||||
let webhookError: string | undefined;
|
let webhookError: string | undefined;
|
||||||
@@ -134,15 +119,8 @@ export const webhookServiceFactory = ({ webhookDAL, projectEnvDAL, permissionSer
|
|||||||
return { ...webhook, ...updatedWebhook };
|
return { ...webhook, ...updatedWebhook };
|
||||||
};
|
};
|
||||||
|
|
||||||
const listWebhooks = async ({
|
const listWebhooks = async ({ actorId, actor, actorOrgId, projectId, secretPath, environment }: TListWebhookDTO) => {
|
||||||
actorId,
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
actor,
|
|
||||||
actorOrgScope,
|
|
||||||
projectId,
|
|
||||||
secretPath,
|
|
||||||
environment
|
|
||||||
}: TListWebhookDTO) => {
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgScope);
|
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Webhooks);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Webhooks);
|
||||||
|
|
||||||
return webhookDAL.findAllWebhooks(projectId, environment, secretPath);
|
return webhookDAL.findAllWebhooks(projectId, environment, secretPath);
|
||||||
|
|||||||
+4
-5
@@ -16,7 +16,7 @@ import {
|
|||||||
useOrganization,
|
useOrganization,
|
||||||
useSubscription
|
useSubscription
|
||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
import { useDeleteOrgMembership, useGetSSOConfig } from "@app/hooks/api";
|
import { useDeleteOrgMembership } from "@app/hooks/api";
|
||||||
import { usePopUp } from "@app/hooks/usePopUp";
|
import { usePopUp } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
import { AddOrgMemberModal } from "./AddOrgMemberModal";
|
import { AddOrgMemberModal } from "./AddOrgMemberModal";
|
||||||
@@ -27,10 +27,9 @@ export const OrgMembersSection = () => {
|
|||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
const orgId = currentOrg?.id ?? "";
|
const orgId = currentOrg?.id ?? "";
|
||||||
|
|
||||||
const [completeInviteLink, setCompleteInviteLink] = useState<string>("");
|
const [completeInviteLink, setCompleteInviteLink] = useState<string>("");
|
||||||
|
|
||||||
const { data: ssoConfig, isLoading: isLoadingSSOConfig } = useGetSSOConfig(orgId);
|
|
||||||
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
||||||
"addMember",
|
"addMember",
|
||||||
"removeMember",
|
"removeMember",
|
||||||
@@ -45,9 +44,9 @@ export const OrgMembersSection = () => {
|
|||||||
: false;
|
: false;
|
||||||
|
|
||||||
const handleAddMemberModal = () => {
|
const handleAddMemberModal = () => {
|
||||||
if (!isLoadingSSOConfig && ssoConfig && ssoConfig.isActive) {
|
if (currentOrg?.authEnforced) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "You cannot invite users when SAML SSO is configured for your organization",
|
text: "You cannot invite users when org-level auth is configured for your organization",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,577 +0,0 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
||||||
import { Controller, useForm } from "react-hook-form";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
import {
|
|
||||||
faCheck,
|
|
||||||
faCopy,
|
|
||||||
faMagnifyingGlass,
|
|
||||||
faPlus,
|
|
||||||
faTrash,
|
|
||||||
faUsers
|
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { yupResolver } from "@hookform/resolvers/yup";
|
|
||||||
import * as yup from "yup";
|
|
||||||
|
|
||||||
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
|
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
|
||||||
import {
|
|
||||||
decryptAssymmetric,
|
|
||||||
encryptAssymmetric
|
|
||||||
} from "@app/components/utilities/cryptography/crypto";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
DeleteActionModal,
|
|
||||||
EmailServiceSetupModal,
|
|
||||||
EmptyState,
|
|
||||||
FormControl,
|
|
||||||
IconButton,
|
|
||||||
Input,
|
|
||||||
Modal,
|
|
||||||
ModalContent,
|
|
||||||
Select,
|
|
||||||
SelectItem,
|
|
||||||
Table,
|
|
||||||
TableContainer,
|
|
||||||
TableSkeleton,
|
|
||||||
Tag,
|
|
||||||
TBody,
|
|
||||||
Td,
|
|
||||||
Th,
|
|
||||||
THead,
|
|
||||||
Tr,
|
|
||||||
UpgradePlanModal
|
|
||||||
} from "@app/components/v2";
|
|
||||||
import {
|
|
||||||
OrgPermissionActions,
|
|
||||||
OrgPermissionSubjects,
|
|
||||||
useOrganization,
|
|
||||||
useSubscription,
|
|
||||||
useUser,
|
|
||||||
useWorkspace
|
|
||||||
} from "@app/context";
|
|
||||||
import { usePopUp, useToggle } from "@app/hooks";
|
|
||||||
import {
|
|
||||||
useAddUserToOrg,
|
|
||||||
useDeleteOrgMembership,
|
|
||||||
useGetOrgUsers,
|
|
||||||
useGetSSOConfig,
|
|
||||||
useGetUserWorkspaceMemberships,
|
|
||||||
useGetUserWsKey,
|
|
||||||
useUpdateOrgUserRole,
|
|
||||||
useUploadWsKey
|
|
||||||
} from "@app/hooks/api";
|
|
||||||
import { TProjectRole } from "@app/hooks/api/roles/types";
|
|
||||||
import { useFetchServerStatus } from "@app/hooks/api/serverDetails";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
roles?: TProjectRole[];
|
|
||||||
isRolesLoading?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const addMemberFormSchema = yup.object({
|
|
||||||
email: yup.string().email().required().label("Email").trim().lowercase()
|
|
||||||
});
|
|
||||||
|
|
||||||
type TAddMemberForm = yup.InferType<typeof addMemberFormSchema>;
|
|
||||||
|
|
||||||
export const OrgMembersTable = ({ roles = [], isRolesLoading }: Props) => {
|
|
||||||
const router = useRouter();
|
|
||||||
const { createNotification } = useNotificationContext();
|
|
||||||
|
|
||||||
const { currentOrg } = useOrganization();
|
|
||||||
const { workspaces, currentWorkspace } = useWorkspace();
|
|
||||||
const { user } = useUser();
|
|
||||||
const userId = user?.id || "";
|
|
||||||
const orgId = currentOrg?.id || "";
|
|
||||||
const workspaceId = currentWorkspace?.id || "";
|
|
||||||
|
|
||||||
const { data: ssoConfig, isLoading: isLoadingSSOConfig } = useGetSSOConfig(orgId);
|
|
||||||
const [searchMemberFilter, setSearchMemberFilter] = useState("");
|
|
||||||
const { data: serverDetails } = useFetchServerStatus();
|
|
||||||
|
|
||||||
const [isInviteLinkCopied, setInviteLinkCopied] = useToggle(false);
|
|
||||||
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
|
||||||
"addMember",
|
|
||||||
"removeMember",
|
|
||||||
"upgradePlan",
|
|
||||||
"setUpEmail"
|
|
||||||
] as const);
|
|
||||||
const { subscription } = useSubscription();
|
|
||||||
|
|
||||||
const { data: members, isLoading: isMembersLoading } = useGetOrgUsers(orgId);
|
|
||||||
const { data: workspaceMemberships, isLoading: IsWsMembershipLoading } =
|
|
||||||
useGetUserWorkspaceMemberships(orgId);
|
|
||||||
const { data: wsKey } = useGetUserWsKey(workspaceId);
|
|
||||||
|
|
||||||
const removeUserOrgMembership = useDeleteOrgMembership();
|
|
||||||
const addUserToOrg = useAddUserToOrg();
|
|
||||||
const updateOrgUserRole = useUpdateOrgUserRole();
|
|
||||||
const uploadWsKey = useUploadWsKey();
|
|
||||||
|
|
||||||
const [completeInviteLink, setCompleteInviteLink] = useState<string | undefined>("");
|
|
||||||
|
|
||||||
const isMoreUsersNotAllowed = subscription?.memberLimit
|
|
||||||
? subscription.membersUsed >= subscription.memberLimit
|
|
||||||
: false;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (router.query.action === "invite") {
|
|
||||||
handlePopUpOpen("addMember");
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const {
|
|
||||||
control,
|
|
||||||
handleSubmit,
|
|
||||||
reset,
|
|
||||||
formState: { isSubmitting }
|
|
||||||
} = useForm<TAddMemberForm>({ resolver: yupResolver(addMemberFormSchema) });
|
|
||||||
|
|
||||||
const onAddMember = async ({ email }: TAddMemberForm) => {
|
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { data } = await addUserToOrg.mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
inviteeEmail: email
|
|
||||||
});
|
|
||||||
setCompleteInviteLink(data?.completeInviteLink);
|
|
||||||
// only show this notification when email is configured.
|
|
||||||
// A [completeInviteLink] will not be sent if smtp is configured
|
|
||||||
if (!data.completeInviteLink) {
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully invited user to the organization.",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to invite user to org",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (serverDetails?.emailConfigured) {
|
|
||||||
handlePopUpClose("addMember");
|
|
||||||
}
|
|
||||||
reset();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onAddUserToOrg = async (email: string) => {
|
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { data } = await addUserToOrg.mutateAsync({
|
|
||||||
organizationId: currentOrg?.id,
|
|
||||||
inviteeEmail: email
|
|
||||||
});
|
|
||||||
setCompleteInviteLink(data?.completeInviteLink);
|
|
||||||
|
|
||||||
// only show this notification when email is configured. A [completeInviteLink] will not be sent if smtp is configured
|
|
||||||
if (!data.completeInviteLink) {
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully invited user to the organization.",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to invite user to org",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const onRemoveOrgMemberApproved = async () => {
|
|
||||||
const membershipId = (popUp?.removeMember?.data as { id: string })?.id;
|
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await removeUserOrgMembership.mutateAsync({ orgId: currentOrg?.id, membershipId });
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully removed user from org",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove user from the organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpClose("removeMember");
|
|
||||||
};
|
|
||||||
|
|
||||||
const isIamOwner = useMemo(
|
|
||||||
() => members?.find(({ user: u }) => userId === u?.id)?.role === "owner",
|
|
||||||
[userId, members]
|
|
||||||
);
|
|
||||||
|
|
||||||
const findRoleFromId = useCallback(
|
|
||||||
(roleId: string) => {
|
|
||||||
return roles.find(({ id }) => id === roleId);
|
|
||||||
},
|
|
||||||
[roles]
|
|
||||||
);
|
|
||||||
|
|
||||||
const filterdUser = useMemo(
|
|
||||||
() =>
|
|
||||||
members?.filter(
|
|
||||||
({ user: u, inviteEmail }) =>
|
|
||||||
u?.firstName?.toLowerCase().includes(searchMemberFilter) ||
|
|
||||||
u?.lastName?.toLowerCase().includes(searchMemberFilter) ||
|
|
||||||
u?.email?.toLowerCase().includes(searchMemberFilter) ||
|
|
||||||
inviteEmail?.includes(searchMemberFilter)
|
|
||||||
),
|
|
||||||
[members, searchMemberFilter]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let timer: NodeJS.Timeout;
|
|
||||||
if (isInviteLinkCopied) {
|
|
||||||
timer = setTimeout(() => setInviteLinkCopied.off(), 2000);
|
|
||||||
}
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}, [isInviteLinkCopied]);
|
|
||||||
|
|
||||||
const onRoleChange = async (membershipId: string, role: string) => {
|
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await updateOrgUserRole.mutateAsync({ organizationId: currentOrg?.id, membershipId, role });
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully updated user role",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update user role",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const onGrantAccess = async (grantedUserId: string, publicKey: string) => {
|
|
||||||
try {
|
|
||||||
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
|
|
||||||
if (!PRIVATE_KEY || !wsKey) return;
|
|
||||||
|
|
||||||
// assymmetrically decrypt symmetric key with local private key
|
|
||||||
const key = decryptAssymmetric({
|
|
||||||
ciphertext: wsKey.encryptedKey,
|
|
||||||
nonce: wsKey.nonce,
|
|
||||||
publicKey: wsKey.sender.publicKey,
|
|
||||||
privateKey: PRIVATE_KEY
|
|
||||||
});
|
|
||||||
|
|
||||||
const { ciphertext, nonce } = encryptAssymmetric({
|
|
||||||
plaintext: key,
|
|
||||||
publicKey,
|
|
||||||
privateKey: PRIVATE_KEY
|
|
||||||
});
|
|
||||||
|
|
||||||
await uploadWsKey.mutateAsync({
|
|
||||||
userId: grantedUserId,
|
|
||||||
nonce,
|
|
||||||
encryptedKey: ciphertext,
|
|
||||||
workspaceId: currentWorkspace?.id || ""
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to grant access to user",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const copyTokenToClipboard = () => {
|
|
||||||
navigator.clipboard.writeText(completeInviteLink as string);
|
|
||||||
setInviteLinkCopied.on();
|
|
||||||
};
|
|
||||||
|
|
||||||
const isLoading = isMembersLoading || IsWsMembershipLoading || isRolesLoading;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-full">
|
|
||||||
<div className="mb-4 flex">
|
|
||||||
<div className="mr-4 flex-1">
|
|
||||||
<Input
|
|
||||||
value={searchMemberFilter}
|
|
||||||
onChange={(e) => setSearchMemberFilter(e.target.value)}
|
|
||||||
leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
|
|
||||||
placeholder="Search members..."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Member}>
|
|
||||||
{(isAllowed) => (
|
|
||||||
<Button
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
|
||||||
onClick={() => {
|
|
||||||
if (!isLoadingSSOConfig && ssoConfig && ssoConfig.isActive) {
|
|
||||||
createNotification({
|
|
||||||
text: "You cannot invite users when SAML SSO is configured for your organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMoreUsersNotAllowed) {
|
|
||||||
handlePopUpOpen("upgradePlan");
|
|
||||||
} else {
|
|
||||||
handlePopUpOpen("addMember");
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Add Member
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</OrgPermissionCan>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<TableContainer>
|
|
||||||
<Table>
|
|
||||||
<THead>
|
|
||||||
<Tr>
|
|
||||||
<Th>Name</Th>
|
|
||||||
<Th>Email</Th>
|
|
||||||
<Th>Role</Th>
|
|
||||||
<Th>Projects</Th>
|
|
||||||
<Th aria-label="actions" />
|
|
||||||
</Tr>
|
|
||||||
</THead>
|
|
||||||
<TBody>
|
|
||||||
{isLoading && <TableSkeleton columns={5} innerKey="org-members" />}
|
|
||||||
{!isLoading &&
|
|
||||||
filterdUser?.map(
|
|
||||||
({ user: u, inviteEmail, role, roleId, id: orgMembershipId, status }) => {
|
|
||||||
const name = u ? `${u.firstName || "-"} ${u.lastName || ""}` : "-";
|
|
||||||
const email = u?.email || inviteEmail;
|
|
||||||
const userWs = workspaceMemberships?.[u?.id];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Tr key={`org-membership-${orgMembershipId}`} className="w-full">
|
|
||||||
<Td>{name}</Td>
|
|
||||||
<Td>{email}</Td>
|
|
||||||
<Td>
|
|
||||||
<OrgPermissionCan
|
|
||||||
I={OrgPermissionActions.Edit}
|
|
||||||
a={OrgPermissionSubjects.Member}
|
|
||||||
>
|
|
||||||
{(isAllowed) => (
|
|
||||||
<>
|
|
||||||
{status === "accepted" && (
|
|
||||||
<Select
|
|
||||||
defaultValue={
|
|
||||||
role === "custom" ? findRoleFromId(roleId)?.slug : role
|
|
||||||
}
|
|
||||||
isDisabled={userId === u?.id || !isAllowed}
|
|
||||||
className="w-40 bg-mineshaft-600"
|
|
||||||
dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
|
|
||||||
onValueChange={(selectedRole) =>
|
|
||||||
onRoleChange(orgMembershipId, selectedRole)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{roles
|
|
||||||
.filter(({ slug }) =>
|
|
||||||
slug === "owner" ? isIamOwner || role === "owner" : true
|
|
||||||
)
|
|
||||||
.map(({ slug, name: roleName }) => (
|
|
||||||
<SelectItem value={slug} key={`owner-option-${slug}`}>
|
|
||||||
{roleName}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
)}
|
|
||||||
{(status === "invited" || status === "verified") &&
|
|
||||||
serverDetails?.emailConfigured && (
|
|
||||||
<Button
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
className="w-40"
|
|
||||||
colorSchema="primary"
|
|
||||||
variant="outline_bg"
|
|
||||||
onClick={() => onAddUserToOrg(email)}
|
|
||||||
>
|
|
||||||
Resend Invite
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
{status === "completed" && (
|
|
||||||
<Button
|
|
||||||
colorSchema="secondary"
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
onClick={() => onGrantAccess(u?.id, u?.publicKey)}
|
|
||||||
>
|
|
||||||
Grant Access
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</OrgPermissionCan>
|
|
||||||
</Td>
|
|
||||||
<Td>
|
|
||||||
{userWs ? (
|
|
||||||
userWs?.map(({ name: wsName, id }) => (
|
|
||||||
<Tag key={`user-${u.id}-workspace-${id}`} className="my-1">
|
|
||||||
{wsName}
|
|
||||||
</Tag>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<div className="flex flex-row">
|
|
||||||
{(status === "invited" || status === "verified") &&
|
|
||||||
serverDetails?.emailConfigured ? (
|
|
||||||
<Tag colorSchema="red">
|
|
||||||
This user hasn't accepted the invite yet
|
|
||||||
</Tag>
|
|
||||||
) : (
|
|
||||||
<Tag colorSchema="red">
|
|
||||||
This user isn't part of any projects yet
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
{router.query.id !== "undefined" &&
|
|
||||||
!(
|
|
||||||
(status === "invited" || status === "verified") &&
|
|
||||||
serverDetails?.emailConfigured
|
|
||||||
) && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() =>
|
|
||||||
router.push(`/project/${workspaces[0]?.id}/members`)
|
|
||||||
}
|
|
||||||
className="w-max cursor-pointer rounded-sm bg-mineshaft px-1.5 py-0.5 text-sm duration-200 hover:bg-primary hover:text-black"
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={faPlus} className="mr-1" />
|
|
||||||
Add to projects
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Td>
|
|
||||||
<Td>
|
|
||||||
{userId !== u?.id && (
|
|
||||||
<OrgPermissionCan
|
|
||||||
I={OrgPermissionActions.Delete}
|
|
||||||
a={OrgPermissionSubjects.Member}
|
|
||||||
>
|
|
||||||
{(isAllowed) => (
|
|
||||||
<IconButton
|
|
||||||
ariaLabel="delete"
|
|
||||||
colorSchema="danger"
|
|
||||||
isDisabled={userId === u?.id || !isAllowed}
|
|
||||||
onClick={() =>
|
|
||||||
handlePopUpOpen("removeMember", { id: orgMembershipId })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={faTrash} />
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
</OrgPermissionCan>
|
|
||||||
)}
|
|
||||||
</Td>
|
|
||||||
</Tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
</TBody>
|
|
||||||
</Table>
|
|
||||||
{!isLoading && filterdUser?.length === 0 && (
|
|
||||||
<EmptyState title="No project members found" icon={faUsers} />
|
|
||||||
)}
|
|
||||||
</TableContainer>
|
|
||||||
</div>
|
|
||||||
<Modal
|
|
||||||
isOpen={popUp?.addMember?.isOpen}
|
|
||||||
onOpenChange={(isOpen) => {
|
|
||||||
handlePopUpToggle("addMember", isOpen);
|
|
||||||
setCompleteInviteLink(undefined);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ModalContent
|
|
||||||
title={`Invite others to ${currentOrg?.name}`}
|
|
||||||
subTitle={
|
|
||||||
<div>
|
|
||||||
{!completeInviteLink && (
|
|
||||||
<div>
|
|
||||||
An invite is specific to an email address and expires after 1 day.
|
|
||||||
<br />
|
|
||||||
For security reasons, you will need to separately add members to projects.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{completeInviteLink &&
|
|
||||||
"This Infisical instance does not have a email provider setup. Please share this invite link with the invitee manually"}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{!completeInviteLink && (
|
|
||||||
<form onSubmit={handleSubmit(onAddMember)}>
|
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
defaultValue=""
|
|
||||||
name="email"
|
|
||||||
render={({ field, fieldState: { error } }) => (
|
|
||||||
<FormControl label="Email" isError={Boolean(error)} errorText={error?.message}>
|
|
||||||
<Input {...field} />
|
|
||||||
</FormControl>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="mt-8 flex items-center">
|
|
||||||
<Button
|
|
||||||
className="mr-4"
|
|
||||||
size="sm"
|
|
||||||
type="submit"
|
|
||||||
isLoading={isSubmitting}
|
|
||||||
isDisabled={isSubmitting}
|
|
||||||
>
|
|
||||||
Add Member
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
colorSchema="secondary"
|
|
||||||
variant="plain"
|
|
||||||
onClick={() => handlePopUpClose("addMember")}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
)}
|
|
||||||
{completeInviteLink && (
|
|
||||||
<div className="mt-2 mb-3 mr-2 flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
|
|
||||||
<p className="mr-4 break-all">{completeInviteLink}</p>
|
|
||||||
<IconButton
|
|
||||||
ariaLabel="copy icon"
|
|
||||||
colorSchema="secondary"
|
|
||||||
className="group relative"
|
|
||||||
onClick={copyTokenToClipboard}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={isInviteLinkCopied ? faCheck : faCopy} />
|
|
||||||
<span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
|
|
||||||
click to copy
|
|
||||||
</span>
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
<DeleteActionModal
|
|
||||||
isOpen={popUp.removeMember.isOpen}
|
|
||||||
deleteKey="remove"
|
|
||||||
title="Do you want to remove this user from the org?"
|
|
||||||
onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
|
|
||||||
onDeleteApproved={onRemoveOrgMemberApproved}
|
|
||||||
/>
|
|
||||||
<UpgradePlanModal
|
|
||||||
isOpen={popUp.upgradePlan.isOpen}
|
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
|
|
||||||
text="You can add custom environments if you switch to Infisical's Team plan."
|
|
||||||
/>
|
|
||||||
<EmailServiceSetupModal
|
|
||||||
isOpen={popUp.setUpEmail?.isOpen}
|
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("setUpEmail", isOpen)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user