Port trust center features after main rebase
Move Emile's commitment CRUD into complianceportal management, wire console and visitor GraphQL, and drop portal magic-link sign-in in favor of OAuth /initiate while keeping documents, NDA/full-name gates, and access-request resume markers. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -41,6 +41,20 @@ const (
|
||||
ActionCompliancePortalReferenceUpdate = "compliance-portal:portal-reference:update"
|
||||
ActionCompliancePortalReferenceDelete = "compliance-portal:portal-reference:delete"
|
||||
|
||||
// Compliance portal commitment group actions.
|
||||
ActionCompliancePortalCommitmentGroupList = "compliance-portal:commitment-group:list"
|
||||
ActionCompliancePortalCommitmentGroupCreate = "compliance-portal:commitment-group:create"
|
||||
ActionCompliancePortalCommitmentGroupUpdate = "compliance-portal:commitment-group:update"
|
||||
ActionCompliancePortalCommitmentGroupUpdateRank = "compliance-portal:commitment-group:update-rank"
|
||||
ActionCompliancePortalCommitmentGroupDelete = "compliance-portal:commitment-group:delete"
|
||||
|
||||
// Compliance portal commitment actions.
|
||||
ActionCompliancePortalCommitmentList = "compliance-portal:commitment:list"
|
||||
ActionCompliancePortalCommitmentCreate = "compliance-portal:commitment:create"
|
||||
ActionCompliancePortalCommitmentUpdate = "compliance-portal:commitment:update"
|
||||
ActionCompliancePortalCommitmentUpdateRank = "compliance-portal:commitment:update-rank"
|
||||
ActionCompliancePortalCommitmentDelete = "compliance-portal:commitment:delete"
|
||||
|
||||
// Compliance portal file actions.
|
||||
ActionCompliancePortalFileGet = "compliance-portal:portal-file:get"
|
||||
ActionCompliancePortalFileList = "compliance-portal:portal-file:list"
|
||||
|
||||
271
pkg/complianceportal/management/commitment_group_service.go
Normal file
271
pkg/complianceportal/management/commitment_group_service.go
Normal file
@@ -0,0 +1,271 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package management
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/validator"
|
||||
)
|
||||
|
||||
type (
|
||||
CreateCompliancePortalCommitmentGroupRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Title string
|
||||
Description string
|
||||
}
|
||||
|
||||
UpdateCompliancePortalCommitmentGroupRequest struct {
|
||||
ID gid.GID
|
||||
Title *string
|
||||
Description *string
|
||||
Rank *int
|
||||
}
|
||||
)
|
||||
|
||||
func (r *CreateCompliancePortalCommitmentGroupRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType))
|
||||
v.Check(r.Title, "title", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
|
||||
func (r *UpdateCompliancePortalCommitmentGroupRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalCommitmentGroupEntityType))
|
||||
v.Check(r.Title, "title", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
|
||||
func (s *Service) ListCommitmentGroups(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterID gid.GID,
|
||||
cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) {
|
||||
var groups coredata.CompliancePortalCommitmentGroups
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
err := groups.LoadByTrustCenterID(ctx, conn, scope, trustCenterID, cursor)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment groups: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return page.NewPage(groups, cursor), nil
|
||||
}
|
||||
|
||||
func (s *Service) CountCommitmentGroups(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) (err error) {
|
||||
groups := coredata.CompliancePortalCommitmentGroups{}
|
||||
|
||||
count, err = groups.CountByTrustCenterID(ctx, conn, scope, trustCenterID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance portal commitment groups: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetCommitmentGroup(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
groupID gid.GID,
|
||||
) (*coredata.CompliancePortalCommitmentGroup, error) {
|
||||
var group coredata.CompliancePortalCommitmentGroup
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
err := group.LoadByID(ctx, conn, scope, groupID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &group, nil
|
||||
}
|
||||
|
||||
func (s *Service) CreateCommitmentGroup(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *CreateCompliancePortalCommitmentGroupRequest,
|
||||
) (*coredata.CompliancePortalCommitmentGroup, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
groupID := gid.New(scope.GetTenantID(), coredata.CompliancePortalCommitmentGroupEntityType)
|
||||
|
||||
var group *coredata.CompliancePortalCommitmentGroup
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
trustCenter := &coredata.TrustCenter{}
|
||||
if err := trustCenter.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
}
|
||||
|
||||
group = &coredata.CompliancePortalCommitmentGroup{
|
||||
ID: groupID,
|
||||
OrganizationID: trustCenter.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := group.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return group, nil
|
||||
}
|
||||
|
||||
func (s *Service) UpdateCommitmentGroup(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateCompliancePortalCommitmentGroupRequest,
|
||||
) (*coredata.CompliancePortalCommitmentGroup, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var group *coredata.CompliancePortalCommitmentGroup
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
group = &coredata.CompliancePortalCommitmentGroup{}
|
||||
|
||||
if err := group.LoadByID(ctx, tx, scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
if req.Title != nil {
|
||||
group.Title = *req.Title
|
||||
}
|
||||
|
||||
if req.Description != nil {
|
||||
group.Description = *req.Description
|
||||
}
|
||||
|
||||
group.UpdatedAt = now
|
||||
|
||||
if req.Rank != nil {
|
||||
group.Rank = *req.Rank
|
||||
if err := group.UpdateRank(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update rank: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := group.Update(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return group, nil
|
||||
}
|
||||
|
||||
func (s *Service) DeleteCommitmentGroup(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
groupID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
group := &coredata.CompliancePortalCommitmentGroup{}
|
||||
|
||||
if err := group.LoadByID(ctx, tx, scope, groupID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
if err := group.Delete(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot delete compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
294
pkg/complianceportal/management/commitment_service.go
Normal file
294
pkg/complianceportal/management/commitment_service.go
Normal file
@@ -0,0 +1,294 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package management
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/validator"
|
||||
)
|
||||
|
||||
type (
|
||||
CreateCompliancePortalCommitmentRequest struct {
|
||||
GroupID gid.GID
|
||||
Icon coredata.CompliancePortalCommitmentIcon
|
||||
Eyebrow string
|
||||
Title string
|
||||
Description string
|
||||
}
|
||||
|
||||
UpdateCompliancePortalCommitmentRequest struct {
|
||||
ID gid.GID
|
||||
Icon *coredata.CompliancePortalCommitmentIcon
|
||||
Eyebrow *string
|
||||
Title *string
|
||||
Description *string
|
||||
Rank *int
|
||||
}
|
||||
)
|
||||
|
||||
func (r *CreateCompliancePortalCommitmentRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.GroupID, "group_id", validator.Required(), validator.GID(coredata.CompliancePortalCommitmentGroupEntityType))
|
||||
v.Check(r.Icon, "icon", validator.Required(), validator.OneOfSlice(coredata.CompliancePortalCommitmentIcons()))
|
||||
v.Check(r.Eyebrow, "eyebrow", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Title, "title", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
|
||||
func (r *UpdateCompliancePortalCommitmentRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalCommitmentEntityType))
|
||||
|
||||
if r.Icon != nil {
|
||||
v.Check(*r.Icon, "icon", validator.OneOfSlice(coredata.CompliancePortalCommitmentIcons()))
|
||||
}
|
||||
|
||||
v.Check(r.Eyebrow, "eyebrow", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Title, "title", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(r.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
|
||||
func (s *Service) ListCommitments(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
groupID gid.GID,
|
||||
cursor *page.Cursor[coredata.CompliancePortalCommitmentOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalCommitment, coredata.CompliancePortalCommitmentOrderField], error) {
|
||||
var commitments coredata.CompliancePortalCommitments
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
err := commitments.LoadByGroupID(ctx, conn, scope, groupID, cursor)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitments: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return page.NewPage(commitments, cursor), nil
|
||||
}
|
||||
|
||||
func (s *Service) CountCommitments(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
groupID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) (err error) {
|
||||
commitments := coredata.CompliancePortalCommitments{}
|
||||
|
||||
count, err = commitments.CountByGroupID(ctx, conn, scope, groupID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance portal commitments: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetCommitment(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
commitmentID gid.GID,
|
||||
) (*coredata.CompliancePortalCommitment, error) {
|
||||
var commitment coredata.CompliancePortalCommitment
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
err := commitment.LoadByID(ctx, conn, scope, commitmentID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &commitment, nil
|
||||
}
|
||||
|
||||
func (s *Service) CreateCommitment(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *CreateCompliancePortalCommitmentRequest,
|
||||
) (*coredata.CompliancePortalCommitment, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
commitmentID := gid.New(scope.GetTenantID(), coredata.CompliancePortalCommitmentEntityType)
|
||||
|
||||
var commitment *coredata.CompliancePortalCommitment
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
group := &coredata.CompliancePortalCommitmentGroup{}
|
||||
if err := group.LoadByID(ctx, tx, scope, req.GroupID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment group: %w", err)
|
||||
}
|
||||
|
||||
commitment = &coredata.CompliancePortalCommitment{
|
||||
ID: commitmentID,
|
||||
OrganizationID: group.OrganizationID,
|
||||
TrustCenterID: group.TrustCenterID,
|
||||
GroupID: req.GroupID,
|
||||
Icon: req.Icon,
|
||||
Eyebrow: req.Eyebrow,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := commitment.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert compliance portal commitment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return commitment, nil
|
||||
}
|
||||
|
||||
func (s *Service) UpdateCommitment(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateCompliancePortalCommitmentRequest,
|
||||
) (*coredata.CompliancePortalCommitment, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var commitment *coredata.CompliancePortalCommitment
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
commitment = &coredata.CompliancePortalCommitment{}
|
||||
|
||||
if err := commitment.LoadByID(ctx, tx, scope, req.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment: %w", err)
|
||||
}
|
||||
|
||||
if req.Icon != nil {
|
||||
commitment.Icon = *req.Icon
|
||||
}
|
||||
|
||||
if req.Eyebrow != nil {
|
||||
commitment.Eyebrow = *req.Eyebrow
|
||||
}
|
||||
|
||||
if req.Title != nil {
|
||||
commitment.Title = *req.Title
|
||||
}
|
||||
|
||||
if req.Description != nil {
|
||||
commitment.Description = *req.Description
|
||||
}
|
||||
|
||||
commitment.UpdatedAt = now
|
||||
|
||||
if req.Rank != nil {
|
||||
commitment.Rank = *req.Rank
|
||||
if err := commitment.UpdateRank(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update rank: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := commitment.Update(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot update compliance portal commitment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return commitment, nil
|
||||
}
|
||||
|
||||
func (s *Service) DeleteCommitment(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
commitmentID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
commitment := &coredata.CompliancePortalCommitment{}
|
||||
|
||||
if err := commitment.LoadByID(ctx, tx, scope, commitmentID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal commitment: %w", err)
|
||||
}
|
||||
|
||||
if err := commitment.Delete(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot delete compliance portal commitment: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
@@ -21,14 +21,6 @@ import (
|
||||
|
||||
var organizationCondition = policy.Equals("principal.organization_id", "resource.organization_id")
|
||||
|
||||
// FullAccessPolicy grants organization owners and admins complete access to
|
||||
// every compliance portal capability, including custom domains, portal
|
||||
// configuration, access grants, files, references, frameworks, external URLs
|
||||
// and mailing lists.
|
||||
//
|
||||
// The managed probopage subdomain is a system-owned resource and can never be
|
||||
// deleted, so an explicit deny (which takes precedence over any allow) blocks
|
||||
// deletion of managed domains for every role.
|
||||
var FullAccessPolicy = policy.NewPolicy(
|
||||
"compliance-portal:full-access",
|
||||
"Compliance Portal Full Access",
|
||||
@@ -40,8 +32,6 @@ var FullAccessPolicy = policy.NewPolicy(
|
||||
When(policy.Equals("resource.managed", "true")),
|
||||
).WithDescription("Full compliance portal access for organization owners and admins")
|
||||
|
||||
// ViewerPolicy grants organization viewers read-only access to the compliance
|
||||
// portal.
|
||||
var ViewerPolicy = policy.NewPolicy(
|
||||
"compliance-portal:viewer",
|
||||
"Compliance Portal Viewer",
|
||||
@@ -52,11 +42,11 @@ var ViewerPolicy = policy.NewPolicy(
|
||||
ActionCompliancePortalDocumentAccessList,
|
||||
ActionCompliancePortalFileGet, ActionCompliancePortalFileList, ActionCompliancePortalFileGetFileUrl,
|
||||
ActionCompliancePortalReferenceList, ActionCompliancePortalReferenceGetLogoUrl,
|
||||
ActionCompliancePortalCommitmentGroupList, ActionCompliancePortalCommitmentList,
|
||||
ActionComplianceFrameworkList,
|
||||
).WithSID("compliance-portal-read-access").When(organizationCondition),
|
||||
).WithDescription("Read-only compliance portal access for organization viewers")
|
||||
|
||||
// PolicySet returns the PolicySet for the compliance portal service.
|
||||
func PolicySet() *iam.PolicySet {
|
||||
return iam.NewPolicySet().
|
||||
AddRolePolicy("OWNER", FullAccessPolicy).
|
||||
|
||||
Reference in New Issue
Block a user