Replace the old PDF/snapshot-based exports for processing activities, Data Protection Impact Assessments and Transfer Impact Assessments with the publish document system. Includes GraphQL mutations, MCP tools, CLI commands, n8n operations, frontend publish dialogs, e2e tests, and prosemirror register templates that mirror the previous PDF layouts. Each register lives as a generated DocumentTypeRegister document on the organization, reused across publishes (the major version bumps on every republish). Approvers can be passed in to create a draft pending approval; otherwise the version is published immediately. The frontend ProcessingActivities page exposes a Publish dropdown per register and a Document link button per active tab, pre-fills the previous default approvers, and navigates to the published document on success. Remove snapshot mode entirely from these three entities: drop snapshotId and sourceId from GraphQL schemas, types, filters, resolvers, MCP spec, frontend routes and pages; remove SnapshotsTypeProcessingActivities from the snapshot registry and delete the ProcessingActivities.Snapshot, ProcessingActivitySnapshotter interface and *.InsertProcessingActivitySnapshots methods. The snapshot_id columns remain in the database but are now filtered out with snapshot_id IS NULL. Add Get/Upsert/Clear GeneratedDocumentID methods on each entity type (ProcessingActivity, DataProtectionImpactAssessment, TransferImpactAssessment) backed by new columns in the generated_documents table, matching the Finding/Obligation pattern. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
205 lines
8.2 KiB
Go
205 lines
8.2 KiB
Go
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.com>.
|
|
//
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
// copyright notice and this permission notice appear in all copies.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
package probo
|
|
|
|
import (
|
|
"go.probo.inc/probo/pkg/iam"
|
|
"go.probo.inc/probo/pkg/iam/policy"
|
|
)
|
|
|
|
var (
|
|
organizationCondition = policy.Equals("principal.organization_id", "resource.organization_id")
|
|
)
|
|
|
|
// OwnerPolicy defines permissions for organization owners.
|
|
var OwnerPolicy = policy.NewPolicy(
|
|
"probo:owner",
|
|
"Probo Owner",
|
|
policy.Allow("core:*").WithSID("full-core-access").When(organizationCondition),
|
|
).WithDescription("Full probo access for organization owners")
|
|
|
|
// AdminPolicy defines permissions for organization admins.
|
|
var AdminPolicy = policy.NewPolicy(
|
|
"probo:admin",
|
|
"Probo Admin",
|
|
policy.Allow("core:*").WithSID("full-core-access").When(organizationCondition),
|
|
).WithDescription("Probo admin access - can manage core entities")
|
|
|
|
// ViewerPolicy defines read-only permissions for organization viewers.
|
|
var ViewerPolicy = policy.NewPolicy(
|
|
"probo:viewer",
|
|
"Probo Viewer",
|
|
policy.Allow(
|
|
ActionOrganizationGet,
|
|
ActionOrganizationGetLogoUrl,
|
|
ActionOrganizationGetHorizontalLogoUrl,
|
|
).WithSID("org-read-access").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionVendorGet, ActionVendorList,
|
|
ActionVendorContactGet, ActionVendorContactList,
|
|
ActionVendorServiceGet, ActionVendorServiceList,
|
|
ActionVendorComplianceReportGet, ActionVendorComplianceReportList,
|
|
ActionVendorBusinessAssociateAgreementGet,
|
|
ActionVendorDataPrivacyAgreementGet,
|
|
ActionVendorRiskAssessmentList,
|
|
ActionFrameworkGet, ActionFrameworkList,
|
|
ActionControlGet, ActionControlList,
|
|
ActionMeasureGet, ActionMeasureList,
|
|
ActionTaskGet, ActionTaskList,
|
|
ActionEvidenceList,
|
|
ActionDocumentGet, ActionDocumentList,
|
|
ActionDocumentVersionGet, ActionDocumentVersionList,
|
|
ActionDocumentVersionSignatureGet, ActionDocumentVersionSignatureList,
|
|
ActionDocumentVersionApprovalList,
|
|
ActionRiskGet, ActionRiskList,
|
|
ActionAssetGet, ActionAssetList,
|
|
ActionDatumGet, ActionDatumList,
|
|
ActionAuditGet, ActionAuditList,
|
|
ActionReportGet, ActionReportGetReportUrl, ActionReportDownloadUrlGet,
|
|
ActionFindingGet, ActionFindingList,
|
|
ActionObligationGet, ActionObligationList,
|
|
ActionProcessingActivityGet, ActionProcessingActivityList,
|
|
ActionDataProtectionImpactAssessmentGet, ActionDataProtectionImpactAssessmentList,
|
|
ActionTransferImpactAssessmentGet, ActionTransferImpactAssessmentList,
|
|
ActionSnapshotGet, ActionSnapshotList,
|
|
ActionFileGet, ActionFileDownloadUrl,
|
|
ActionSlackConnectionList, ActionConnectorList,
|
|
ActionRightsRequestGet, ActionRightsRequestList,
|
|
ActionStatementOfApplicabilityGet, ActionStatementOfApplicabilityList,
|
|
ActionApplicabilityStatementGet, ActionApplicabilityStatementList,
|
|
ActionWebhookSubscriptionGet, ActionWebhookSubscriptionList,
|
|
ActionAccessReviewCampaignGet, ActionAccessReviewCampaignList,
|
|
ActionAccessEntryGet, ActionAccessEntryList,
|
|
ActionAccessSourceGet, ActionAccessSourceList,
|
|
ActionCookieBannerGet, ActionCookieBannerList,
|
|
ActionCookieBannerVersionGet, ActionCookieBannerVersionList,
|
|
ActionCookieCategoryGet, ActionCookieCategoryList,
|
|
ActionCookieGet, ActionCookieList,
|
|
ActionCookieConsentRecordList,
|
|
).WithSID("entity-read-access").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionTrustCenterGet,
|
|
ActionTrustCenterAccessGet, ActionTrustCenterAccessList,
|
|
ActionTrustCenterDocumentAccessList,
|
|
ActionTrustCenterFileGet, ActionTrustCenterFileList, ActionTrustCenterFileGetFileUrl,
|
|
ActionTrustCenterReferenceList, ActionTrustCenterReferenceGetLogoUrl,
|
|
ActionComplianceFrameworkList,
|
|
).WithSID("trust-center-read-access").When(organizationCondition),
|
|
|
|
policy.Allow(ActionCustomDomainGet).WithSID("custom-domain-read").When(organizationCondition),
|
|
policy.Allow(ActionOrganizationContextGet).WithSID("organization-context-read").When(organizationCondition),
|
|
policy.Allow(
|
|
ActionDocumentVersionExportPDF, ActionDocumentVersionSign,
|
|
).WithSID("document-signing").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionDocumentVersionApprove, ActionDocumentVersionReject,
|
|
).WithSID("document-approval").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionEmployeeDocumentGet, ActionEmployeeDocumentList,
|
|
ActionEmployeeDocumentVersionExportPDF,
|
|
).WithSID("employee-document-access").When(organizationCondition),
|
|
).WithDescription("Read-only probo access for organization viewers")
|
|
|
|
// AuditorPolicy defines permissions for auditor role.
|
|
var AuditorPolicy = policy.NewPolicy(
|
|
"probo:auditor",
|
|
"Probo Auditor",
|
|
policy.Allow(
|
|
ActionOrganizationGet,
|
|
ActionOrganizationGetLogoUrl,
|
|
ActionOrganizationGetHorizontalLogoUrl,
|
|
).WithSID("org-read-access").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionVendorGet, ActionVendorList,
|
|
ActionVendorContactGet, ActionVendorContactList,
|
|
ActionVendorServiceGet, ActionVendorServiceList,
|
|
ActionVendorComplianceReportGet, ActionVendorComplianceReportList,
|
|
ActionVendorBusinessAssociateAgreementGet,
|
|
ActionVendorDataPrivacyAgreementGet,
|
|
ActionVendorRiskAssessmentList,
|
|
ActionFrameworkGet, ActionFrameworkList,
|
|
ActionControlGet, ActionControlList,
|
|
ActionMeasureGet, ActionMeasureList,
|
|
ActionEvidenceList,
|
|
ActionDocumentGet, ActionDocumentList,
|
|
ActionDocumentVersionGet, ActionDocumentVersionList,
|
|
ActionDocumentVersionSignatureGet, ActionDocumentVersionSignatureList,
|
|
ActionDocumentVersionApprovalList,
|
|
ActionRiskGet, ActionRiskList,
|
|
ActionAssetGet, ActionAssetList,
|
|
ActionDatumGet, ActionDatumList,
|
|
ActionAuditGet, ActionAuditList,
|
|
ActionReportGet, ActionReportGetReportUrl, ActionReportDownloadUrlGet,
|
|
ActionFindingGet, ActionFindingList,
|
|
ActionObligationGet, ActionObligationList,
|
|
ActionProcessingActivityGet, ActionProcessingActivityList,
|
|
ActionDataProtectionImpactAssessmentGet,
|
|
ActionTransferImpactAssessmentGet, ActionTransferImpactAssessmentList,
|
|
ActionSnapshotGet, ActionSnapshotList,
|
|
ActionFileGet, ActionFileDownloadUrl,
|
|
ActionStatementOfApplicabilityGet, ActionStatementOfApplicabilityList,
|
|
ActionApplicabilityStatementGet, ActionApplicabilityStatementList,
|
|
).WithSID("entity-read-access").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionDocumentVersionExportPDF, ActionDocumentVersionSign,
|
|
).WithSID("document-signing").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionEmployeeDocumentGet, ActionEmployeeDocumentList,
|
|
ActionEmployeeDocumentVersionExportPDF,
|
|
).WithSID("employee-document-access").When(organizationCondition),
|
|
).WithDescription("Read-only probo access for auditors (excludes internal/employee content)")
|
|
|
|
// EmployeePolicy defines permissions for employee role.
|
|
var EmployeePolicy = policy.NewPolicy(
|
|
"probo:employee",
|
|
"Probo Employee",
|
|
policy.Allow(
|
|
ActionOrganizationGet,
|
|
ActionOrganizationGetLogoUrl,
|
|
).WithSID("org-basic-access").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionEmployeeDocumentGet, ActionEmployeeDocumentList,
|
|
).WithSID("employee-document-access").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionDocumentVersionSign,
|
|
ActionEmployeeDocumentVersionExportPDF,
|
|
).WithSID("document-version-signing").When(organizationCondition),
|
|
|
|
policy.Allow(
|
|
ActionDocumentVersionApprovalList,
|
|
ActionDocumentVersionApprove,
|
|
ActionDocumentVersionReject,
|
|
).WithSID("document-version-approval").When(organizationCondition),
|
|
).WithDescription("Employee access - can sign documents, approve documents, and view internal content")
|
|
|
|
// ProboPolicySet returns the PolicySet for the probo service.
|
|
func ProboPolicySet() *iam.PolicySet {
|
|
return iam.NewPolicySet().
|
|
AddRolePolicy("OWNER", OwnerPolicy).
|
|
AddRolePolicy("ADMIN", AdminPolicy).
|
|
AddRolePolicy("VIEWER", ViewerPolicy).
|
|
AddRolePolicy("AUDITOR", AuditorPolicy).
|
|
AddRolePolicy("EMPLOYEE", EmployeePolicy)
|
|
}
|