Rename backend services for portal

Point domain services, bootstrap, and related
packages at Compliance Portal types so callers
stop depending on the old Trust Center names.

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-07-20 18:08:21 +02:00
parent 4bf3d4df79
commit 0f0f6643ad
47 changed files with 727 additions and 727 deletions

View File

@@ -57,7 +57,7 @@ func FetchSitemapTool() agent.Tool {
return agent.FunctionTool( return agent.FunctionTool(
"fetch_sitemap", "fetch_sitemap",
"Fetch and parse a sitemap XML file. Returns discovered URLs which can reveal pages not linked from the main navigation (trust centers, legal docs, status pages).", "Fetch and parse a sitemap XML file. Returns discovered URLs which can reveal pages not linked from the main navigation (compliance portals, legal docs, status pages).",
func(ctx context.Context, p sitemapParams) (agent.ToolResult, error) { func(ctx context.Context, p sitemapParams) (agent.ToolResult, error) {
if err := validatePublicURL(p.URL); err != nil { if err := validatePublicURL(p.URL); err != nil {
return agent.ResultJSON( return agent.ResultJSON(

View File

@@ -155,7 +155,7 @@ func (b *Builder) Build() (*probodconfig.FullConfig, error) {
), ),
}, },
}, },
TrustCenter: probodconfig.TrustCenterConfig{ CompliancePortal: probodconfig.CompliancePortalConfig{
HTTPAddr: b.resolver.getEnv("PROBOD_TRUST_CENTER_HTTP_ADDR"), HTTPAddr: b.resolver.getEnv("PROBOD_TRUST_CENTER_HTTP_ADDR"),
HTTPSAddr: b.resolver.getEnv("PROBOD_TRUST_CENTER_HTTPS_ADDR"), HTTPSAddr: b.resolver.getEnv("PROBOD_TRUST_CENTER_HTTPS_ADDR"),
BaseDomain: b.resolver.getEnv("PROBOD_TRUST_CENTER_BASE_DOMAIN"), BaseDomain: b.resolver.getEnv("PROBOD_TRUST_CENTER_BASE_DOMAIN"),

View File

@@ -188,10 +188,10 @@ func TestBuilder_Build_Defaults(t *testing.T) {
assert.Empty(t, cfg.Probod.Auth.SAML.DomainVerificationResolverAddr) assert.Empty(t, cfg.Probod.Auth.SAML.DomainVerificationResolverAddr)
// Trust center config // Trust center config
assert.Empty(t, cfg.Probod.TrustCenter.HTTPAddr) assert.Empty(t, cfg.Probod.CompliancePortal.HTTPAddr)
assert.Empty(t, cfg.Probod.TrustCenter.HTTPSAddr) assert.Empty(t, cfg.Probod.CompliancePortal.HTTPSAddr)
assert.Empty(t, cfg.Probod.TrustCenter.BaseDomain) assert.Empty(t, cfg.Probod.CompliancePortal.BaseDomain)
assert.Nil(t, cfg.Probod.TrustCenter.ProxyProtocol.TrustedProxies) assert.Nil(t, cfg.Probod.CompliancePortal.ProxyProtocol.TrustedProxies)
// AWS config // AWS config
assert.Empty(t, cfg.Probod.AWS.Region) assert.Empty(t, cfg.Probod.AWS.Region)
@@ -469,10 +469,10 @@ func TestBuilder_Build_CustomValues(t *testing.T) {
assert.Equal(t, 120, cfg.Probod.Auth.SAML.DomainVerificationIntervalSeconds) assert.Equal(t, 120, cfg.Probod.Auth.SAML.DomainVerificationIntervalSeconds)
assert.Equal(t, "1.1.1.1:53", cfg.Probod.Auth.SAML.DomainVerificationResolverAddr) assert.Equal(t, "1.1.1.1:53", cfg.Probod.Auth.SAML.DomainVerificationResolverAddr)
// Trust center // Trust center
assert.Equal(t, ":8080", cfg.Probod.TrustCenter.HTTPAddr) assert.Equal(t, ":8080", cfg.Probod.CompliancePortal.HTTPAddr)
assert.Equal(t, ":8443", cfg.Probod.TrustCenter.HTTPSAddr) assert.Equal(t, ":8443", cfg.Probod.CompliancePortal.HTTPSAddr)
assert.Equal(t, "probopage.example.com", cfg.Probod.TrustCenter.BaseDomain) assert.Equal(t, "probopage.example.com", cfg.Probod.CompliancePortal.BaseDomain)
assert.Equal(t, []string{"10.0.1.1", "10.0.1.2"}, cfg.Probod.TrustCenter.ProxyProtocol.TrustedProxies) assert.Equal(t, []string{"10.0.1.1", "10.0.1.2"}, cfg.Probod.CompliancePortal.ProxyProtocol.TrustedProxies)
// AWS // AWS
assert.Equal(t, "eu-west-1", cfg.Probod.AWS.Region) assert.Equal(t, "eu-west-1", cfg.Probod.AWS.Region)
assert.Equal(t, "probo-files", cfg.Probod.AWS.Bucket) assert.Equal(t, "probo-files", cfg.Probod.AWS.Bucket)

View File

@@ -173,7 +173,7 @@ func TestWriteConfig_OmitsEmptyOptionalBlocks(t *testing.T) {
Pepper: "pepper", Pepper: "pepper",
}, },
}, },
TrustCenter: probodconfig.TrustCenterConfig{ CompliancePortal: probodconfig.CompliancePortalConfig{
HTTPAddr: ":80", HTTPAddr: ":80",
}, },
CustomDomains: probodconfig.CustomDomainsConfig{ CustomDomains: probodconfig.CustomDomainsConfig{
@@ -222,9 +222,9 @@ func TestWriteConfig_OmitsEmptyOptionalBlocks(t *testing.T) {
require.True(t, ok) require.True(t, ok)
assert.NotContains(t, customDomains, "acme") assert.NotContains(t, customDomains, "acme")
trustCenter, ok := probod["trust-center"].(map[string]any) compliancePortal, ok := probod["trust-center"].(map[string]any)
require.True(t, ok) require.True(t, ok)
assert.NotContains(t, trustCenter, "proxy-protocol") assert.NotContains(t, compliancePortal, "proxy-protocol")
llm, ok := probod["llm"].(map[string]any) llm, ok := probod["llm"].(map[string]any)
require.True(t, ok) require.True(t, ok)
@@ -249,7 +249,7 @@ func TestWriteConfig_OmitsEmptyProxyProtocolAndCorsSlices(t *testing.T) {
AllowedOrigins: []string{}, AllowedOrigins: []string{},
}, },
}, },
TrustCenter: probodconfig.TrustCenterConfig{ CompliancePortal: probodconfig.CompliancePortalConfig{
HTTPAddr: ":10080", HTTPAddr: ":10080",
ProxyProtocol: probodconfig.ProxyProtocolConfig{ ProxyProtocol: probodconfig.ProxyProtocolConfig{
TrustedProxies: make([]string, 0), TrustedProxies: make([]string, 0),
@@ -277,9 +277,9 @@ func TestWriteConfig_OmitsEmptyProxyProtocolAndCorsSlices(t *testing.T) {
assert.NotContains(t, api, "proxy-protocol") assert.NotContains(t, api, "proxy-protocol")
assert.NotContains(t, api, "cors") assert.NotContains(t, api, "cors")
trustCenter, ok := probod["trust-center"].(map[string]any) compliancePortal, ok := probod["trust-center"].(map[string]any)
require.True(t, ok) require.True(t, ok)
assert.NotContains(t, trustCenter, "proxy-protocol") assert.NotContains(t, compliancePortal, "proxy-protocol")
} }
func TestWriteConfig_OmitsEmptyExtraHeaderFieldsMap(t *testing.T) { func TestWriteConfig_OmitsEmptyExtraHeaderFieldsMap(t *testing.T) {

View File

@@ -38,32 +38,32 @@ import (
type ( type (
CreateAccessRequest struct { CreateAccessRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
IdentityID gid.GID IdentityID gid.GID
} }
UpdateDocumentAccessRequest struct { UpdateDocumentAccessRequest struct {
ID gid.GID ID gid.GID
Status coredata.TrustCenterDocumentAccessStatus Status coredata.CompliancePortalDocumentAccessStatus
} }
UpdateAccessRequest struct { UpdateAccessRequest struct {
ID gid.GID ID gid.GID
DocumentAccesses []UpdateDocumentAccessRequest DocumentAccesses []UpdateDocumentAccessRequest
ReportAccesses []UpdateDocumentAccessRequest ReportAccesses []UpdateDocumentAccessRequest
TrustCenterFileAccesses []UpdateDocumentAccessRequest CompliancePortalFileAccesses []UpdateDocumentAccessRequest
} }
AccessData struct { AccessData struct {
TrustCenterID gid.GID `json:"trust_center_id"` CompliancePortalID gid.GID `json:"trust_center_id"`
Email mail.Addr `json:"email"` Email mail.Addr `json:"email"`
} }
) )
func (utcar *UpdateAccessRequest) Validate() error { func (utcar *UpdateAccessRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(utcar.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterAccessEntityType)) v.Check(utcar.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalAccessEntityType))
for i, docAccess := range utcar.DocumentAccesses { for i, docAccess := range utcar.DocumentAccesses {
v.Check(docAccess.ID, fmt.Sprintf("documentAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.DocumentEntityType)) v.Check(docAccess.ID, fmt.Sprintf("documentAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.DocumentEntityType))
@@ -73,8 +73,8 @@ func (utcar *UpdateAccessRequest) Validate() error {
v.Check(reportAccess.ID, fmt.Sprintf("reportAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.FileEntityType)) v.Check(reportAccess.ID, fmt.Sprintf("reportAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.FileEntityType))
} }
for i, reportAccess := range utcar.TrustCenterFileAccesses { for i, reportAccess := range utcar.CompliancePortalFileAccesses {
v.Check(reportAccess.ID, fmt.Sprintf("trustCenterFileAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.TrustCenterFileEntityType)) v.Check(reportAccess.ID, fmt.Sprintf("compliancePortalFileAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.CompliancePortalFileEntityType))
} }
return v.Error() return v.Error()
@@ -84,14 +84,14 @@ func (s *Service) ListAccesses(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
cursor *page.Cursor[coredata.TrustCenterAccessOrderField], cursor *page.Cursor[coredata.CompliancePortalAccessOrderField],
) (*page.Page[*coredata.TrustCenterAccess, coredata.TrustCenterAccessOrderField], error) { ) (*page.Page[*coredata.CompliancePortalAccess, coredata.CompliancePortalAccessOrderField], error) {
var accesses coredata.TrustCenterAccesses var accesses coredata.CompliancePortalAccesses
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
return accesses.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor) return accesses.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
}, },
) )
if err != nil { if err != nil {
@@ -104,15 +104,15 @@ func (s *Service) ListAccesses(
func (s *Service) ListAvailableDocumentAccesses( func (s *Service) ListAvailableDocumentAccesses(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField], cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField],
) (*page.Page[*coredata.TrustCenterDocumentAccess, coredata.TrustCenterDocumentAccessOrderField], error) { ) (*page.Page[*coredata.CompliancePortalDocumentAccess, coredata.CompliancePortalDocumentAccessOrderField], error) {
var documentAccesses coredata.TrustCenterDocumentAccesses var documentAccesses coredata.CompliancePortalDocumentAccesses
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
return documentAccesses.LoadAvailableByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID, cursor) return documentAccesses.LoadAvailableByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID, cursor)
}, },
) )
if err != nil { if err != nil {
@@ -126,8 +126,8 @@ func (s *Service) GetAccess(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
accessID gid.GID, accessID gid.GID,
) (*coredata.TrustCenterAccess, error) { ) (*coredata.CompliancePortalAccess, error) {
var access coredata.TrustCenterAccess var access coredata.CompliancePortalAccess
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -145,7 +145,7 @@ func (s *Service) GetAccess(
func (s *Service) CountDocumentAccesses( func (s *Service) CountDocumentAccesses(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) (int, error) { ) (int, error) {
var count int var count int
@@ -153,11 +153,11 @@ func (s *Service) CountDocumentAccesses(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
var ( var (
documentAccesses coredata.TrustCenterDocumentAccesses documentAccesses coredata.CompliancePortalDocumentAccesses
err error err error
) )
count, err = documentAccesses.CountByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID) count, err = documentAccesses.CountByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
return err return err
}, },
@@ -172,7 +172,7 @@ func (s *Service) CountDocumentAccesses(
func (s *Service) CountPendingRequestDocumentAccesses( func (s *Service) CountPendingRequestDocumentAccesses(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) (int, error) { ) (int, error) {
var count int var count int
@@ -180,11 +180,11 @@ func (s *Service) CountPendingRequestDocumentAccesses(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
var ( var (
documentAccesses coredata.TrustCenterDocumentAccesses documentAccesses coredata.CompliancePortalDocumentAccesses
err error err error
) )
count, err = documentAccesses.CountPendingRequestByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID) count, err = documentAccesses.CountPendingRequestByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
return err return err
}, },
@@ -199,7 +199,7 @@ func (s *Service) CountPendingRequestDocumentAccesses(
func (s *Service) CountActiveDocumentAccesses( func (s *Service) CountActiveDocumentAccesses(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) (int, error) { ) (int, error) {
var count int var count int
@@ -207,11 +207,11 @@ func (s *Service) CountActiveDocumentAccesses(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
var ( var (
documentAccesses coredata.TrustCenterDocumentAccesses documentAccesses coredata.CompliancePortalDocumentAccesses
err error err error
) )
count, err = documentAccesses.CountActiveByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID) count, err = documentAccesses.CountActiveByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
return err return err
}, },
@@ -227,34 +227,34 @@ func (s *Service) UpdateAccess(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *UpdateAccessRequest, req *UpdateAccessRequest,
) (*coredata.TrustCenterAccess, error) { ) (*coredata.CompliancePortalAccess, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
var ( var (
access *coredata.TrustCenterAccess access *coredata.CompliancePortalAccess
trustCenterAcessActivated bool compliancePortalAcessActivated bool
shouldUpdateSlackMessage bool shouldUpdateSlackMessage bool
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
access = &coredata.TrustCenterAccess{} access = &coredata.CompliancePortalAccess{}
if err := access.LoadByID(ctx, tx, scope, req.ID); err != nil { if err := access.LoadByID(ctx, tx, scope, req.ID); err != nil {
return fmt.Errorf("cannot load compliance page access: %w", err) return fmt.Errorf("cannot load compliance page access: %w", err)
} }
var tcdas coredata.TrustCenterDocumentAccesses var tcdas coredata.CompliancePortalDocumentAccesses
if len(req.DocumentAccesses) > 0 { if len(req.DocumentAccesses) > 0 {
var documentData []coredata.MergeTrustCenterDocumentAccessesData var documentData []coredata.MergeCompliancePortalDocumentAccessesData
documentIDs := make([]gid.GID, 0, len(req.DocumentAccesses)) documentIDs := make([]gid.GID, 0, len(req.DocumentAccesses))
for _, d := range req.DocumentAccesses { for _, d := range req.DocumentAccesses {
documentData = append(documentData, coredata.MergeTrustCenterDocumentAccessesData{ documentData = append(documentData, coredata.MergeCompliancePortalDocumentAccessesData{
ID: d.ID, ID: d.ID,
Status: d.Status, Status: d.Status,
}) })
@@ -273,11 +273,11 @@ func (s *Service) UpdateAccess(
} }
if len(req.ReportAccesses) > 0 { if len(req.ReportAccesses) > 0 {
var reportData []coredata.MergeTrustCenterDocumentAccessesData var reportData []coredata.MergeCompliancePortalDocumentAccessesData
reportIDs := make([]gid.GID, 0, len(req.ReportAccesses)) reportIDs := make([]gid.GID, 0, len(req.ReportAccesses))
for _, d := range req.ReportAccesses { for _, d := range req.ReportAccesses {
reportData = append(reportData, coredata.MergeTrustCenterDocumentAccessesData{ reportData = append(reportData, coredata.MergeCompliancePortalDocumentAccessesData{
ID: d.ID, ID: d.ID,
Status: d.Status, Status: d.Status,
}) })
@@ -295,39 +295,39 @@ func (s *Service) UpdateAccess(
} }
} }
if len(req.TrustCenterFileAccesses) > 0 { if len(req.CompliancePortalFileAccesses) > 0 {
var fileData []coredata.MergeTrustCenterDocumentAccessesData var fileData []coredata.MergeCompliancePortalDocumentAccessesData
trustCenterFileIDs := make([]gid.GID, 0, len(req.TrustCenterFileAccesses)) compliancePortalFileIDs := make([]gid.GID, 0, len(req.CompliancePortalFileAccesses))
for _, d := range req.TrustCenterFileAccesses { for _, d := range req.CompliancePortalFileAccesses {
fileData = append(fileData, coredata.MergeTrustCenterDocumentAccessesData{ fileData = append(fileData, coredata.MergeCompliancePortalDocumentAccessesData{
ID: d.ID, ID: d.ID,
Status: d.Status, Status: d.Status,
}) })
trustCenterFileIDs = append(trustCenterFileIDs, d.ID) compliancePortalFileIDs = append(compliancePortalFileIDs, d.ID)
} }
trustCenterFiles := &coredata.TrustCenterFiles{} compliancePortalFiles := &coredata.CompliancePortalFiles{}
if err := trustCenterFiles.LoadByIDs(ctx, tx, scope, trustCenterFileIDs); err != nil { if err := compliancePortalFiles.LoadByIDs(ctx, tx, scope, compliancePortalFileIDs); err != nil {
return fmt.Errorf("cannot load compliance page files: %w", err) return fmt.Errorf("cannot load compliance page files: %w", err)
} }
if err := tcdas.MergeTrustCenterFileAccesses(ctx, tx, scope, access.OrganizationID, access.ID, fileData); err != nil { if err := tcdas.MergeCompliancePortalFileAccesses(ctx, tx, scope, access.OrganizationID, access.ID, fileData); err != nil {
return fmt.Errorf("cannot merge compliance page file accesses: %w", err) return fmt.Errorf("cannot merge compliance page file accesses: %w", err)
} }
} }
if trustCenterAcessActivated { if compliancePortalAcessActivated {
if err := s.sendAccessEmail(ctx, scope, tx, access); err != nil { if err := s.sendAccessEmail(ctx, scope, tx, access); err != nil {
return fmt.Errorf("cannot send access email: %w", err) return fmt.Errorf("cannot send access email: %w", err)
} }
} }
shouldUpdateSlackMessage = trustCenterAcessActivated || shouldUpdateSlackMessage = compliancePortalAcessActivated ||
len(req.DocumentAccesses) > 0 || len(req.DocumentAccesses) > 0 ||
len(req.ReportAccesses) > 0 || len(req.ReportAccesses) > 0 ||
len(req.TrustCenterFileAccesses) > 0 len(req.CompliancePortalFileAccesses) > 0
return nil return nil
}, },
@@ -337,7 +337,7 @@ func (s *Service) UpdateAccess(
} }
if shouldUpdateSlackMessage { if shouldUpdateSlackMessage {
if err := s.SlackMessages.QueueSlackNotification(ctx, scope, access.IdentityID, access.TrustCenterID); err != nil { if err := s.SlackMessages.QueueSlackNotification(ctx, scope, access.IdentityID, access.CompliancePortalID); err != nil {
if !errors.Is(err, slack.ErrNoSlackConnector) { if !errors.Is(err, slack.ErrNoSlackConnector) {
return nil, fmt.Errorf("cannot queue slack notification: %w", err) return nil, fmt.Errorf("cannot queue slack notification: %w", err)
} }
@@ -350,14 +350,14 @@ func (s *Service) UpdateAccess(
func (s *Service) DeleteAccess( func (s *Service) DeleteAccess(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) error { ) error {
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
access := &coredata.TrustCenterAccess{} access := &coredata.CompliancePortalAccess{}
if err := access.LoadByID(ctx, tx, scope, trustCenterAccessID); err != nil { if err := access.LoadByID(ctx, tx, scope, compliancePortalAccessID); err != nil {
return fmt.Errorf("cannot load compliance page access: %w", err) return fmt.Errorf("cannot load compliance page access: %w", err)
} }
@@ -376,7 +376,7 @@ func (s *Service) sendAccessEmail(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
tx pg.Tx, tx pg.Tx,
access *coredata.TrustCenterAccess, access *coredata.CompliancePortalAccess,
) error { ) error {
organization := &coredata.Organization{} organization := &coredata.Organization{}
if err := organization.LoadByID(ctx, tx, scope, access.OrganizationID); err != nil { if err := organization.LoadByID(ctx, tx, scope, access.OrganizationID); err != nil {
@@ -401,14 +401,14 @@ func (s *Service) sendAccessEmail(
return fmt.Errorf("cannot load profile: %w", err) return fmt.Errorf("cannot load profile: %w", err)
} }
emailPresenterCfg, err := s.EmailPresenterConfig(ctx, scope, access.TrustCenterID) emailPresenterCfg, err := s.EmailPresenterConfig(ctx, scope, access.CompliancePortalID)
if err != nil { if err != nil {
return fmt.Errorf("cannot get compliance page email presenter config: %w", err) return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
} }
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName) emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName)
subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterAccess(ctx, organization.Name) subject, textBody, htmlBody, err := emailPresenter.RenderCompliancePortalAccess(ctx, organization.Name)
if err != nil { if err != nil {
return fmt.Errorf("cannot render compliance page access email: %w", err) return fmt.Errorf("cannot render compliance page access email: %w", err)
} }

View File

@@ -34,9 +34,9 @@ import (
type ( type (
CreateCompliancePortalCommitmentGroupRequest struct { CreateCompliancePortalCommitmentGroupRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
Title string Title string
Description string Description string
} }
UpdateCompliancePortalCommitmentGroupRequest struct { UpdateCompliancePortalCommitmentGroupRequest struct {
@@ -50,7 +50,7 @@ type (
func (r *CreateCompliancePortalCommitmentGroupRequest) Validate() error { func (r *CreateCompliancePortalCommitmentGroupRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(r.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(r.Title, "title", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(r.Title, "title", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(r.Description, "description", validator.SafeText(ContentMaxLength)) v.Check(r.Description, "description", validator.SafeText(ContentMaxLength))
@@ -70,7 +70,7 @@ func (r *UpdateCompliancePortalCommitmentGroupRequest) Validate() error {
func (s *Service) ListCommitmentGroups( func (s *Service) ListCommitmentGroups(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField], cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField],
) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) { ) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) {
var groups coredata.CompliancePortalCommitmentGroups var groups coredata.CompliancePortalCommitmentGroups
@@ -78,7 +78,7 @@ func (s *Service) ListCommitmentGroups(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := groups.LoadByTrustCenterID(ctx, conn, scope, trustCenterID, cursor) err := groups.LoadByCompliancePortalID(ctx, conn, scope, compliancePortalID, cursor)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance portal commitment groups: %w", err) return fmt.Errorf("cannot load compliance portal commitment groups: %w", err)
} }
@@ -96,7 +96,7 @@ func (s *Service) ListCommitmentGroups(
func (s *Service) CountCommitmentGroups( func (s *Service) CountCommitmentGroups(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
) (int, error) { ) (int, error) {
var count int var count int
@@ -105,7 +105,7 @@ func (s *Service) CountCommitmentGroups(
func(ctx context.Context, conn pg.Querier) (err error) { func(ctx context.Context, conn pg.Querier) (err error) {
groups := coredata.CompliancePortalCommitmentGroups{} groups := coredata.CompliancePortalCommitmentGroups{}
count, err = groups.CountByTrustCenterID(ctx, conn, scope, trustCenterID) count, err = groups.CountByCompliancePortalID(ctx, conn, scope, compliancePortalID)
if err != nil { if err != nil {
return fmt.Errorf("cannot count compliance portal commitment groups: %w", err) return fmt.Errorf("cannot count compliance portal commitment groups: %w", err)
} }
@@ -163,19 +163,19 @@ func (s *Service) CreateCommitmentGroup(
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
trustCenter := &coredata.TrustCenter{} compliancePortal := &coredata.CompliancePortal{}
if err := trustCenter.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil { if err := compliancePortal.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load trust center: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
group = &coredata.CompliancePortalCommitmentGroup{ group = &coredata.CompliancePortalCommitmentGroup{
ID: groupID, ID: groupID,
OrganizationID: trustCenter.OrganizationID, OrganizationID: compliancePortal.OrganizationID,
TrustCenterID: req.TrustCenterID, CompliancePortalID: req.CompliancePortalID,
Title: req.Title, Title: req.Title,
Description: req.Description, Description: req.Description,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := group.Insert(ctx, tx, scope); err != nil { if err := group.Insert(ctx, tx, scope); err != nil {

View File

@@ -181,16 +181,16 @@ func (s *Service) CreateCommitment(
} }
commitment = &coredata.CompliancePortalCommitment{ commitment = &coredata.CompliancePortalCommitment{
ID: commitmentID, ID: commitmentID,
OrganizationID: group.OrganizationID, OrganizationID: group.OrganizationID,
TrustCenterID: group.TrustCenterID, CompliancePortalID: group.CompliancePortalID,
GroupID: req.GroupID, GroupID: req.GroupID,
Icon: req.Icon, Icon: req.Icon,
Eyebrow: req.Eyebrow, Eyebrow: req.Eyebrow,
Title: req.Title, Title: req.Title,
Description: req.Description, Description: req.Description,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := commitment.Insert(ctx, tx, scope); err != nil { if err := commitment.Insert(ctx, tx, scope); err != nil {

View File

@@ -34,9 +34,9 @@ import (
type ( type (
CreateCustomLinkRequest struct { CreateCustomLinkRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
Name string Name string
URL string URL string
} }
UpdateCustomLinkRequest struct { UpdateCustomLinkRequest struct {
@@ -53,7 +53,7 @@ type (
func (r *CreateCustomLinkRequest) Validate() error { func (r *CreateCustomLinkRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(r.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(r.URL, "url", validator.Required(), validator.URL()) v.Check(r.URL, "url", validator.Required(), validator.URL())
return v.Error() return v.Error()
@@ -86,7 +86,7 @@ func (s *Service) ListCustomLinks(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
if err := items.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor); err != nil { if err := items.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor); err != nil {
return fmt.Errorf("cannot load custom links: %w", err) return fmt.Errorf("cannot load custom links: %w", err)
} }
@@ -117,19 +117,19 @@ func (s *Service) CreateCustomLink(
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
item = &coredata.ComplianceCustomLink{ item = &coredata.ComplianceCustomLink{
ID: id, ID: id,
OrganizationID: compliancePage.OrganizationID, OrganizationID: compliancePage.OrganizationID,
TrustCenterID: req.TrustCenterID, CompliancePortalID: req.CompliancePortalID,
Name: req.Name, Name: req.Name,
URL: req.URL, URL: req.URL,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := item.Insert(ctx, tx, scope); err != nil { if err := item.Insert(ctx, tx, scope); err != nil {

View File

@@ -23,11 +23,11 @@ import (
"go.probo.inc/probo/pkg/gid" "go.probo.inc/probo/pkg/gid"
) )
func (s *Service) EffectiveDomainForCompliancePage( func (s *Service) EffectiveDomainForCompliancePortal(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope coredata.Scoper, scope coredata.Scoper,
compliancePage *coredata.TrustCenter, compliancePage *coredata.CompliancePortal,
) (*coredata.CustomDomain, error) { ) (*coredata.CustomDomain, error) {
byID, active, err := loadDomains(ctx, conn, scope, compliancePage) byID, active, err := loadDomains(ctx, conn, scope, compliancePage)
if err != nil { if err != nil {
@@ -49,11 +49,11 @@ func (s *Service) EffectiveDomainForCompliancePage(
return nil, nil return nil, nil
} }
func (s *Service) PublicURLForCompliancePage( func (s *Service) PublicURLForCompliancePortal(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope coredata.Scoper, scope coredata.Scoper,
compliancePage *coredata.TrustCenter, compliancePage *coredata.CompliancePortal,
) (string, error) { ) (string, error) {
byID, active, err := loadDomains(ctx, conn, scope, compliancePage) byID, active, err := loadDomains(ctx, conn, scope, compliancePage)
if err != nil { if err != nil {
@@ -80,7 +80,7 @@ func loadDomains(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope coredata.Scoper, scope coredata.Scoper,
compliancePage *coredata.TrustCenter, compliancePage *coredata.CompliancePortal,
) (map[gid.GID]*coredata.CustomDomain, map[gid.GID]bool, error) { ) (map[gid.GID]*coredata.CustomDomain, map[gid.GID]bool, error) {
var ids []gid.GID var ids []gid.GID
if compliancePage.CustomDomainID != nil { if compliancePage.CustomDomainID != nil {

View File

@@ -35,7 +35,7 @@ func (s *Service) AddCustomDomain(
domain string, domain string,
) (*coredata.CustomDomain, error) { ) (*coredata.CustomDomain, error) {
v := validator.New() v := validator.New()
v.Check(compliancePageID, "compliance_page_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(compliancePageID, "compliance_page_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(domain, "domain", validator.Required(), validator.NotEmpty(), validator.Domain()) v.Check(domain, "domain", validator.Required(), validator.NotEmpty(), validator.Domain())
if err := v.Error(); err != nil { if err := v.Error(); err != nil {
@@ -47,7 +47,7 @@ func (s *Service) AddCustomDomain(
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -107,7 +107,7 @@ func (s *Service) RemoveCustomDomain(
return ErrCustomDomainManaged return ErrCustomDomainManaged
} }
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
err := compliancePage.LoadByDomainID(ctx, tx, customDomainID) err := compliancePage.LoadByDomainID(ctx, tx, customDomainID)
switch { switch {
@@ -177,14 +177,14 @@ func (s *Service) PublicURL(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
var err error var err error
publicURL, err = s.PublicURLForCompliancePage(ctx, conn, scope, compliancePage) publicURL, err = s.PublicURLForCompliancePortal(ctx, conn, scope, compliancePage)
if err != nil { if err != nil {
return fmt.Errorf("cannot resolve public url: %w", err) return fmt.Errorf("cannot resolve public url: %w", err)
} }

View File

@@ -41,18 +41,18 @@ import (
type ( type (
CreateFileRequest struct { CreateFileRequest struct {
OrganizationID gid.GID OrganizationID gid.GID
Name string Name string
Category string Category string
File File File File
TrustCenterVisibility coredata.TrustCenterVisibility CompliancePortalVisibility coredata.CompliancePortalVisibility
} }
UpdateFileRequest struct { UpdateFileRequest struct {
ID gid.GID ID gid.GID
Name *string Name *string
Category *string Category *string
TrustCenterVisibility *coredata.TrustCenterVisibility CompliancePortalVisibility *coredata.CompliancePortalVisibility
} }
) )
@@ -63,7 +63,7 @@ func (ctcfr *CreateFileRequest) Validate() error {
v.Check(ctcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(ctcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(ctcfr.Category, "category", validator.Required(), validator.SafeText(TitleMaxLength)) v.Check(ctcfr.Category, "category", validator.Required(), validator.SafeText(TitleMaxLength))
v.Check(ctcfr.File, "file", validator.Required()) v.Check(ctcfr.File, "file", validator.Required())
v.Check(ctcfr.TrustCenterVisibility, "trust_center_visibility", validator.Required(), validator.OneOfSlice(coredata.TrustCenterVisibilities())) v.Check(ctcfr.CompliancePortalVisibility, "trust_center_visibility", validator.Required(), validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
return v.Error() return v.Error()
} }
@@ -71,10 +71,10 @@ func (ctcfr *CreateFileRequest) Validate() error {
func (utcfr *UpdateFileRequest) Validate() error { func (utcfr *UpdateFileRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(utcfr.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterFileEntityType)) v.Check(utcfr.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalFileEntityType))
v.Check(utcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(utcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(utcfr.Category, "category", validator.SafeText(TitleMaxLength)) v.Check(utcfr.Category, "category", validator.SafeText(TitleMaxLength))
v.Check(utcfr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities())) v.Check(utcfr.CompliancePortalVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
return v.Error() return v.Error()
} }
@@ -83,10 +83,10 @@ func (s *Service) ListFilesForOrganizationID(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
organizationID gid.GID, organizationID gid.GID,
cursor *page.Cursor[coredata.TrustCenterFileOrderField], cursor *page.Cursor[coredata.CompliancePortalFileOrderField],
filter *coredata.TrustCenterFileFilter, filter *coredata.CompliancePortalFileFilter,
) (*page.Page[*coredata.TrustCenterFile, coredata.TrustCenterFileOrderField], error) { ) (*page.Page[*coredata.CompliancePortalFile, coredata.CompliancePortalFileOrderField], error) {
var files coredata.TrustCenterFiles var files coredata.CompliancePortalFiles
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -116,7 +116,7 @@ func (s *Service) CountFilesForOrganizationID(
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
var err error var err error
count, err = (&coredata.TrustCenterFiles{}).CountByOrganizationID(ctx, conn, scope, organizationID) count, err = (&coredata.CompliancePortalFiles{}).CountByOrganizationID(ctx, conn, scope, organizationID)
if err != nil { if err != nil {
return fmt.Errorf("cannot count compliance page files: %w", err) return fmt.Errorf("cannot count compliance page files: %w", err)
} }
@@ -134,13 +134,13 @@ func (s *Service) GetFile(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
id gid.GID, id gid.GID,
) (*coredata.TrustCenterFile, error) { ) (*coredata.CompliancePortalFile, error) {
var file *coredata.TrustCenterFile var file *coredata.CompliancePortalFile
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
file = &coredata.TrustCenterFile{} file = &coredata.CompliancePortalFile{}
if err := file.LoadByID(ctx, conn, scope, id); err != nil { if err := file.LoadByID(ctx, conn, scope, id); err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err) return fmt.Errorf("cannot load compliance page file: %w", err)
} }
@@ -159,7 +159,7 @@ func (s *Service) CreateFile(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *CreateFileRequest, req *CreateFileRequest,
) (*coredata.TrustCenterFile, error) { ) (*coredata.CompliancePortalFile, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
@@ -179,32 +179,32 @@ func (s *Service) CreateFile(
now := time.Now() now := time.Now()
trustCenterFileID := gid.New(scope.GetTenantID(), coredata.TrustCenterFileEntityType) compliancePortalFileID := gid.New(scope.GetTenantID(), coredata.CompliancePortalFileEntityType)
var ( var (
file *coredata.TrustCenterFile file *coredata.CompliancePortalFile
s3Key string s3Key string
) )
err = s.pg.WithTx( err = s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
fileID, objectKey, err := s.uploadFile(ctx, scope, tx, req.File, trustCenterFileID, req.OrganizationID, now) fileID, objectKey, err := s.uploadFile(ctx, scope, tx, req.File, compliancePortalFileID, req.OrganizationID, now)
if err != nil { if err != nil {
return fmt.Errorf("cannot upload file: %w", err) return fmt.Errorf("cannot upload file: %w", err)
} }
s3Key = objectKey s3Key = objectKey
file = &coredata.TrustCenterFile{ file = &coredata.CompliancePortalFile{
ID: trustCenterFileID, ID: compliancePortalFileID,
OrganizationID: req.OrganizationID, OrganizationID: req.OrganizationID,
Name: req.Name, Name: req.Name,
Category: req.Category, Category: req.Category,
FileID: fileID, FileID: fileID,
TrustCenterVisibility: req.TrustCenterVisibility, CompliancePortalVisibility: req.CompliancePortalVisibility,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := file.Insert(ctx, tx, scope); err != nil { if err := file.Insert(ctx, tx, scope); err != nil {
@@ -226,19 +226,19 @@ func (s *Service) UpdateFile(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *UpdateFileRequest, req *UpdateFileRequest,
) (*coredata.TrustCenterFile, error) { ) (*coredata.CompliancePortalFile, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
now := time.Now() now := time.Now()
var file *coredata.TrustCenterFile var file *coredata.CompliancePortalFile
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
file = &coredata.TrustCenterFile{} file = &coredata.CompliancePortalFile{}
if err := file.LoadByID(ctx, tx, scope, req.ID); err != nil { if err := file.LoadByID(ctx, tx, scope, req.ID); err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err) return fmt.Errorf("cannot load compliance page file: %w", err)
@@ -252,8 +252,8 @@ func (s *Service) UpdateFile(
file.Category = *req.Category file.Category = *req.Category
} }
if req.TrustCenterVisibility != nil { if req.CompliancePortalVisibility != nil {
file.TrustCenterVisibility = *req.TrustCenterVisibility file.CompliancePortalVisibility = *req.CompliancePortalVisibility
} }
file.UpdatedAt = now file.UpdatedAt = now
@@ -275,14 +275,14 @@ func (s *Service) UpdateFile(
func (s *Service) DeleteFile( func (s *Service) DeleteFile(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) error { ) error {
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
file := &coredata.TrustCenterFile{} file := &coredata.CompliancePortalFile{}
if err := file.LoadByID(ctx, tx, scope, trustCenterFileID); err != nil { if err := file.LoadByID(ctx, tx, scope, compliancePortalFileID); err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err) return fmt.Errorf("cannot load compliance page file: %w", err)
} }
@@ -299,7 +299,7 @@ func (s *Service) DeleteFile(
func (s *Service) GenerateFileURL( func (s *Service) GenerateFileURL(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
duration time.Duration, duration time.Duration,
) (string, error) { ) (string, error) {
var storedFile *coredata.File var storedFile *coredata.File
@@ -307,8 +307,8 @@ func (s *Service) GenerateFileURL(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
file := &coredata.TrustCenterFile{} file := &coredata.CompliancePortalFile{}
if err := file.LoadByID(ctx, conn, scope, trustCenterFileID); err != nil { if err := file.LoadByID(ctx, conn, scope, compliancePortalFileID); err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err) return fmt.Errorf("cannot load compliance page file: %w", err)
} }
@@ -337,7 +337,7 @@ func (s *Service) uploadFile(
scope coredata.Scoper, scope coredata.Scoper,
tx pg.Tx, tx pg.Tx,
file File, file File,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
organizationID gid.GID, organizationID gid.GID,
now time.Time, now time.Time,
) (gid.GID, string, error) { ) (gid.GID, string, error) {
@@ -404,7 +404,7 @@ func (s *Service) uploadFile(
CacheControl: new("private, max-age=3600"), CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{ Metadata: map[string]string{
"type": "compliance-page-file", "type": "compliance-page-file",
"compliance-page-file-id": trustCenterFileID.String(), "compliance-page-file-id": compliancePortalFileID.String(),
"organization-id": organizationID.String(), "organization-id": organizationID.String(),
}, },
}, },

View File

@@ -34,8 +34,8 @@ import (
type ( type (
CreateFrameworkRequest struct { CreateFrameworkRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
FrameworkID gid.GID FrameworkID gid.GID
} }
UpdateFrameworkRequest struct { UpdateFrameworkRequest struct {
@@ -51,7 +51,7 @@ type (
func (r *CreateFrameworkRequest) Validate() error { func (r *CreateFrameworkRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(r.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(r.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(r.FrameworkID, "framework_id", validator.Required(), validator.GID(coredata.FrameworkEntityType)) v.Check(r.FrameworkID, "framework_id", validator.Required(), validator.GID(coredata.FrameworkEntityType))
return v.Error() return v.Error()
@@ -84,7 +84,7 @@ func (s *Service) ListFrameworksWithHidden(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
if err := cfs.LoadWithHiddenByTrustCenterID(ctx, conn, scope, compliancePageID, cursor); err != nil { if err := cfs.LoadWithHiddenByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor); err != nil {
return fmt.Errorf("cannot load frameworks with hidden: %w", err) return fmt.Errorf("cannot load frameworks with hidden: %w", err)
} }
@@ -116,8 +116,8 @@ func (s *Service) CreateFramework(
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -127,12 +127,12 @@ func (s *Service) CreateFramework(
} }
cf = &coredata.ComplianceFramework{ cf = &coredata.ComplianceFramework{
ID: cfID, ID: cfID,
OrganizationID: compliancePage.OrganizationID, OrganizationID: compliancePage.OrganizationID,
TrustCenterID: req.TrustCenterID, CompliancePortalID: req.CompliancePortalID,
FrameworkID: req.FrameworkID, FrameworkID: req.FrameworkID,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := cf.Insert(ctx, tx, scope); err != nil { if err := cf.Insert(ctx, tx, scope); err != nil {

View File

@@ -54,15 +54,15 @@ type (
} }
UploadNDARequest struct { UploadNDARequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
File io.Reader File io.Reader
FileName string FileName string
} }
UpdateBrandRequest struct { UpdateBrandRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
LogoFile **FileUpload LogoFile **FileUpload
DarkLogoFile **FileUpload DarkLogoFile **FileUpload
} }
) )
@@ -71,7 +71,7 @@ const maxBrandFileSize = 5 * 1024 * 1024 // 5MB
func (utcr *UpdateRequest) Validate() error { func (utcr *UpdateRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(utcr.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(utcr.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(utcr.Slug, "slug", validator.SafeText(NameMaxLength)) v.Check(utcr.Slug, "slug", validator.SafeText(NameMaxLength))
v.Check(utcr.NonDisclosureAgreementFileID, "non_disclosure_agreement_file_id", validator.GID(coredata.FileEntityType)) v.Check(utcr.NonDisclosureAgreementFileID, "non_disclosure_agreement_file_id", validator.GID(coredata.FileEntityType))
@@ -101,7 +101,7 @@ func (utcr *UpdateRequest) Validate() error {
func (utcndar *UploadNDARequest) Validate() error { func (utcndar *UploadNDARequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(utcndar.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(utcndar.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(utcndar.FileName, "file_name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(utcndar.FileName, "file_name", validator.SafeTextNoNewLine(TitleMaxLength))
return v.Error() return v.Error()
@@ -134,13 +134,13 @@ func (s *Service) Get(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
) (*coredata.TrustCenter, error) { ) (*coredata.CompliancePortal, error) {
var compliancePage *coredata.TrustCenter var compliancePage *coredata.CompliancePortal
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -159,13 +159,13 @@ func (s *Service) GetByOrganizationID(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
organizationID gid.GID, organizationID gid.GID,
) (*coredata.TrustCenter, error) { ) (*coredata.CompliancePortal, error) {
var compliancePage *coredata.TrustCenter var compliancePage *coredata.CompliancePortal
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByOrganizationID(ctx, conn, scope, organizationID); err != nil { if err := compliancePage.LoadByOrganizationID(ctx, conn, scope, organizationID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -184,20 +184,20 @@ func (s *Service) Update(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *UpdateRequest, req *UpdateRequest,
) (*coredata.TrustCenter, *coredata.File, error) { ) (*coredata.CompliancePortal, *coredata.File, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, nil, err return nil, nil, err
} }
var ( var (
compliancePage *coredata.TrustCenter compliancePage *coredata.CompliancePortal
file *coredata.File file *coredata.File
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, req.ID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, req.ID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -267,26 +267,26 @@ func (s *Service) UploadNDA(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *UploadNDARequest, req *UploadNDARequest,
) (*coredata.TrustCenter, *coredata.File, error) { ) (*coredata.CompliancePortal, *coredata.File, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, nil, err return nil, nil, err
} }
var ( var (
compliancePage *coredata.TrustCenter compliancePage *coredata.CompliancePortal
file *coredata.File file *coredata.File
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, req.TrustCenterID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
if compliancePage.OrganizationID == gid.Nil { if compliancePage.OrganizationID == gid.Nil {
return fmt.Errorf("compliance page %s has no organization", req.TrustCenterID) return fmt.Errorf("compliance page %s has no organization", req.CompliancePortalID)
} }
objectKey, err := uuid.NewV7() objectKey, err := uuid.NewV7()
@@ -320,7 +320,7 @@ func (s *Service) UploadNDA(
req.File, req.File,
map[string]string{ map[string]string{
"type": "compliance-page-nda", "type": "compliance-page-nda",
"compliance-page-id": req.TrustCenterID.String(), "compliance-page-id": req.CompliancePortalID.String(),
"organization-id": compliancePage.OrganizationID.String(), "organization-id": compliancePage.OrganizationID.String(),
}, },
) )
@@ -355,13 +355,13 @@ func (s *Service) DeleteNDA(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
) (*coredata.TrustCenter, *coredata.File, error) { ) (*coredata.CompliancePortal, *coredata.File, error) {
var compliancePage *coredata.TrustCenter var compliancePage *coredata.CompliancePortal
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -387,21 +387,21 @@ func (s *Service) UpdateBrand(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *UpdateBrandRequest, req *UpdateBrandRequest,
) (*coredata.TrustCenter, *coredata.File, error) { ) (*coredata.CompliancePortal, *coredata.File, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, nil, err return nil, nil, err
} }
var ( var (
compliancePage *coredata.TrustCenter compliancePage *coredata.CompliancePortal
ndaFile *coredata.File ndaFile *coredata.File
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, conn pg.Tx) error { func(ctx context.Context, conn pg.Tx) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, req.TrustCenterID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -462,7 +462,7 @@ func (s *Service) uploadBrandFile(
conn pg.Tx, conn pg.Tx,
fileUpload *FileUpload, fileUpload *FileUpload,
fileType string, fileType string,
compliancePage *coredata.TrustCenter, compliancePage *coredata.CompliancePortal,
) (*coredata.File, error) { ) (*coredata.File, error) {
objectKey, err := uuid.NewV7() objectKey, err := uuid.NewV7()
if err != nil { if err != nil {
@@ -529,7 +529,7 @@ func (s *Service) GenerateNDAFileURL(
) (*string, error) { ) (*string, error) {
var file *coredata.File var file *coredata.File
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -573,7 +573,7 @@ func (s *Service) GenerateLogoURL(
expiresIn time.Duration, expiresIn time.Duration,
) (*string, error) { ) (*string, error) {
file := &coredata.File{} file := &coredata.File{}
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -620,7 +620,7 @@ func (s *Service) GenerateDarkLogoURL(
expiresIn time.Duration, expiresIn time.Duration,
) (*string, error) { ) (*string, error) {
file := &coredata.File{} file := &coredata.File{}
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -666,7 +666,7 @@ func (s *Service) EmailPresenterConfig(
compliancePageID gid.GID, compliancePageID gid.GID,
) (emails.PresenterConfig, error) { ) (emails.PresenterConfig, error) {
var ( var (
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
organization = &coredata.Organization{} organization = &coredata.Organization{}
logoFile = &coredata.File{} logoFile = &coredata.File{}
compliancePageURL string compliancePageURL string
@@ -690,7 +690,7 @@ func (s *Service) EmailPresenterConfig(
return fmt.Errorf("cannot load organization: %w", err) return fmt.Errorf("cannot load organization: %w", err)
} }
publicURL, err := s.PublicURLForCompliancePage(ctx, conn, scope, compliancePage) publicURL, err := s.PublicURLForCompliancePortal(ctx, conn, scope, compliancePage)
if err != nil { if err != nil {
return fmt.Errorf("cannot resolve compliance page URL: %w", err) return fmt.Errorf("cannot resolve compliance page URL: %w", err)
} }
@@ -736,7 +736,7 @@ func (s *Service) GetMailingList(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }

View File

@@ -40,11 +40,11 @@ import (
type ( type (
CreateReferenceRequest struct { CreateReferenceRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
Name string Name string
Description *string Description *string
WebsiteURL string WebsiteURL string
LogoFile File LogoFile File
} }
UpdateReferenceRequest struct { UpdateReferenceRequest struct {
@@ -60,7 +60,7 @@ type (
func (ctcrr *CreateReferenceRequest) Validate() error { func (ctcrr *CreateReferenceRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(ctcrr.TrustCenterID, "trust_center_id", validator.Required(), validator.GID(coredata.TrustCenterEntityType)) v.Check(ctcrr.CompliancePortalID, "trust_center_id", validator.Required(), validator.GID(coredata.CompliancePortalEntityType))
v.Check(ctcrr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(ctcrr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(ctcrr.Description, "description", validator.SafeText(ContentMaxLength)) v.Check(ctcrr.Description, "description", validator.SafeText(ContentMaxLength))
v.Check(ctcrr.WebsiteURL, "website_url", validator.Required(), validator.SafeText(2048)) v.Check(ctcrr.WebsiteURL, "website_url", validator.Required(), validator.SafeText(2048))
@@ -71,7 +71,7 @@ func (ctcrr *CreateReferenceRequest) Validate() error {
func (utcrr *UpdateReferenceRequest) Validate() error { func (utcrr *UpdateReferenceRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(utcrr.ID, "id", validator.Required(), validator.GID(coredata.TrustCenterReferenceEntityType)) v.Check(utcrr.ID, "id", validator.Required(), validator.GID(coredata.CompliancePortalReferenceEntityType))
v.Check(utcrr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(utcrr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(utcrr.Description, "description", validator.SafeText(ContentMaxLength)) v.Check(utcrr.Description, "description", validator.SafeText(ContentMaxLength))
v.Check(utcrr.WebsiteURL, "website_url", validator.SafeText(2048)) v.Check(utcrr.WebsiteURL, "website_url", validator.SafeText(2048))
@@ -83,14 +83,14 @@ func (s *Service) ListReferences(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
cursor *page.Cursor[coredata.TrustCenterReferenceOrderField], cursor *page.Cursor[coredata.CompliancePortalReferenceOrderField],
) (*page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField], error) { ) (*page.Page[*coredata.CompliancePortalReference, coredata.CompliancePortalReferenceOrderField], error) {
var references coredata.TrustCenterReferences var references coredata.CompliancePortalReferences
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := references.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor) err := references.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance page references: %w", err) return fmt.Errorf("cannot load compliance page references: %w", err)
} }
@@ -115,9 +115,9 @@ func (s *Service) CountReferences(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) (err error) { func(ctx context.Context, conn pg.Querier) (err error) {
references := coredata.TrustCenterReferences{} references := coredata.CompliancePortalReferences{}
count, err = references.CountByTrustCenterID(ctx, conn, scope, compliancePageID) count, err = references.CountByCompliancePortalID(ctx, conn, scope, compliancePageID)
if err != nil { if err != nil {
return fmt.Errorf("cannot count compliance page references: %w", err) return fmt.Errorf("cannot count compliance page references: %w", err)
} }
@@ -136,8 +136,8 @@ func (s *Service) GetReference(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
referenceID gid.GID, referenceID gid.GID,
) (*coredata.TrustCenterReference, error) { ) (*coredata.CompliancePortalReference, error) {
var reference coredata.TrustCenterReference var reference coredata.CompliancePortalReference
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -161,44 +161,44 @@ func (s *Service) CreateReference(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *CreateReferenceRequest, req *CreateReferenceRequest,
) (*coredata.TrustCenterReference, error) { ) (*coredata.CompliancePortalReference, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
now := time.Now() now := time.Now()
referenceID := gid.New(scope.GetTenantID(), coredata.TrustCenterReferenceEntityType) referenceID := gid.New(scope.GetTenantID(), coredata.CompliancePortalReferenceEntityType)
var reference *coredata.TrustCenterReference var reference *coredata.CompliancePortalReference
var logoKey string var logoKey string
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, req.LogoFile, referenceID, req.TrustCenterID, now) fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, req.LogoFile, referenceID, req.CompliancePortalID, now)
if err != nil { if err != nil {
return fmt.Errorf("cannot upload logo file: %w", err) return fmt.Errorf("cannot upload logo file: %w", err)
} }
logoKey = s3Key logoKey = s3Key
reference = &coredata.TrustCenterReference{ reference = &coredata.CompliancePortalReference{
ID: referenceID, ID: referenceID,
OrganizationID: compliancePage.OrganizationID, OrganizationID: compliancePage.OrganizationID,
TrustCenterID: req.TrustCenterID, CompliancePortalID: req.CompliancePortalID,
Name: req.Name, Name: req.Name,
Description: req.Description, Description: req.Description,
WebsiteURL: req.WebsiteURL, WebsiteURL: req.WebsiteURL,
LogoFileID: fileID, LogoFileID: fileID,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := reference.Insert(ctx, tx, scope); err != nil { if err := reference.Insert(ctx, tx, scope); err != nil {
@@ -220,7 +220,7 @@ func (s *Service) UpdateReference(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *UpdateReferenceRequest, req *UpdateReferenceRequest,
) (*coredata.TrustCenterReference, error) { ) (*coredata.CompliancePortalReference, error) {
if err := req.Validate(); err != nil { if err := req.Validate(); err != nil {
return nil, err return nil, err
} }
@@ -228,7 +228,7 @@ func (s *Service) UpdateReference(
now := time.Now() now := time.Now()
var ( var (
reference *coredata.TrustCenterReference reference *coredata.CompliancePortalReference
newFileID *gid.GID newFileID *gid.GID
logoKey string logoKey string
) )
@@ -236,14 +236,14 @@ func (s *Service) UpdateReference(
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
reference = &coredata.TrustCenterReference{} reference = &coredata.CompliancePortalReference{}
if err := reference.LoadByID(ctx, tx, scope, req.ID); err != nil { if err := reference.LoadByID(ctx, tx, scope, req.ID); err != nil {
return fmt.Errorf("cannot load compliance page reference: %w", err) return fmt.Errorf("cannot load compliance page reference: %w", err)
} }
if req.LogoFile != nil { if req.LogoFile != nil {
fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, *req.LogoFile, req.ID, reference.TrustCenterID, now) fileID, s3Key, err := s.uploadReferenceLogoFile(ctx, scope, tx, *req.LogoFile, req.ID, reference.CompliancePortalID, now)
if err != nil { if err != nil {
return fmt.Errorf("cannot upload logo file: %w", err) return fmt.Errorf("cannot upload logo file: %w", err)
} }
@@ -295,14 +295,14 @@ func (s *Service) UpdateReference(
func (s *Service) DeleteReference( func (s *Service) DeleteReference(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterReferenceID gid.GID, compliancePortalReferenceID gid.GID,
) error { ) error {
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
reference := &coredata.TrustCenterReference{} reference := &coredata.CompliancePortalReference{}
if err := reference.LoadByID(ctx, tx, scope, trustCenterReferenceID); err != nil { if err := reference.LoadByID(ctx, tx, scope, compliancePortalReferenceID); err != nil {
return fmt.Errorf("cannot load compliance page reference: %w", err) return fmt.Errorf("cannot load compliance page reference: %w", err)
} }
@@ -322,7 +322,7 @@ func (s *Service) GenerateReferenceLogoURL(
scope coredata.Scoper, scope coredata.Scoper,
referenceID gid.GID, referenceID gid.GID,
) (string, error) { ) (string, error) {
reference := &coredata.TrustCenterReference{} reference := &coredata.CompliancePortalReference{}
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
@@ -358,7 +358,7 @@ func (s *Service) uploadReferenceLogoFile(
return gid.GID{}, "", fmt.Errorf("cannot generate object key: %w", err) return gid.GID{}, "", fmt.Errorf("cannot generate object key: %w", err)
} }
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
return gid.GID{}, "", fmt.Errorf("cannot load compliance page: %w", err) return gid.GID{}, "", fmt.Errorf("cannot load compliance page: %w", err)
} }

View File

@@ -89,7 +89,7 @@ func (s *Service) ListAuditsForOrganizationID(
var audits coredata.Audits var audits coredata.Audits
if filter == nil { if filter == nil {
filter = coredata.NewAuditTrustCenterFilter() filter = coredata.NewAuditCompliancePortalFilter()
} }
err := s.pg.WithConn( err := s.pg.WithConn(

View File

@@ -65,7 +65,7 @@ func PortalBaseURLFromCIMDClientID(clientIDURL string) (string, error) {
} }
func BuildClientMetadataDocument( func BuildClientMetadataDocument(
portal *coredata.TrustCenter, portal *coredata.CompliancePortal,
portalBaseURL string, portalBaseURL string,
) (oauth2.ClientMetadataDocument, error) { ) (oauth2.ClientMetadataDocument, error) {
clientID, err := CIMDClientIDURL(portalBaseURL) clientID, err := CIMDClientIDURL(portalBaseURL)

View File

@@ -65,7 +65,7 @@ func TestBuildClientMetadataDocument(t *testing.T) {
t.Parallel() t.Parallel()
websiteURL := "https://www.acme.com" websiteURL := "https://www.acme.com"
portal := &coredata.TrustCenter{ portal := &coredata.CompliancePortal{
Title: "Acme Compliance Page", Title: "Acme Compliance Page",
WebsiteURL: &websiteURL, WebsiteURL: &websiteURL,
} }
@@ -87,7 +87,7 @@ func TestBuildClientMetadataDocument_LogoURIUsesBrandLogoEndpoint(t *testing.T)
t.Parallel() t.Parallel()
logoFileID := gid.MustParseGID("WR-qMrB5AAEAGQAAAZ9mIO8B8vDFQ-i3") logoFileID := gid.MustParseGID("WR-qMrB5AAEAGQAAAZ9mIO8B8vDFQ-i3")
portal := &coredata.TrustCenter{ portal := &coredata.CompliancePortal{
Title: "Acme Compliance Page", Title: "Acme Compliance Page",
LogoFileID: &logoFileID, LogoFileID: &logoFileID,
} }

View File

@@ -66,7 +66,7 @@ func (s *Service) ListComplianceFrameworksByPortalID(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := complianceFrameworks.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor) err := complianceFrameworks.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance frameworks: %w", err) return fmt.Errorf("cannot load compliance frameworks: %w", err)
} }

View File

@@ -33,7 +33,7 @@ import (
func (s *Service) ListCommitmentGroupsForPortalID( func (s *Service) ListCommitmentGroupsForPortalID(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterID gid.GID, compliancePortalID gid.GID,
cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField], cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField],
) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) { ) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) {
var groups coredata.CompliancePortalCommitmentGroups var groups coredata.CompliancePortalCommitmentGroups
@@ -41,7 +41,7 @@ func (s *Service) ListCommitmentGroupsForPortalID(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := groups.LoadByTrustCenterID(ctx, conn, scope, trustCenterID, cursor) err := groups.LoadByCompliancePortalID(ctx, conn, scope, compliancePortalID, cursor)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance portal commitment groups: %w", err) return fmt.Errorf("cannot load compliance portal commitment groups: %w", err)
} }

View File

@@ -119,7 +119,7 @@ type (
} }
) )
func (s *Service) RenderCompliancePageMarkdown( func (s *Service) RenderCompliancePortalMarkdown(
ctx context.Context, ctx context.Context,
w io.Writer, w io.Writer,
compliancePageID gid.GID, compliancePageID gid.GID,
@@ -286,7 +286,7 @@ func (s *Service) fetchDocumentIDs(
} }
for _, doc := range result.Data { for _, doc := range result.Data {
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue continue
} }
@@ -308,8 +308,8 @@ func (s *Service) fetchDocumentIDs(
page.MaxCursorSize, page.MaxCursorSize,
cursorKey, cursorKey,
page.Head, page.Head,
page.OrderBy[coredata.TrustCenterFileOrderField]{ page.OrderBy[coredata.CompliancePortalFileOrderField]{
Field: coredata.TrustCenterFileOrderFieldCreatedAt, Field: coredata.CompliancePortalFileOrderFieldCreatedAt,
Direction: page.OrderDirectionAsc, Direction: page.OrderDirectionAsc,
}, },
) )
@@ -319,14 +319,14 @@ func (s *Service) fetchDocumentIDs(
scope, scope,
orgID, orgID,
cursor, cursor,
coredata.NewTrustCenterFileFilter(), coredata.NewCompliancePortalFileFilter(),
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot list compliance page files: %w", err) return nil, fmt.Errorf("cannot list compliance page files: %w", err)
} }
for _, file := range result.Data { for _, file := range result.Data {
if file.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if file.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue continue
} }
@@ -338,7 +338,7 @@ func (s *Service) fetchDocumentIDs(
} }
last := result.Data[len(result.Data)-1] last := result.Data[len(result.Data)-1]
ck := last.CursorKey(coredata.TrustCenterFileOrderFieldCreatedAt) ck := last.CursorKey(coredata.CompliancePortalFileOrderFieldCreatedAt)
cursorKey = &ck cursorKey = &ck
} }
@@ -360,7 +360,7 @@ func (s *Service) fetchDocumentIDs(
} }
for _, audit := range result.Data { for _, audit := range result.Data {
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if audit.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue continue
} }
@@ -477,7 +477,7 @@ func (s *Service) fetchDocuments(
} }
for _, doc := range result.Data { for _, doc := range result.Data {
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue continue
} }
@@ -527,7 +527,7 @@ func (s *Service) fetchAudits(
} }
for _, audit := range result.Data { for _, audit := range result.Data {
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if audit.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue continue
} }
@@ -631,8 +631,8 @@ func (s *Service) fetchReferences(
page.MaxCursorSize, page.MaxCursorSize,
cursorKey, cursorKey,
page.Head, page.Head,
page.OrderBy[coredata.TrustCenterReferenceOrderField]{ page.OrderBy[coredata.CompliancePortalReferenceOrderField]{
Field: coredata.TrustCenterReferenceOrderFieldRank, Field: coredata.CompliancePortalReferenceOrderFieldRank,
Direction: page.OrderDirectionAsc, Direction: page.OrderDirectionAsc,
}, },
) )
@@ -659,7 +659,7 @@ func (s *Service) fetchReferences(
} }
last := result.Data[len(result.Data)-1] last := result.Data[len(result.Data)-1]
ck := last.CursorKey(coredata.TrustCenterReferenceOrderFieldRank) ck := last.CursorKey(coredata.CompliancePortalReferenceOrderFieldRank)
cursorKey = &ck cursorKey = &ck
} }

View File

@@ -41,7 +41,7 @@ func (s *Service) ListCustomLinksForPortalID(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := links.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor) err := links.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil { if err != nil {
return fmt.Errorf("cannot load custom links: %w", err) return fmt.Errorf("cannot load custom links: %w", err)
} }

View File

@@ -53,7 +53,7 @@ func (s *Service) ListDocumentsForOrganizationID(
var documents coredata.Documents var documents coredata.Documents
if filter == nil { if filter == nil {
filter = coredata.NewDocumentTrustCenterFilter() filter = coredata.NewDocumentCompliancePortalFilter()
} }
err := s.pg.WithConn( err := s.pg.WithConn(
@@ -131,7 +131,7 @@ func (s *Service) GetDocument(
return nil, ErrDocumentNotFound return nil, ErrDocumentNotFound
} }
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if document.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
return nil, ErrDocumentNotVisible return nil, ErrDocumentNotVisible
} }
@@ -158,7 +158,7 @@ func (s *Service) exportDocumentPDFData(
return &ErrDocumentArchived{} return &ErrDocumentArchived{}
} }
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if document.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
return fmt.Errorf("document not visible on compliance page") return fmt.Errorf("document not visible on compliance page")
} }

View File

@@ -36,37 +36,37 @@ import (
) )
type PortalAccessRequest struct { type PortalAccessRequest struct {
TrustCenterID gid.GID CompliancePortalID gid.GID
IdentityID gid.GID IdentityID gid.GID
DocumentIDs []gid.GID DocumentIDs []gid.GID
ReportIDs []gid.GID ReportIDs []gid.GID
TrustCenterFileIDs []gid.GID CompliancePortalFileIDs []gid.GID
} }
const ( const (
PortalAccessURLFormat = "https://%s/organizations/%s/trust-center/access" PortalAccessURLFormat = "https://%s/organizations/%s/compliance-page/access"
) )
func (s *Service) RequestPortalAccess( func (s *Service) RequestPortalAccess(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
req *PortalAccessRequest, req *PortalAccessRequest,
) (*coredata.TrustCenterAccess, error) { ) (*coredata.CompliancePortalAccess, error) {
var ( var (
now = time.Now() now = time.Now()
access *coredata.TrustCenterAccess access *coredata.CompliancePortalAccess
) )
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
access = &coredata.TrustCenterAccess{} access = &coredata.CompliancePortalAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, req.TrustCenterID, req.IdentityID); err != nil { if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, req.CompliancePortalID, req.IdentityID); err != nil {
return fmt.Errorf("cannot load compliance page membership: %w", err) return fmt.Errorf("cannot load compliance page membership: %w", err)
} }
@@ -74,7 +74,7 @@ func (s *Service) RequestPortalAccess(
documentIDs := req.DocumentIDs documentIDs := req.DocumentIDs
if req.DocumentIDs == nil { if req.DocumentIDs == nil {
filter := coredata.NewDocumentTrustCenterFilter() filter := coredata.NewDocumentCompliancePortalFilter()
allDocuments, err := page.LoadAll( allDocuments, err := page.LoadAll(
ctx, ctx,
@@ -102,7 +102,7 @@ func (s *Service) RequestPortalAccess(
reportIDs := req.ReportIDs reportIDs := req.ReportIDs
if req.ReportIDs == nil { if req.ReportIDs == nil {
auditFilter := coredata.NewAuditTrustCenterFilter() auditFilter := coredata.NewAuditCompliancePortalFilter()
allAudits, err := page.LoadAll( allAudits, err := page.LoadAll(
ctx, ctx,
@@ -130,20 +130,20 @@ func (s *Service) RequestPortalAccess(
} }
} }
trustCenterFileIDs := req.TrustCenterFileIDs compliancePortalFileIDs := req.CompliancePortalFileIDs
if req.TrustCenterFileIDs == nil { if req.CompliancePortalFileIDs == nil {
filter := coredata.NewTrustCenterFileFilter( filter := coredata.NewCompliancePortalFileFilter(
coredata.WithTrustCenterFileVisibilities(coredata.TrustCenterVisibilityPrivate, coredata.TrustCenterVisibilityNone), coredata.WithCompliancePortalFileVisibilities(coredata.CompliancePortalVisibilityPrivate, coredata.CompliancePortalVisibilityNone),
) )
allTrustCenterFiles, err := page.LoadAll( allCompliancePortalFiles, err := page.LoadAll(
ctx, ctx,
page.OrderBy[coredata.TrustCenterFileOrderField]{ page.OrderBy[coredata.CompliancePortalFileOrderField]{
Field: coredata.TrustCenterFileOrderFieldCreatedAt, Field: coredata.CompliancePortalFileOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc, Direction: page.OrderDirectionDesc,
}, },
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterFileOrderField]) ([]*coredata.TrustCenterFile, error) { func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalFileOrderField]) ([]*coredata.CompliancePortalFile, error) {
var batch coredata.TrustCenterFiles var batch coredata.CompliancePortalFiles
if err := batch.LoadByOrganizationID(ctx, tx, scope, organizationID, cursor, filter); err != nil { if err := batch.LoadByOrganizationID(ctx, tx, scope, organizationID, cursor, filter); err != nil {
return nil, fmt.Errorf("cannot list compliance page files: %w", err) return nil, fmt.Errorf("cannot list compliance page files: %w", err)
} }
@@ -155,20 +155,20 @@ func (s *Service) RequestPortalAccess(
return err return err
} }
for _, file := range allTrustCenterFiles { for _, file := range allCompliancePortalFiles {
trustCenterFileIDs = append(trustCenterFileIDs, file.ID) compliancePortalFileIDs = append(compliancePortalFileIDs, file.ID)
} }
} }
existingAccesses, err := page.LoadAll( existingAccesses, err := page.LoadAll(
ctx, ctx,
page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{ page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt, Field: coredata.CompliancePortalDocumentAccessOrderFieldCreatedAt,
Direction: page.OrderDirectionAsc, Direction: page.OrderDirectionAsc,
}, },
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField]) ([]*coredata.TrustCenterDocumentAccess, error) { func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField]) ([]*coredata.CompliancePortalDocumentAccess, error) {
var batch coredata.TrustCenterDocumentAccesses var batch coredata.CompliancePortalDocumentAccesses
if err := batch.LoadByTrustCenterAccessID(ctx, tx, scope, access.ID, cursor); err != nil { if err := batch.LoadByCompliancePortalAccessID(ctx, tx, scope, access.ID, cursor); err != nil {
return nil, fmt.Errorf("cannot load existing access records: %w", err) return nil, fmt.Errorf("cannot load existing access records: %w", err)
} }
@@ -179,12 +179,12 @@ func (s *Service) RequestPortalAccess(
return err return err
} }
existingDocumentIDs, existingReportIDs, existingTrustCenterFileIDs := extractExistingIDs(existingAccesses) existingDocumentIDs, existingReportIDs, existingCompliancePortalFileIDs := extractExistingIDs(existingAccesses)
newDocumentIDs := filterExistingIDs(documentIDs, existingDocumentIDs) newDocumentIDs := filterExistingIDs(documentIDs, existingDocumentIDs)
newReportIDs := filterExistingIDs(reportIDs, existingReportIDs) newReportIDs := filterExistingIDs(reportIDs, existingReportIDs)
newTrustCenterFileIDs := filterExistingIDs(trustCenterFileIDs, existingTrustCenterFileIDs) newCompliancePortalFileIDs := filterExistingIDs(compliancePortalFileIDs, existingCompliancePortalFileIDs)
var accesses coredata.TrustCenterDocumentAccesses var accesses coredata.CompliancePortalDocumentAccesses
if err := accesses.BulkInsertDocumentAccesses( if err := accesses.BulkInsertDocumentAccesses(
ctx, ctx,
@@ -193,7 +193,7 @@ func (s *Service) RequestPortalAccess(
access.ID, access.ID,
access.OrganizationID, access.OrganizationID,
newDocumentIDs, newDocumentIDs,
coredata.TrustCenterDocumentAccessStatusRequested, coredata.CompliancePortalDocumentAccessStatusRequested,
now, now,
); err != nil { ); err != nil {
return fmt.Errorf("cannot bulk insert compliance page document accesses: %w", err) return fmt.Errorf("cannot bulk insert compliance page document accesses: %w", err)
@@ -206,20 +206,20 @@ func (s *Service) RequestPortalAccess(
access.ID, access.ID,
access.OrganizationID, access.OrganizationID,
newReportIDs, newReportIDs,
coredata.TrustCenterDocumentAccessStatusRequested, coredata.CompliancePortalDocumentAccessStatusRequested,
now, now,
); err != nil { ); err != nil {
return fmt.Errorf("cannot bulk insert compliance page report accesses: %w", err) return fmt.Errorf("cannot bulk insert compliance page report accesses: %w", err)
} }
if err := accesses.BulkInsertTrustCenterFileAccesses( if err := accesses.BulkInsertCompliancePortalFileAccesses(
ctx, ctx,
tx, tx,
scope, scope,
access.ID, access.ID,
access.OrganizationID, access.OrganizationID,
newTrustCenterFileIDs, newCompliancePortalFileIDs,
coredata.TrustCenterDocumentAccessStatusRequested, coredata.CompliancePortalDocumentAccessStatusRequested,
now, now,
); err != nil { ); err != nil {
return fmt.Errorf("cannot bulk insert compliance page file accesses: %w", err) return fmt.Errorf("cannot bulk insert compliance page file accesses: %w", err)
@@ -232,7 +232,7 @@ func (s *Service) RequestPortalAccess(
return nil, err return nil, err
} }
if err := s.slack.QueueSlackNotification(ctx, scope, req.IdentityID, req.TrustCenterID); err != nil { if err := s.slack.QueueSlackNotification(ctx, scope, req.IdentityID, req.CompliancePortalID); err != nil {
s.logger.ErrorCtx(ctx, "cannot queue slack notification", log.Error(err)) s.logger.ErrorCtx(ctx, "cannot queue slack notification", log.Error(err))
} }
@@ -244,13 +244,13 @@ func (s *Service) GetPortalAccess(
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
identityID gid.GID, identityID gid.GID,
) (coredata.TrustCenterAccess, error) { ) (coredata.CompliancePortalAccess, error) {
var access coredata.TrustCenterAccess var access coredata.CompliancePortalAccess
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
return access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID) return access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
}, },
) )
@@ -263,15 +263,15 @@ func (s *Service) GetPortalDocumentAccess(
compliancePageID gid.GID, compliancePageID gid.GID,
identityID gid.GID, identityID gid.GID,
documentID gid.GID, documentID gid.GID,
) (*coredata.TrustCenterDocumentAccess, error) { ) (*coredata.CompliancePortalDocumentAccess, error) {
var documentAccess *coredata.TrustCenterDocumentAccess var documentAccess *coredata.CompliancePortalDocumentAccess
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
access := &coredata.TrustCenterAccess{} access := &coredata.CompliancePortalAccess{}
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID) err := access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrMembershipNotFound return ErrMembershipNotFound
@@ -291,9 +291,9 @@ func (s *Service) GetPortalDocumentAccess(
return ErrUserInactive return ErrUserInactive
} }
documentAccess = &coredata.TrustCenterDocumentAccess{} documentAccess = &coredata.CompliancePortalDocumentAccess{}
err = documentAccess.LoadByTrustCenterAccessIDAndDocumentID(ctx, conn, scope, access.ID, documentID) err = documentAccess.LoadByCompliancePortalAccessIDAndDocumentID(ctx, conn, scope, access.ID, documentID)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrDocumentAccessNotFound return ErrDocumentAccessNotFound
@@ -318,15 +318,15 @@ func (s *Service) GetPortalReportFileAccess(
compliancePageID gid.GID, compliancePageID gid.GID,
identityID gid.GID, identityID gid.GID,
reportFileID gid.GID, reportFileID gid.GID,
) (*coredata.TrustCenterDocumentAccess, error) { ) (*coredata.CompliancePortalDocumentAccess, error) {
var reportAccess *coredata.TrustCenterDocumentAccess var reportAccess *coredata.CompliancePortalDocumentAccess
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
access := &coredata.TrustCenterAccess{} access := &coredata.CompliancePortalAccess{}
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID) err := access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrMembershipNotFound return ErrMembershipNotFound
@@ -346,9 +346,9 @@ func (s *Service) GetPortalReportFileAccess(
return ErrUserInactive return ErrUserInactive
} }
reportAccess = &coredata.TrustCenterDocumentAccess{} reportAccess = &coredata.CompliancePortalDocumentAccess{}
err = reportAccess.LoadByTrustCenterAccessIDAndReportFileID(ctx, conn, scope, access.ID, reportFileID) err = reportAccess.LoadByCompliancePortalAccessIDAndReportFileID(ctx, conn, scope, access.ID, reportFileID)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrDocumentAccessNotFound return ErrDocumentAccessNotFound
@@ -372,16 +372,16 @@ func (s *Service) GetPortalFileAccess(
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
identityID gid.GID, identityID gid.GID,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) (*coredata.TrustCenterDocumentAccess, error) { ) (*coredata.CompliancePortalDocumentAccess, error) {
var fileAccess *coredata.TrustCenterDocumentAccess var fileAccess *coredata.CompliancePortalDocumentAccess
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
access := &coredata.TrustCenterAccess{} access := &coredata.CompliancePortalAccess{}
err := access.LoadByTrustCenterIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID) err := access.LoadByCompliancePortalIDAndIdentityID(ctx, conn, scope, compliancePageID, identityID)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrMembershipNotFound return ErrMembershipNotFound
@@ -401,9 +401,9 @@ func (s *Service) GetPortalFileAccess(
return ErrUserInactive return ErrUserInactive
} }
fileAccess = &coredata.TrustCenterDocumentAccess{} fileAccess = &coredata.CompliancePortalDocumentAccess{}
err = fileAccess.LoadByTrustCenterAccessIDAndTrustCenterFileID(ctx, conn, scope, access.ID, trustCenterFileID) err = fileAccess.LoadByCompliancePortalAccessIDAndCompliancePortalFileID(ctx, conn, scope, access.ID, compliancePortalFileID)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrDocumentAccessNotFound return ErrDocumentAccessNotFound
@@ -434,7 +434,7 @@ func (s *Service) GrantPortalAccessByIDs(
return s.pg.WithTx( return s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil { if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -444,8 +444,8 @@ func (s *Service) GrantPortalAccessByIDs(
return fmt.Errorf("cannot load identity: %w", err) return fmt.Errorf("cannot load identity: %w", err)
} }
access := &coredata.TrustCenterAccess{} access := &coredata.CompliancePortalAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil { if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
return fmt.Errorf("cannot load compliance page access: %w", err) return fmt.Errorf("cannot load compliance page access: %w", err)
} }
@@ -476,7 +476,7 @@ func (s *Service) GrantPortalAccessByIDs(
} }
if len(fileIDs) > 0 { if len(fileIDs) > 0 {
if err := coredata.GrantByTrustCenterFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil { if err := coredata.GrantByCompliancePortalFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil {
return fmt.Errorf("cannot grant compliance page file accesses: %w", err) return fmt.Errorf("cannot grant compliance page file accesses: %w", err)
} }
} }
@@ -503,7 +503,7 @@ func (s *Service) sendPortalAccessEmail(
ctx context.Context, ctx context.Context,
tx pg.Tx, tx pg.Tx,
scope coredata.Scoper, scope coredata.Scoper,
access *coredata.TrustCenterAccess, access *coredata.CompliancePortalAccess,
profile *coredata.MembershipProfile, profile *coredata.MembershipProfile,
) error { ) error {
organization := &coredata.Organization{} organization := &coredata.Organization{}
@@ -518,14 +518,14 @@ func (s *Service) sendPortalAccessEmail(
return fmt.Errorf("cannot update compliance page access with expiration: %w", err) return fmt.Errorf("cannot update compliance page access with expiration: %w", err)
} }
emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.TrustCenterID) emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.CompliancePortalID)
if err != nil { if err != nil {
return fmt.Errorf("cannot get compliance page email presenter config: %w", err) return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
} }
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName) emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName)
subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterAccess(ctx, organization.Name) subject, textBody, htmlBody, err := emailPresenter.RenderCompliancePortalAccess(ctx, organization.Name)
if err != nil { if err != nil {
return fmt.Errorf("cannot render compliance page access email: %w", err) return fmt.Errorf("cannot render compliance page access email: %w", err)
} }
@@ -560,7 +560,7 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
return s.pg.WithTx( return s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil { if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -570,8 +570,8 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
return fmt.Errorf("cannot load identity: %w", err) return fmt.Errorf("cannot load identity: %w", err)
} }
access := &coredata.TrustCenterAccess{} access := &coredata.CompliancePortalAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil { if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
return fmt.Errorf("cannot load compliance page access: %w", err) return fmt.Errorf("cannot load compliance page access: %w", err)
} }
@@ -602,7 +602,7 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
if len(fileIDs) > 0 { if len(fileIDs) > 0 {
shouldSendEmail = true shouldSendEmail = true
if err := coredata.RejectOrRevokeByTrustCenterFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil { if err := coredata.RejectOrRevokeByCompliancePortalFileIDs(ctx, tx, scope, access.ID, fileIDs, now); err != nil {
return fmt.Errorf("cannot reject/revoke compliance page file accesses: %w", err) return fmt.Errorf("cannot reject/revoke compliance page file accesses: %w", err)
} }
} }
@@ -622,7 +622,7 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
ctx context.Context, ctx context.Context,
tx pg.Tx, tx pg.Tx,
scope coredata.Scoper, scope coredata.Scoper,
access *coredata.TrustCenterAccess, access *coredata.CompliancePortalAccess,
profile *coredata.MembershipProfile, profile *coredata.MembershipProfile,
documentIDs []gid.GID, documentIDs []gid.GID,
reportIDs []gid.GID, reportIDs []gid.GID,
@@ -657,7 +657,7 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
fileNames = append(fileNames, reportLabels...) fileNames = append(fileNames, reportLabels...)
} }
var files coredata.TrustCenterFiles var files coredata.CompliancePortalFiles
if len(fileIDs) > 0 { if len(fileIDs) > 0 {
if err := files.LoadByIDs(ctx, tx, scope, fileIDs); err != nil && !errors.Is(err, coredata.ErrResourceNotFound) { if err := files.LoadByIDs(ctx, tx, scope, fileIDs); err != nil && !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load files by IDs: %w", err) return fmt.Errorf("cannot load files by IDs: %w", err)
@@ -668,14 +668,14 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
} }
} }
emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.TrustCenterID) emailPresenterCfg, err := s.GetPortalEmailPresenterConfig(ctx, scope, access.CompliancePortalID)
if err != nil { if err != nil {
return fmt.Errorf("cannot get compliance page email presenter config: %w", err) return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
} }
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName) emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName)
subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterDocumentAccessRejected( subject, textBody, htmlBody, err := emailPresenter.RenderCompliancePortalDocumentAccessRejected(
ctx, ctx,
fileNames, fileNames,
organization.Name, organization.Name,
@@ -702,11 +702,11 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
return nil return nil
} }
func extractExistingIDs(accesses coredata.TrustCenterDocumentAccesses) ([]gid.GID, []gid.GID, []gid.GID) { func extractExistingIDs(accesses coredata.CompliancePortalDocumentAccesses) ([]gid.GID, []gid.GID, []gid.GID) {
var ( var (
documentIDs []gid.GID documentIDs []gid.GID
reportIDs []gid.GID reportIDs []gid.GID
trustCenterFileIDs []gid.GID compliancePortalFileIDs []gid.GID
) )
for _, access := range accesses { for _, access := range accesses {
@@ -718,12 +718,12 @@ func extractExistingIDs(accesses coredata.TrustCenterDocumentAccesses) ([]gid.GI
reportIDs = append(reportIDs, *access.ReportFileID) reportIDs = append(reportIDs, *access.ReportFileID)
} }
if access.TrustCenterFileID != nil { if access.CompliancePortalFileID != nil {
trustCenterFileIDs = append(trustCenterFileIDs, *access.TrustCenterFileID) compliancePortalFileIDs = append(compliancePortalFileIDs, *access.CompliancePortalFileID)
} }
} }
return documentIDs, reportIDs, trustCenterFileIDs return documentIDs, reportIDs, compliancePortalFileIDs
} }
func filterExistingIDs(allIDs []gid.GID, existingIDs []gid.GID) []gid.GID { func filterExistingIDs(allIDs []gid.GID, existingIDs []gid.GID) []gid.GID {

View File

@@ -38,14 +38,14 @@ func (s *Service) GetPortalFile(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
organizationID gid.GID, organizationID gid.GID,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) (*coredata.TrustCenterFile, error) { ) (*coredata.CompliancePortalFile, error) {
trustCenterFile := &coredata.TrustCenterFile{} compliancePortalFile := &coredata.CompliancePortalFile{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := trustCenterFile.LoadByID(ctx, conn, scope, trustCenterFileID) err := compliancePortalFile.LoadByID(ctx, conn, scope, compliancePortalFileID)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err) return fmt.Errorf("cannot load compliance page file: %w", err)
} }
@@ -57,30 +57,30 @@ func (s *Service) GetPortalFile(
return nil, err return nil, err
} }
if trustCenterFile.OrganizationID != organizationID { if compliancePortalFile.OrganizationID != organizationID {
return nil, ErrPortalFileNotFound return nil, ErrPortalFileNotFound
} }
if trustCenterFile.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if compliancePortalFile.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
return nil, ErrPortalFileNotVisible return nil, ErrPortalFileNotVisible
} }
return trustCenterFile, nil return compliancePortalFile, nil
} }
func (s *Service) ListPortalFilesForOrganizationID( func (s *Service) ListPortalFilesForOrganizationID(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
organizationID gid.GID, organizationID gid.GID,
cursor *page.Cursor[coredata.TrustCenterFileOrderField], cursor *page.Cursor[coredata.CompliancePortalFileOrderField],
filter *coredata.TrustCenterFileFilter, filter *coredata.CompliancePortalFileFilter,
) (*page.Page[*coredata.TrustCenterFile, coredata.TrustCenterFileOrderField], error) { ) (*page.Page[*coredata.CompliancePortalFile, coredata.CompliancePortalFileOrderField], error) {
var trustCenterFiles coredata.TrustCenterFiles var compliancePortalFiles coredata.CompliancePortalFiles
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := trustCenterFiles.LoadByOrganizationID(ctx, conn, scope, organizationID, cursor, filter) err := compliancePortalFiles.LoadByOrganizationID(ctx, conn, scope, organizationID, cursor, filter)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance page files: %w", err) return fmt.Errorf("cannot load compliance page files: %w", err)
} }
@@ -92,16 +92,16 @@ func (s *Service) ListPortalFilesForOrganizationID(
return nil, err return nil, err
} }
return page.NewPage(trustCenterFiles, cursor), nil return page.NewPage(compliancePortalFiles, cursor), nil
} }
func (s *Service) ExportPortalFile( func (s *Service) ExportPortalFile(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
email mail.Addr, email mail.Addr,
) ([]byte, string, error) { ) ([]byte, string, error) {
fileData, mimeType, err := s.exportPortalFileData(ctx, scope, trustCenterFileID) fileData, mimeType, err := s.exportPortalFileData(ctx, scope, compliancePortalFileID)
if err != nil { if err != nil {
return nil, "", fmt.Errorf("cannot export compliance page file: %w", err) return nil, "", fmt.Errorf("cannot export compliance page file: %w", err)
} }
@@ -121,31 +121,31 @@ func (s *Service) ExportPortalFile(
func (s *Service) ExportPortalFileWithoutWatermark( func (s *Service) ExportPortalFileWithoutWatermark(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) ([]byte, string, error) { ) ([]byte, string, error) {
return s.exportPortalFileData(ctx, scope, trustCenterFileID) return s.exportPortalFileData(ctx, scope, compliancePortalFileID)
} }
func (s *Service) exportPortalFileData( func (s *Service) exportPortalFileData(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterFileID gid.GID, compliancePortalFileID gid.GID,
) ([]byte, string, error) { ) ([]byte, string, error) {
var ( var (
trustCenterFile *coredata.TrustCenterFile compliancePortalFile *coredata.CompliancePortalFile
file *coredata.File file *coredata.File
) )
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
trustCenterFile = &coredata.TrustCenterFile{} compliancePortalFile = &coredata.CompliancePortalFile{}
if err := trustCenterFile.LoadByID(ctx, conn, scope, trustCenterFileID); err != nil { if err := compliancePortalFile.LoadByID(ctx, conn, scope, compliancePortalFileID); err != nil {
return fmt.Errorf("cannot load compliance page file: %w", err) return fmt.Errorf("cannot load compliance page file: %w", err)
} }
file = &coredata.File{} file = &coredata.File{}
if err := file.LoadByID(ctx, conn, scope, trustCenterFile.FileID); err != nil { if err := file.LoadByID(ctx, conn, scope, compliancePortalFile.FileID); err != nil {
return fmt.Errorf("cannot load file: %w", err) return fmt.Errorf("cannot load file: %w", err)
} }

View File

@@ -34,16 +34,16 @@ func (s *Service) ListPortalReferencesForPortalID(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
cursor *page.Cursor[coredata.TrustCenterReferenceOrderField], cursor *page.Cursor[coredata.CompliancePortalReferenceOrderField],
) (*page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField], error) { ) (*page.Page[*coredata.CompliancePortalReference, coredata.CompliancePortalReferenceOrderField], error) {
var references coredata.TrustCenterReferences var references coredata.CompliancePortalReferences
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
err := references.LoadByTrustCenterID(ctx, conn, scope, compliancePageID, cursor) err := references.LoadByCompliancePortalID(ctx, conn, scope, compliancePageID, cursor)
if err != nil { if err != nil {
return fmt.Errorf("cannot load compliance page references: %w", err) return fmt.Errorf("cannot load compliance page references: %w", err)
} }
@@ -62,8 +62,8 @@ func (s *Service) GetPortalReference(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
referenceID gid.GID, referenceID gid.GID,
) (*coredata.TrustCenterReference, error) { ) (*coredata.CompliancePortalReference, error) {
reference := &coredata.TrustCenterReference{} reference := &coredata.CompliancePortalReference{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,

View File

@@ -36,13 +36,13 @@ func (s *Service) GetPortal(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
compliancePageID gid.GID, compliancePageID gid.GID,
) (*coredata.TrustCenter, error) { ) (*coredata.CompliancePortal, error) {
var compliancePage *coredata.TrustCenter var compliancePage *coredata.CompliancePortal
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -67,7 +67,7 @@ func (s *Service) GetPortalNDAFile(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -102,7 +102,7 @@ func (s *Service) GeneratePortalNDAFileURL(
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -137,7 +137,7 @@ func (s *Service) GetPortalEmailPresenterConfig(
compliancePageID gid.GID, compliancePageID gid.GID,
) (emails.PresenterConfig, error) { ) (emails.PresenterConfig, error) {
var ( var (
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
organization = &coredata.Organization{} organization = &coredata.Organization{}
logoFile = &coredata.File{} logoFile = &coredata.File{}
compliancePageURL string compliancePageURL string
@@ -161,7 +161,7 @@ func (s *Service) GetPortalEmailPresenterConfig(
return fmt.Errorf("cannot load organization: %w", err) return fmt.Errorf("cannot load organization: %w", err)
} }
publicURL, err := s.management.PublicURLForCompliancePage( publicURL, err := s.management.PublicURLForCompliancePortal(
ctx, ctx,
conn, conn,
scope, scope,

View File

@@ -95,8 +95,8 @@ func NewService(
func (s *Service) GetPortalByID( func (s *Service) GetPortalByID(
ctx context.Context, ctx context.Context,
id gid.GID, id gid.GID,
) (*coredata.TrustCenter, error) { ) (*coredata.CompliancePortal, error) {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -130,12 +130,12 @@ func (s *Service) GetPortalEffectiveCanonicalHost(ctx context.Context, complianc
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, conn, coredata.NewNoScope(), compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, conn, coredata.NewNoScope(), compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
domain, err := s.management.EffectiveDomainForCompliancePage(ctx, conn, coredata.NewNoScope(), compliancePage) domain, err := s.management.EffectiveDomainForCompliancePortal(ctx, conn, coredata.NewNoScope(), compliancePage)
if err != nil { if err != nil {
return err return err
} }
@@ -186,8 +186,8 @@ func (s *Service) GetPortalCanonicalBaseURL(
return parsed.String(), nil return parsed.String(), nil
} }
func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*coredata.TrustCenter, error) { func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*coredata.CompliancePortal, error) {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
@@ -201,7 +201,7 @@ func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*co
return fmt.Errorf("cannot load custom domain: %w", err) return fmt.Errorf("cannot load custom domain: %w", err)
} }
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
if err := compliancePage.LoadByDomainID(ctx, conn, customDomain.ID); err != nil { if err := compliancePage.LoadByDomainID(ctx, conn, customDomain.ID); err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
return ErrPageNotFound return ErrPageNotFound
@@ -224,7 +224,7 @@ func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*co
// the compliance page that belongs to the given organization. This is used by the // the compliance page that belongs to the given organization. This is used by the
// esign certificate worker which needs per-org branding at render time. // esign certificate worker which needs per-org branding at render time.
func (s *Service) GetPortalEmailPresenterConfigByOrganizationID(ctx context.Context, orgID gid.GID) (emails.PresenterConfig, error) { func (s *Service) GetPortalEmailPresenterConfigByOrganizationID(ctx context.Context, orgID gid.GID) (emails.PresenterConfig, error) {
var compliancePage coredata.TrustCenter var compliancePage coredata.CompliancePortal
scope := coredata.NewScopeFromObjectID(orgID) scope := coredata.NewScopeFromObjectID(orgID)
@@ -265,13 +265,13 @@ func (s *Service) GetPortalOrganization(
return org, nil return org, nil
} }
func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.GID, identityID gid.GID) (*coredata.TrustCenterAccess, error) { func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.GID, identityID gid.GID) (*coredata.CompliancePortalAccess, error) {
membership := &coredata.TrustCenterAccess{} membership := &coredata.CompliancePortalAccess{}
err := s.pg.WithConn( err := s.pg.WithConn(
ctx, ctx,
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
return membership.LoadByTrustCenterIDAndIdentityID( return membership.LoadByCompliancePortalIDAndIdentityID(
ctx, ctx,
conn, conn,
coredata.NewScopeFromObjectID(compliancePageID), coredata.NewScopeFromObjectID(compliancePageID),
@@ -295,9 +295,9 @@ func (s *Service) ProvisionPortalMember(
ctx context.Context, ctx context.Context,
compliancePageID gid.GID, compliancePageID gid.GID,
identityID gid.GID, identityID gid.GID,
) (*coredata.TrustCenterAccess, error) { ) (*coredata.CompliancePortalAccess, error) {
var ( var (
access *coredata.TrustCenterAccess access *coredata.CompliancePortalAccess
now = time.Now() now = time.Now()
scope = coredata.NewScopeFromObjectID(compliancePageID) scope = coredata.NewScopeFromObjectID(compliancePageID)
) )
@@ -305,7 +305,7 @@ func (s *Service) ProvisionPortalMember(
err := s.pg.WithTx( err := s.pg.WithTx(
ctx, ctx,
func(ctx context.Context, tx pg.Tx) error { func(ctx context.Context, tx pg.Tx) error {
compliancePage := &coredata.TrustCenter{} compliancePage := &coredata.CompliancePortal{}
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil { if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
return fmt.Errorf("cannot load compliance page: %w", err) return fmt.Errorf("cannot load compliance page: %w", err)
} }
@@ -315,20 +315,20 @@ func (s *Service) ProvisionPortalMember(
return fmt.Errorf("cannot load identity: %w", err) return fmt.Errorf("cannot load identity: %w", err)
} }
access = &coredata.TrustCenterAccess{} access = &coredata.CompliancePortalAccess{}
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePageID, identityID); err != nil { if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePageID, identityID); err != nil {
if !errors.Is(err, coredata.ErrResourceNotFound) { if !errors.Is(err, coredata.ErrResourceNotFound) {
return fmt.Errorf("cannot load compliance page access: %w", err) return fmt.Errorf("cannot load compliance page access: %w", err)
} }
access = &coredata.TrustCenterAccess{ access = &coredata.CompliancePortalAccess{
ID: gid.New(scope.GetTenantID(), coredata.TrustCenterAccessEntityType), ID: gid.New(scope.GetTenantID(), coredata.CompliancePortalAccessEntityType),
OrganizationID: compliancePage.OrganizationID, OrganizationID: compliancePage.OrganizationID,
TenantID: scope.GetTenantID(), TenantID: scope.GetTenantID(),
IdentityID: identityID, IdentityID: identityID,
TrustCenterID: compliancePageID, CompliancePortalID: compliancePageID,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
var sig *coredata.ElectronicSignature var sig *coredata.ElectronicSignature

View File

@@ -63,8 +63,8 @@ func (s *Service) ListThirdPartiesForOrganizationID(
filter *coredata.ThirdPartyFilter, filter *coredata.ThirdPartyFilter,
) (*page.Page[*coredata.ThirdParty, coredata.ThirdPartyOrderField], error) { ) (*page.Page[*coredata.ThirdParty, coredata.ThirdPartyOrderField], error) {
if filter == nil { if filter == nil {
showOnTrustCenter := true showOnCompliancePortal := true
filter = coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, nil, nil, nil) filter = coredata.NewThirdPartyFilter(&showOnCompliancePortal, nil, nil, nil, nil)
} }
var thirdParties coredata.ThirdParties var thirdParties coredata.ThirdParties
@@ -99,7 +99,7 @@ func (s *Service) ListDistinctPortalCategoriesForOrganizationID(
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
thirdParties := &coredata.ThirdParties{} thirdParties := &coredata.ThirdParties{}
result, err := thirdParties.LoadDistinctTrustCenterCategoriesByOrganizationID(ctx, conn, scope, organizationID) result, err := thirdParties.LoadDistinctCompliancePortalCategoriesByOrganizationID(ctx, conn, scope, organizationID)
if err != nil { if err != nil {
return fmt.Errorf("cannot load thirdParty categories: %w", err) return fmt.Errorf("cannot load thirdParty categories: %w", err)
} }
@@ -128,7 +128,7 @@ func (s *Service) ListDistinctPortalCountriesForOrganizationID(
func(ctx context.Context, conn pg.Querier) error { func(ctx context.Context, conn pg.Querier) error {
thirdParties := &coredata.ThirdParties{} thirdParties := &coredata.ThirdParties{}
result, err := thirdParties.LoadDistinctTrustCenterCountriesByOrganizationID(ctx, conn, scope, organizationID) result, err := thirdParties.LoadDistinctCompliancePortalCountriesByOrganizationID(ctx, conn, scope, organizationID)
if err != nil { if err != nil {
return fmt.Errorf("cannot load thirdParty countries: %w", err) return fmt.Errorf("cannot load thirdParty countries: %w", err)
} }
@@ -152,8 +152,8 @@ func (s *Service) CountThirdPartiesForPortalID(
filter *coredata.ThirdPartyFilter, filter *coredata.ThirdPartyFilter,
) (int, error) { ) (int, error) {
if filter == nil { if filter == nil {
showOnTrustCenter := true showOnCompliancePortal := true
filter = coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, nil, nil, nil) filter = coredata.NewThirdPartyFilter(&showOnCompliancePortal, nil, nil, nil, nil)
} }
var count int var count int

View File

@@ -39,7 +39,7 @@ import (
) )
// EmailPresenterConfigFunc resolves the emails.PresenterConfig for the // EmailPresenterConfigFunc resolves the emails.PresenterConfig for the
// organization that owns the given trust center. // organization that owns the given compliance portal.
type EmailPresenterConfigFunc func(ctx context.Context, organizationID gid.GID) (emails.PresenterConfig, error) type EmailPresenterConfigFunc func(ctx context.Context, organizationID gid.GID) (emails.PresenterConfig, error)
type completionCertificateHandler struct { type completionCertificateHandler struct {

View File

@@ -608,8 +608,8 @@ func (s *OrganizationService) CreateOrganization(
UpdatedAt: now, UpdatedAt: now,
} }
trustCenter = &coredata.TrustCenter{ compliancePortal = &coredata.CompliancePortal{
ID: gid.New(tenantID, coredata.TrustCenterEntityType), ID: gid.New(tenantID, coredata.CompliancePortalEntityType),
OrganizationID: organization.ID, OrganizationID: organization.ID,
TenantID: organization.TenantID, TenantID: organization.TenantID,
Active: false, Active: false,
@@ -726,7 +726,7 @@ func (s *OrganizationService) CreateOrganization(
} }
organization.LogoFileID = &logoFile.ID organization.LogoFileID = &logoFile.ID
trustCenter.LogoFileID = &logoFile.ID compliancePortal.LogoFileID = &logoFile.ID
} }
if horizontalLogoFile != nil { if horizontalLogoFile != nil {
@@ -760,8 +760,8 @@ func (s *OrganizationService) CreateOrganization(
// a default managed domain: there is no suffix to mint a // a default managed domain: there is no suffix to mint a
// "{slug}." hostname from, so the compliance page stays without // "{slug}." hostname from, so the compliance page stays without
// a domain until the organization adds a custom one. // a domain until the organization adds a custom one.
if s.trustCenterBaseDomain != "" { if s.compliancePortalBaseDomain != "" {
defaultDomainHostname := trustCenter.Slug + "." + s.trustCenterBaseDomain defaultDomainHostname := compliancePortal.Slug + "." + s.compliancePortalBaseDomain
defaultDomain := coredata.NewCustomDomain( defaultDomain := coredata.NewCustomDomain(
tenantID, tenantID,
@@ -781,29 +781,29 @@ func (s *OrganizationService) CreateOrganization(
return fmt.Errorf("cannot insert default custom domain: %w", err) return fmt.Errorf("cannot insert default custom domain: %w", err)
} }
trustCenter.DefaultDomainID = &defaultDomain.ID compliancePortal.DefaultDomainID = &defaultDomain.ID
} }
if err := trustCenter.Insert(ctx, tx, scope); err != nil { if err := compliancePortal.Insert(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot insert trust center: %w", err) return fmt.Errorf("cannot insert compliance portal: %w", err)
} }
proboData := &coredata.ThirdParty{ proboData := &coredata.ThirdParty{
ID: gid.New(scope.GetTenantID(), coredata.ThirdPartyEntityType), ID: gid.New(scope.GetTenantID(), coredata.ThirdPartyEntityType),
OrganizationID: organization.ID, OrganizationID: organization.ID,
Name: proboThirdParty.Name, Name: proboThirdParty.Name,
Description: &proboThirdParty.Description, Description: &proboThirdParty.Description,
Category: coredata.ThirdPartyCategorySecurity, Category: coredata.ThirdPartyCategorySecurity,
HeadquarterAddress: &proboThirdParty.HeadquarterAddress, HeadquarterAddress: &proboThirdParty.HeadquarterAddress,
LegalName: &proboThirdParty.LegalName, LegalName: &proboThirdParty.LegalName,
WebsiteURL: &proboThirdParty.WebsiteURL, WebsiteURL: &proboThirdParty.WebsiteURL,
PrivacyPolicyURL: &proboThirdParty.PrivacyPolicyURL, PrivacyPolicyURL: &proboThirdParty.PrivacyPolicyURL,
TermsOfServiceURL: &proboThirdParty.TermsOfServiceURL, TermsOfServiceURL: &proboThirdParty.TermsOfServiceURL,
SubprocessorsListURL: &proboThirdParty.SubprocessorsListURL, SubprocessorsListURL: &proboThirdParty.SubprocessorsListURL,
ShowOnTrustCenter: false, ShowOnCompliancePortal: false,
Level: 1, Level: 1,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := proboData.Insert(ctx, tx, scope); err != nil { if err := proboData.Insert(ctx, tx, scope); err != nil {
@@ -832,7 +832,7 @@ func (s *OrganizationService) UpdateOrganization(ctx context.Context, organizati
tenantID = organizationID.TenantID() tenantID = organizationID.TenantID()
scope = coredata.NewScopeFromObjectID(organizationID) scope = coredata.NewScopeFromObjectID(organizationID)
organization = &coredata.Organization{} organization = &coredata.Organization{}
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
) )
// TODO: s3 upload happen before we validate the tenantID // TODO: s3 upload happen before we validate the tenantID

View File

@@ -62,7 +62,7 @@ type (
magicLinkTokenValidity time.Duration magicLinkTokenValidity time.Duration
sessionDuration time.Duration sessionDuration time.Duration
bucket string bucket string
trustCenterBaseDomain string compliancePortalBaseDomain string
certManager *certmanager.Service certManager *certmanager.Service
certificate *x509.Certificate certificate *x509.Certificate
privateKey *rsa.PrivateKey privateKey *rsa.PrivateKey
@@ -92,7 +92,7 @@ type (
Bucket string Bucket string
TokenSecret string TokenSecret string
BaseURL *baseurl.BaseURL BaseURL *baseurl.BaseURL
TrustCenterBaseDomain string CompliancePortalBaseDomain string
CertManager *certmanager.Service CertManager *certmanager.Service
EncryptionKey cipher.EncryptionKey EncryptionKey cipher.EncryptionKey
Certificate *x509.Certificate Certificate *x509.Certificate
@@ -166,7 +166,7 @@ func NewService(
magicLinkTokenValidity: cfg.MagicLinkTokenValidity, magicLinkTokenValidity: cfg.MagicLinkTokenValidity,
sessionDuration: cfg.SessionDuration, sessionDuration: cfg.SessionDuration,
bucket: cfg.Bucket, bucket: cfg.Bucket,
trustCenterBaseDomain: cfg.TrustCenterBaseDomain, compliancePortalBaseDomain: cfg.CompliancePortalBaseDomain,
certManager: cfg.CertManager, certManager: cfg.CertManager,
certificate: cfg.Certificate, certificate: cfg.Certificate,
privateKey: cfg.PrivateKey, privateKey: cfg.PrivateKey,

View File

@@ -63,7 +63,7 @@ func (s *Service) mailingListEmailConfig(
) (emails.PresenterConfig, string, string, *mail.Addr, error) { ) (emails.PresenterConfig, string, string, *mail.Addr, error) {
var ( var (
mailingList = &coredata.MailingList{} mailingList = &coredata.MailingList{}
compliancePage = &coredata.TrustCenter{} compliancePage = &coredata.CompliancePortal{}
organization = &coredata.Organization{} organization = &coredata.Organization{}
compliancePageURL string compliancePageURL string
logoFile = &coredata.File{} logoFile = &coredata.File{}
@@ -97,7 +97,7 @@ func (s *Service) mailingListEmailConfig(
return fmt.Errorf("cannot load organization: %w", err) return fmt.Errorf("cannot load organization: %w", err)
} }
publicURL, err := s.compliancePortal.PublicURLForCompliancePage( publicURL, err := s.compliancePortal.PublicURLForCompliancePortal(
ctx, ctx,
conn, conn,
scope, scope,
@@ -116,7 +116,7 @@ func (s *Service) mailingListEmailConfig(
return defaultCfg, "", "", nil, err return defaultCfg, "", "", nil, err
} }
cfg, err := s.presenterConfigFromTrustCenter(compliancePage, organization, compliancePageURL, logoFile) cfg, err := s.presenterConfigFromCompliancePortal(compliancePage, organization, compliancePageURL, logoFile)
if err != nil { if err != nil {
return defaultCfg, "", "", nil, err return defaultCfg, "", "", nil, err
} }
@@ -134,8 +134,8 @@ func (s *Service) mailingListEmailConfig(
return cfg, organization.Name, updatesPageURL, mailingList.ReplyTo, nil return cfg, organization.Name, updatesPageURL, mailingList.ReplyTo, nil
} }
func (s *Service) presenterConfigFromTrustCenter( func (s *Service) presenterConfigFromCompliancePortal(
compliancePage *coredata.TrustCenter, compliancePage *coredata.CompliancePortal,
organization *coredata.Organization, organization *coredata.Organization,
compliancePageURL string, compliancePageURL string,
logoFile *coredata.File, logoFile *coredata.File,

View File

@@ -405,6 +405,6 @@ const (
ActionCommonThirdPartyList = "core:common-third-party:list" ActionCommonThirdPartyList = "core:common-third-party:list"
// ElectronicSignature actions (tenant-scoped via the related document // ElectronicSignature actions (tenant-scoped via the related document
// version signature / trust center access). // version signature / compliance portal access).
ActionElectronicSignatureGet = "core:electronic-signature:get" ActionElectronicSignatureGet = "core:electronic-signature:get"
) )

View File

@@ -39,22 +39,22 @@ type AuditService struct {
type ( type (
CreateAuditRequest struct { CreateAuditRequest struct {
OrganizationID gid.GID OrganizationID gid.GID
FrameworkID gid.GID FrameworkID gid.GID
Name *string Name *string
ValidFrom *time.Time ValidFrom *time.Time
ValidUntil *time.Time ValidUntil *time.Time
State *coredata.AuditState State *coredata.AuditState
TrustCenterVisibility *coredata.TrustCenterVisibility CompliancePortalVisibility *coredata.CompliancePortalVisibility
} }
UpdateAuditRequest struct { UpdateAuditRequest struct {
ID gid.GID ID gid.GID
Name **string Name **string
ValidFrom *time.Time ValidFrom *time.Time
ValidUntil *time.Time ValidUntil *time.Time
State *coredata.AuditState State *coredata.AuditState
TrustCenterVisibility *coredata.TrustCenterVisibility CompliancePortalVisibility *coredata.CompliancePortalVisibility
} }
UploadAuditReportRequest struct { UploadAuditReportRequest struct {
@@ -71,7 +71,7 @@ func (car *CreateAuditRequest) Validate() error {
v.Check(car.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(car.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(car.ValidUntil, "valid_until", validator.After(car.ValidFrom)) v.Check(car.ValidUntil, "valid_until", validator.After(car.ValidFrom))
v.Check(car.State, "state", validator.OneOfSlice(coredata.AuditStates())) v.Check(car.State, "state", validator.OneOfSlice(coredata.AuditStates()))
v.Check(car.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities())) v.Check(car.CompliancePortalVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
return v.Error() return v.Error()
} }
@@ -83,7 +83,7 @@ func (uar *UpdateAuditRequest) Validate() error {
v.Check(uar.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength)) v.Check(uar.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
v.Check(uar.ValidUntil, "valid_until", validator.After(uar.ValidFrom)) v.Check(uar.ValidUntil, "valid_until", validator.After(uar.ValidFrom))
v.Check(uar.State, "state", validator.OneOfSlice(coredata.AuditStates())) v.Check(uar.State, "state", validator.OneOfSlice(coredata.AuditStates()))
v.Check(uar.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities())) v.Check(uar.CompliancePortalVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
return v.Error() return v.Error()
} }
@@ -164,24 +164,24 @@ func (s *AuditService) Create(
now := time.Now() now := time.Now()
audit := &coredata.Audit{ audit := &coredata.Audit{
ID: gid.New(scope.GetTenantID(), coredata.AuditEntityType), ID: gid.New(scope.GetTenantID(), coredata.AuditEntityType),
Name: req.Name, Name: req.Name,
OrganizationID: req.OrganizationID, OrganizationID: req.OrganizationID,
FrameworkID: req.FrameworkID, FrameworkID: req.FrameworkID,
ValidFrom: req.ValidFrom, ValidFrom: req.ValidFrom,
ValidUntil: req.ValidUntil, ValidUntil: req.ValidUntil,
State: coredata.AuditStateNotStarted, State: coredata.AuditStateNotStarted,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if req.State != nil { if req.State != nil {
audit.State = *req.State audit.State = *req.State
} }
if req.TrustCenterVisibility != nil { if req.CompliancePortalVisibility != nil {
audit.TrustCenterVisibility = *req.TrustCenterVisibility audit.CompliancePortalVisibility = *req.CompliancePortalVisibility
} }
err := s.svc.pg.WithTx( err := s.svc.pg.WithTx(
@@ -244,8 +244,8 @@ func (s *AuditService) Update(
audit.State = *req.State audit.State = *req.State
} }
if req.TrustCenterVisibility != nil { if req.CompliancePortalVisibility != nil {
audit.TrustCenterVisibility = *req.TrustCenterVisibility audit.CompliancePortalVisibility = *req.CompliancePortalVisibility
} }
audit.UpdatedAt = time.Now() audit.UpdatedAt = time.Now()

View File

@@ -105,23 +105,23 @@ type (
} }
CreateDocumentRequest struct { CreateDocumentRequest struct {
OrganizationID gid.GID OrganizationID gid.GID
Title string Title string
Content string Content string
Classification coredata.DocumentClassification Classification coredata.DocumentClassification
DocumentType coredata.DocumentType DocumentType coredata.DocumentType
TrustCenterVisibility *coredata.TrustCenterVisibility CompliancePortalVisibility *coredata.CompliancePortalVisibility
DefaultApproverIDs []gid.GID DefaultApproverIDs []gid.GID
} }
UpdateDocumentRequest struct { UpdateDocumentRequest struct {
DocumentID gid.GID DocumentID gid.GID
Title *string Title *string
Content *string Content *string
Classification *coredata.DocumentClassification Classification *coredata.DocumentClassification
DocumentType *coredata.DocumentType DocumentType *coredata.DocumentType
TrustCenterVisibility *coredata.TrustCenterVisibility CompliancePortalVisibility *coredata.CompliancePortalVisibility
DefaultApproverIDs *[]gid.GID DefaultApproverIDs *[]gid.GID
} }
RequestSignatureRequest struct { RequestSignatureRequest struct {
@@ -182,7 +182,7 @@ func (cdr *CreateDocumentRequest) Validate() error {
) )
v.Check(cdr.Classification, "classification", validator.Required(), validator.OneOfSlice(coredata.DocumentClassifications())) v.Check(cdr.Classification, "classification", validator.Required(), validator.OneOfSlice(coredata.DocumentClassifications()))
v.Check(cdr.DocumentType, "document_type", validator.Required(), validator.OneOfSlice(coredata.DocumentTypes())) v.Check(cdr.DocumentType, "document_type", validator.Required(), validator.OneOfSlice(coredata.DocumentTypes()))
v.Check(cdr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities())) v.Check(cdr.CompliancePortalVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
v.Check(len(cdr.DefaultApproverIDs), "default_approver_ids", validator.Max(100)) v.Check(len(cdr.DefaultApproverIDs), "default_approver_ids", validator.Max(100))
v.Check(cdr.DefaultApproverIDs, "default_approver_ids", validator.NoDuplicates()) v.Check(cdr.DefaultApproverIDs, "default_approver_ids", validator.NoDuplicates())
v.CheckEach(cdr.DefaultApproverIDs, "default_approver_ids", func(_ int, item any) { v.CheckEach(cdr.DefaultApproverIDs, "default_approver_ids", func(_ int, item any) {
@@ -231,7 +231,7 @@ func (udr *UpdateDocumentRequest) Validate() error {
v := validator.New() v := validator.New()
v.Check(udr.DocumentID, "document_id", validator.Required(), validator.GID(coredata.DocumentEntityType)) v.Check(udr.DocumentID, "document_id", validator.Required(), validator.GID(coredata.DocumentEntityType))
v.Check(udr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities())) v.Check(udr.CompliancePortalVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.CompliancePortalVisibilities()))
if udr.DefaultApproverIDs != nil { if udr.DefaultApproverIDs != nil {
v.Check(len(*udr.DefaultApproverIDs), "default_approver_ids", validator.Max(100)) v.Check(len(*udr.DefaultApproverIDs), "default_approver_ids", validator.Max(100))
@@ -791,16 +791,16 @@ func (s *DocumentService) Create(
organization := &coredata.Organization{} organization := &coredata.Organization{}
document := &coredata.Document{ document := &coredata.Document{
ID: documentID, ID: documentID,
WriteMode: coredata.DocumentWriteModeAuthored, WriteMode: coredata.DocumentWriteModeAuthored,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if req.TrustCenterVisibility != nil { if req.CompliancePortalVisibility != nil {
document.TrustCenterVisibility = *req.TrustCenterVisibility document.CompliancePortalVisibility = *req.CompliancePortalVisibility
} }
content := req.Content content := req.Content
@@ -2209,8 +2209,8 @@ func (s *DocumentService) Update(
previousDocument := *document previousDocument := *document
if req.TrustCenterVisibility != nil { if req.CompliancePortalVisibility != nil {
document.TrustCenterVisibility = *req.TrustCenterVisibility document.CompliancePortalVisibility = *req.CompliancePortalVisibility
} }
document.UpdatedAt = now document.UpdatedAt = now
@@ -2225,7 +2225,7 @@ func (s *DocumentService) Update(
} }
hasVersionChanges := req.Title != nil || req.Content != nil || req.Classification != nil || req.DocumentType != nil hasVersionChanges := req.Title != nil || req.Content != nil || req.Classification != nil || req.DocumentType != nil
docLevelChanged := req.TrustCenterVisibility != nil || req.DefaultApproverIDs != nil docLevelChanged := req.CompliancePortalVisibility != nil || req.DefaultApproverIDs != nil
if req.Content != nil && document.WriteMode == coredata.DocumentWriteModeGenerated { if req.Content != nil && document.WriteMode == coredata.DocumentWriteModeGenerated {
return &ErrDocumentVersionGenerated{} return &ErrDocumentVersionGenerated{}
@@ -2498,7 +2498,7 @@ func (s *DocumentService) Archive(
document.Status = coredata.DocumentStatusArchived document.Status = coredata.DocumentStatusArchived
document.ArchivedAt = &now document.ArchivedAt = &now
document.UpdatedAt = now document.UpdatedAt = now
document.TrustCenterVisibility = coredata.TrustCenterVisibilityNone document.CompliancePortalVisibility = coredata.CompliancePortalVisibilityNone
if err := document.Update(ctx, tx, scope); err != nil { if err := document.Update(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot archive document: %w", err) return fmt.Errorf("cannot archive document: %w", err)

View File

@@ -98,13 +98,13 @@ func (s *GeneratedDocumentService) PublishStatementOfApplicability(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: soa.OrganizationID, OrganizationID: soa.OrganizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -371,13 +371,13 @@ func (s *GeneratedDocumentService) PublishDataList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -643,13 +643,13 @@ func (s *GeneratedDocumentService) PublishAssetList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -938,13 +938,13 @@ func (s *GeneratedDocumentService) PublishFindingList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -1264,13 +1264,13 @@ func (s *GeneratedDocumentService) PublishObligationList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -1558,13 +1558,13 @@ func (s *GeneratedDocumentService) PublishProcessingActivityList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -1953,13 +1953,13 @@ func (s *GeneratedDocumentService) PublishDataProtectionImpactAssessmentList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -2185,13 +2185,13 @@ func (s *GeneratedDocumentService) PublishTransferImpactAssessmentList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -2433,13 +2433,13 @@ func (s *GeneratedDocumentService) PublishThirdPartyList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {
@@ -2984,13 +2984,13 @@ func (s *GeneratedDocumentService) PublishRiskList(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityNone, CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {

View File

@@ -85,7 +85,7 @@ type (
StatusPageURL **string StatusPageURL **string
BusinessOwnerID **gid.GID BusinessOwnerID **gid.GID
SecurityOwnerID **gid.GID SecurityOwnerID **gid.GID
ShowOnTrustCenter *bool ShowOnCompliancePortal *bool
} }
CreateThirdPartyRiskAssessmentRequest struct { CreateThirdPartyRiskAssessmentRequest struct {
@@ -416,8 +416,8 @@ func (s ThirdPartyService) Update(
thirdParty.SecurityPageURL = *req.SecurityPageURL thirdParty.SecurityPageURL = *req.SecurityPageURL
} }
if req.ShowOnTrustCenter != nil { if req.ShowOnCompliancePortal != nil {
thirdParty.ShowOnTrustCenter = *req.ShowOnTrustCenter thirdParty.ShowOnCompliancePortal = *req.ShowOnCompliancePortal
} }
if req.TrustPageURL != nil { if req.TrustPageURL != nil {
@@ -607,7 +607,7 @@ func (s ThirdPartyService) Create(
TrustPageURL: req.TrustPageURL, TrustPageURL: req.TrustPageURL,
StatusPageURL: req.StatusPageURL, StatusPageURL: req.StatusPageURL,
TermsOfServiceURL: req.TermsOfServiceURL, TermsOfServiceURL: req.TermsOfServiceURL,
ShowOnTrustCenter: false, ShowOnCompliancePortal: false,
Level: 1, Level: 1,
} }
@@ -770,7 +770,7 @@ func (s ThirdPartyService) ImportFromCommon(
TermsOfServiceURL: commonParty.TermsOfServiceURL, TermsOfServiceURL: commonParty.TermsOfServiceURL,
SecurityPageURL: commonParty.SecurityPageURL, SecurityPageURL: commonParty.SecurityPageURL,
TrustPageURL: commonParty.TrustPageURL, TrustPageURL: commonParty.TrustPageURL,
ShowOnTrustCenter: false, ShowOnCompliancePortal: false,
Level: 1, Level: 1,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,

View File

@@ -76,7 +76,7 @@ func BuildTrackerPolicyDocument(data docgen.TrackerPolicyData) (string, error) {
// PublishTrackerPolicy generates (or regenerates) the cookie and tracking // PublishTrackerPolicy generates (or regenerates) the cookie and tracking
// technologies policy document for a banner from its latest published version // technologies policy document for a banner from its latest published version
// snapshot. The document is stored as a GENERATED document that is PRIVATE in // snapshot. The document is stored as a GENERATED document that is PRIVATE in
// the trust center by default, and is linked to the banner through // the compliance portal by default, and is linked to the banner through
// cookie_banners.policy_document_id. // cookie_banners.policy_document_id.
func (s *GeneratedDocumentService) PublishTrackerPolicy( func (s *GeneratedDocumentService) PublishTrackerPolicy(
ctx context.Context, ctx context.Context,
@@ -164,13 +164,13 @@ func (s *GeneratedDocumentService) PublishTrackerPolicy(
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType) documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
document = &coredata.Document{ document = &coredata.Document{
ID: documentID, ID: documentID,
OrganizationID: organizationID, OrganizationID: organizationID,
WriteMode: coredata.DocumentWriteModeGenerated, WriteMode: coredata.DocumentWriteModeGenerated,
TrustCenterVisibility: coredata.TrustCenterVisibilityPrivate, CompliancePortalVisibility: coredata.CompliancePortalVisibilityPrivate,
Status: coredata.DocumentStatusActive, Status: coredata.DocumentStatusActive,
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if err := document.Insert(ctx, tx, scope); err != nil { if err := document.Insert(ctx, tx, scope); err != nil {

View File

@@ -29,7 +29,7 @@ type (
MetricsConfig = probodconfig.MetricsConfig MetricsConfig = probodconfig.MetricsConfig
TracingConfig = probodconfig.TracingConfig TracingConfig = probodconfig.TracingConfig
ESignConfig = probodconfig.ESignConfig ESignConfig = probodconfig.ESignConfig
TrustCenterConfig = probodconfig.TrustCenterConfig CompliancePortalConfig = probodconfig.CompliancePortalConfig
APIConfig = probodconfig.APIConfig APIConfig = probodconfig.APIConfig
CorsConfig = probodconfig.CorsConfig CorsConfig = probodconfig.CorsConfig
GraphQLConfig = probodconfig.GraphQLConfig GraphQLConfig = probodconfig.GraphQLConfig

View File

@@ -145,7 +145,7 @@ func New() *Implm {
DomainVerificationResolverAddr: "8.8.8.8:53", DomainVerificationResolverAddr: "8.8.8.8:53",
}, },
}, },
TrustCenter: TrustCenterConfig{ CompliancePortal: CompliancePortalConfig{
HTTPAddr: ":80", HTTPAddr: ":80",
HTTPSAddr: ":443", HTTPSAddr: ":443",
BaseDomain: "probopage.com", BaseDomain: "probopage.com",
@@ -547,7 +547,7 @@ func (impl *Implm) Run(
CnameTarget: impl.cfg.CustomDomains.CnameTarget, CnameTarget: impl.cfg.CustomDomains.CnameTarget,
CAAIssuerDomain: impl.cfg.CustomDomains.CAAIssuerDomain, CAAIssuerDomain: impl.cfg.CustomDomains.CAAIssuerDomain,
ResolverAddr: impl.cfg.CustomDomains.ResolverAddr, ResolverAddr: impl.cfg.CustomDomains.ResolverAddr,
ManagedBaseDomain: impl.cfg.TrustCenter.BaseDomain, ManagedBaseDomain: impl.cfg.CompliancePortal.BaseDomain,
RenewalInterval: customDomainRenewalInterval, RenewalInterval: customDomainRenewalInterval,
ProvisionInterval: customDomainProvisionInterval, ProvisionInterval: customDomainProvisionInterval,
}, },
@@ -568,7 +568,7 @@ func (impl *Implm) Run(
Bucket: impl.cfg.AWS.Bucket, Bucket: impl.cfg.AWS.Bucket,
TokenSecret: impl.cfg.Auth.Cookie.Secret, TokenSecret: impl.cfg.Auth.Cookie.Secret,
BaseURL: baseURL, BaseURL: baseURL,
TrustCenterBaseDomain: impl.cfg.TrustCenter.BaseDomain, CompliancePortalBaseDomain: impl.cfg.CompliancePortal.BaseDomain,
EncryptionKey: encryptionKey, EncryptionKey: encryptionKey,
Certificate: samlCert, Certificate: samlCert,
PrivateKey: samlKey, PrivateKey: samlKey,
@@ -624,7 +624,7 @@ func (impl *Implm) Run(
s3Client, s3Client,
impl.cfg.AWS.Bucket, impl.cfg.AWS.Bucket,
baseURL.String(), baseURL.String(),
impl.cfg.TrustCenter.BaseDomain, impl.cfg.CompliancePortal.BaseDomain,
fileManagerService, fileManagerService,
certManagerService, certManagerService,
slackService, slackService,
@@ -671,7 +671,7 @@ func (impl *Implm) Run(
return fmt.Errorf("cannot create probo service: %w", err) return fmt.Errorf("cannot create probo service: %w", err)
} }
trustService := visitor.NewService( visitorService := visitor.NewService(
pgClient, pgClient,
s3Client, s3Client,
impl.cfg.AWS.Bucket, impl.cfg.AWS.Bucket,
@@ -691,7 +691,7 @@ func (impl *Implm) Run(
func(ctx context.Context, clientIDURL string) (oauth2.CIMDAllowance, error) { func(ctx context.Context, clientIDURL string) (oauth2.CIMDAllowance, error) {
host, ok := oauth2.CIMDClientIDHost(clientIDURL) host, ok := oauth2.CIMDClientIDHost(clientIDURL)
if ok { if ok {
_, err := trustService.GetPortalByDomainName(ctx, host) _, err := visitorService.GetPortalByDomainName(ctx, host)
if err == nil { if err == nil {
return oauth2.CIMDAllowanceAllowedSkipConsent, nil return oauth2.CIMDAllowanceAllowedSkipConsent, nil
} }
@@ -727,7 +727,7 @@ func (impl *Implm) Run(
ResourceAlias: resourceAliasService, ResourceAlias: resourceAliasService,
File: fileManagerService, File: fileManagerService,
IAM: iamService, IAM: iamService,
Trust: trustService, Visitor: visitorService,
ESign: esignService, ESign: esignService,
Management: managementService, Management: managementService,
CertManager: certManagerService, CertManager: certManagerService,
@@ -773,7 +773,7 @@ func (impl *Implm) Run(
ExtraHeaderFields: impl.cfg.Api.ExtraHeaderFields, ExtraHeaderFields: impl.cfg.Api.ExtraHeaderFields,
Logger: l.Named("compliance-portal"), Logger: l.Named("compliance-portal"),
IAM: iamService, IAM: iamService,
Visitor: trustService, Visitor: visitorService,
ResourceAlias: resourceAliasService, ResourceAlias: resourceAliasService,
File: fileManagerService, File: fileManagerService,
ESign: esignService, ESign: esignService,
@@ -798,7 +798,7 @@ func (impl *Implm) Run(
}, },
) )
if err != nil { if err != nil {
return fmt.Errorf("cannot create trust center handler: %w", err) return fmt.Errorf("cannot create compliance portal handler: %w", err)
} }
apiServerCtx, stopApiServer := context.WithCancel(context.Background()) apiServerCtx, stopApiServer := context.WithCancel(context.Background())
@@ -958,7 +958,7 @@ func (impl *Implm) Run(
wg.Go( wg.Go(
func() { func() {
if err := esignService.Run(esignServiceCtx, trustService.GetPortalEmailPresenterConfigByOrganizationID); err != nil { if err := esignService.Run(esignServiceCtx, visitorService.GetPortalEmailPresenterConfigByOrganizationID); err != nil {
cancel(fmt.Errorf("esign service crashed: %w", err)) cancel(fmt.Errorf("esign service crashed: %w", err))
} }
}, },
@@ -1133,22 +1133,22 @@ func (impl *Implm) Run(
}, },
) )
trustCenterServerCtx, stopTrustCenterServer := context.WithCancel(context.Background()) compliancePortalServerCtx, stopCompliancePortalServer := context.WithCancel(context.Background())
defer stopTrustCenterServer() defer stopCompliancePortalServer()
wg.Go( wg.Go(
func() { func() {
if err := impl.runTrustCenterServer( if err := impl.runCompliancePortalServer(
trustCenterServerCtx, compliancePortalServerCtx,
l, l,
r, r,
tp, tp,
pgClient, pgClient,
compliancePortalHandler, compliancePortalHandler,
trustService, visitorService,
encryptionKey, encryptionKey,
); err != nil { ); err != nil {
cancel(fmt.Errorf("trust center server crashed: %w", err)) cancel(fmt.Errorf("compliance portal server crashed: %w", err))
} }
}, },
) )
@@ -1156,7 +1156,7 @@ func (impl *Implm) Run(
<-ctx.Done() <-ctx.Done()
stopApiServer() stopApiServer()
stopTrustCenterServer() stopCompliancePortalServer()
stopWebhookWorker() stopWebhookWorker()
stopESignService() stopESignService()
stopCertManagerService() stopCertManagerService()
@@ -1298,7 +1298,7 @@ func (impl *Implm) runApiServer(
return ctx.Err() return ctx.Err()
} }
func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Logger) http.Handler { func newCompliancePortalHTTPRedirectHandler(visitorService *visitor.Service, l *log.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() ctx := r.Context()
@@ -1314,10 +1314,10 @@ func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Log
return return
} }
// Check if this domain is a trust center custom domain // Check if this domain is a compliance portal custom domain
if _, err := trustService.GetPortalByDomainName(ctx, domain); err != nil { if _, err := visitorService.GetPortalByDomainName(ctx, domain); err != nil {
if errors.Is(err, visitor.ErrPageNotFound) || errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, visitor.ErrPageNotFound) || errors.Is(err, coredata.ErrResourceNotFound) {
// Not a trust center domain, return 404 // Not a compliance portal domain, return 404
httpserver.RenderError(w, http.StatusNotFound, errors.New("not found")) httpserver.RenderError(w, http.StatusNotFound, errors.New("not found"))
return return
} }
@@ -1327,7 +1327,7 @@ func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Log
return return
} }
// This is a trust center domain, redirect to HTTPS // This is a compliance portal domain, redirect to HTTPS
base, err := baseurl.Parse("https://" + domain) base, err := baseurl.Parse("https://" + domain)
if err != nil { if err != nil {
httpserver.RenderError(w, http.StatusNotFound, errors.New("not found")) httpserver.RenderError(w, http.StatusNotFound, errors.New("not found"))
@@ -1337,7 +1337,7 @@ func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Log
httpsURL := base.WithPath(r.URL.Path).WithQueryValues(r.URL.Query()).MustString() httpsURL := base.WithPath(r.URL.Path).WithQueryValues(r.URL.Query()).MustString()
l.InfoCtx( l.InfoCtx(
ctx, ctx,
"HTTP request to trust center custom domain, redirecting to HTTPS", "HTTP request to compliance portal custom domain, redirecting to HTTPS",
log.String("domain", domain), log.String("domain", domain),
log.String("path", r.URL.Path), log.String("path", r.URL.Path),
log.String("to", httpsURL), log.String("to", httpsURL),
@@ -1346,19 +1346,19 @@ func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Log
}) })
} }
func (impl *Implm) runTrustCenterServer( func (impl *Implm) runCompliancePortalServer(
ctx context.Context, ctx context.Context,
l *log.Logger, l *log.Logger,
r prometheus.Registerer, r prometheus.Registerer,
tp trace.TracerProvider, tp trace.TracerProvider,
pgClient *pg.Client, pgClient *pg.Client,
trustRouter http.Handler, trustRouter http.Handler,
trustService *visitor.Service, visitorService *visitor.Service,
encryptionKey cipher.EncryptionKey, encryptionKey cipher.EncryptionKey,
) error { ) error {
tracer := tp.Tracer("go.probo.inc/probo/pkg/probod") tracer := tp.Tracer("go.probo.inc/probo/pkg/probod")
ctx, span := tracer.Start(ctx, "probod.runTrustCenterServer") ctx, span := tracer.Start(ctx, "probod.runCompliancePortalServer")
defer span.End() defer span.End()
certSelector := certmanager.NewSelector(pgClient, encryptionKey) certSelector := certmanager.NewSelector(pgClient, encryptionKey)
@@ -1371,7 +1371,7 @@ func (impl *Implm) runTrustCenterServer(
g, ctx := errgroup.WithContext(ctx) g, ctx := errgroup.WithContext(ctx)
l.Info("starting trust center services") l.Info("starting compliance portal services")
span.AddEvent("Trust center services starting") span.AddEvent("Trust center services starting")
httpACMEHandler := certmanager.NewACMEChallengeHandler( httpACMEHandler := certmanager.NewACMEChallengeHandler(
@@ -1379,10 +1379,10 @@ func (impl *Implm) runTrustCenterServer(
l.Named("http_acme_handler"), l.Named("http_acme_handler"),
) )
httpRedirectHandler := newTrustCenterHTTPRedirectHandler(trustService, l.Named("http_redirect")) httpRedirectHandler := newCompliancePortalHTTPRedirectHandler(visitorService, l.Named("http_redirect"))
httpServer := httpserver.NewServer( httpServer := httpserver.NewServer(
impl.cfg.TrustCenter.HTTPAddr, impl.cfg.CompliancePortal.HTTPAddr,
httpACMEHandler.Handle(httpRedirectHandler), httpACMEHandler.Handle(httpRedirectHandler),
httpserver.WithLogger(l), httpserver.WithLogger(l),
httpserver.WithRegisterer(r), httpserver.WithRegisterer(r),
@@ -1401,8 +1401,8 @@ func (impl *Implm) runTrustCenterServer(
defer func() { _ = listener.Close() }() defer func() { _ = listener.Close() }()
if len(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies) > 0 { if len(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies) > 0 {
policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies) policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies)
if err != nil { if err != nil {
return fmt.Errorf("cannot build proxy protocol policy: %w", err) return fmt.Errorf("cannot build proxy protocol policy: %w", err)
} }
@@ -1413,7 +1413,7 @@ func (impl *Implm) runTrustCenterServer(
ConnPolicy: policy, ConnPolicy: policy,
} }
l.Info("using proxy protocol for trust center HTTP server", log.Any("trusted-proxies", impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies)) l.Info("using proxy protocol for compliance portal HTTP server", log.Any("trusted-proxies", impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies))
} }
if err := httpServer.Serve(listener); err != nil && err != http.ErrServerClosed { if err := httpServer.Serve(listener); err != nil && err != http.ErrServerClosed {
@@ -1446,7 +1446,7 @@ func (impl *Implm) runTrustCenterServer(
} }
httpServerLogger := l.Named("", log.SkipMatch(ignoreTLSHandshakeErrors)) httpServerLogger := l.Named("", log.SkipMatch(ignoreTLSHandshakeErrors))
httpsServer := httpserver.NewServer( httpsServer := httpserver.NewServer(
impl.cfg.TrustCenter.HTTPSAddr, impl.cfg.CompliancePortal.HTTPSAddr,
handler, handler,
httpserver.WithLogger(httpServerLogger), httpserver.WithLogger(httpServerLogger),
httpserver.WithRegisterer(r), httpserver.WithRegisterer(r),
@@ -1482,7 +1482,7 @@ func (impl *Implm) runTrustCenterServer(
g.Go( g.Go(
func() error { func() error {
l.InfoCtx(ctx, "starting trust center https server", log.String("addr", httpsServer.Addr)) l.InfoCtx(ctx, "starting compliance portal https server", log.String("addr", httpsServer.Addr))
span.AddEvent("HTTPS server starting") span.AddEvent("HTTPS server starting")
listener, err := net.Listen("tcp", httpsServer.Addr) listener, err := net.Listen("tcp", httpsServer.Addr)
@@ -1492,8 +1492,8 @@ func (impl *Implm) runTrustCenterServer(
defer func() { _ = listener.Close() }() defer func() { _ = listener.Close() }()
if len(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies) > 0 { if len(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies) > 0 {
policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies) policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies)
if err != nil { if err != nil {
return fmt.Errorf("cannot build proxy protocol policy: %w", err) return fmt.Errorf("cannot build proxy protocol policy: %w", err)
} }
@@ -1504,7 +1504,7 @@ func (impl *Implm) runTrustCenterServer(
ConnPolicy: policy, ConnPolicy: policy,
} }
l.Info("using proxy protocol for trust center HTTPS server", log.Any("trusted-proxies", impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies)) l.Info("using proxy protocol for compliance portal HTTPS server", log.Any("trusted-proxies", impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies))
} }
if err := httpsServer.ServeTLS(listener, "", ""); err != nil && err != http.ErrServerClosed { if err := httpsServer.ServeTLS(listener, "", ""); err != nil && err != http.ErrServerClosed {
@@ -1515,7 +1515,7 @@ func (impl *Implm) runTrustCenterServer(
}, },
) )
l.Info("trust center servers started") l.Info("compliance portal servers started")
span.AddEvent("Trust center servers started") span.AddEvent("Trust center servers started")
go func() { go func() {
@@ -1524,7 +1524,7 @@ func (impl *Implm) runTrustCenterServer(
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
l.InfoCtx(ctx, "shutting down trust center servers...") l.InfoCtx(ctx, "shutting down compliance portal servers...")
span.AddEvent("Trust center servers shutting down") span.AddEvent("Trust center servers shutting down")
if err := httpsServer.Shutdown(shutdownCtx); err != nil { if err := httpsServer.Shutdown(shutdownCtx); err != nil {

View File

@@ -60,7 +60,7 @@ type (
Pg PgConfig `json:"pg"` Pg PgConfig `json:"pg"`
Api APIConfig `json:"api"` Api APIConfig `json:"api"`
Auth AuthConfig `json:"auth"` Auth AuthConfig `json:"auth"`
TrustCenter TrustCenterConfig `json:"trust-center"` CompliancePortal CompliancePortalConfig `json:"trust-center"`
AWS AWSConfig `json:"aws"` AWS AWSConfig `json:"aws"`
Notifications NotificationsConfig `json:"notifications"` Notifications NotificationsConfig `json:"notifications"`
Connectors []ConnectorConfig `json:"connectors,omitempty"` Connectors []ConnectorConfig `json:"connectors,omitempty"`
@@ -79,8 +79,8 @@ type (
Branding bool `json:"branding"` Branding bool `json:"branding"`
} }
// TrustCenterConfig contains trust center server configuration. // CompliancePortalConfig contains compliance portal server configuration.
TrustCenterConfig struct { CompliancePortalConfig struct {
HTTPAddr string `json:"http-addr,omitempty"` HTTPAddr string `json:"http-addr,omitempty"`
HTTPSAddr string `json:"https-addr,omitempty"` HTTPSAddr string `json:"https-addr,omitempty"`
BaseDomain string `json:"base-domain,omitempty"` BaseDomain string `json:"base-domain,omitempty"`

View File

@@ -123,9 +123,9 @@ func (s *Service) UpdateSlackAccessMessage(
return fmt.Errorf("cannot load slack message: %w", err) return fmt.Errorf("cannot load slack message: %w", err)
} }
var trustCenter coredata.TrustCenter var compliancePortal coredata.CompliancePortal
if err := trustCenter.LoadByOrganizationID(ctx, tx, scope, slackMessage.OrganizationID); err != nil { if err := compliancePortal.LoadByOrganizationID(ctx, tx, scope, slackMessage.OrganizationID); err != nil {
return fmt.Errorf("cannot load trust center: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
identity := &coredata.Identity{} identity := &coredata.Identity{}
@@ -133,12 +133,12 @@ func (s *Service) UpdateSlackAccessMessage(
return fmt.Errorf("cannot load identity: %w", err) return fmt.Errorf("cannot load identity: %w", err)
} }
var trustCenterAccess coredata.TrustCenterAccess var compliancePortalAccess coredata.CompliancePortalAccess
if err := trustCenterAccess.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, trustCenter.ID, identity.ID); err != nil { if err := compliancePortalAccess.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePortal.ID, identity.ID); err != nil {
return fmt.Errorf("cannot load trust center access: %w", err) return fmt.Errorf("cannot load compliance portal access: %w", err)
} }
documents, reports, files, err := s.loadDocumentsReportsAndFilesFromAccesses(ctx, tx, scope, trustCenterAccess.ID) documents, reports, files, err := s.loadDocumentsReportsAndFilesFromAccesses(ctx, tx, scope, compliancePortalAccess.ID)
if err != nil { if err != nil {
return err return err
} }
@@ -149,7 +149,7 @@ func (s *Service) UpdateSlackAccessMessage(
newSlackMessageID, newSlackMessageID,
identity.FullName, identity.FullName,
requesterEmail, requesterEmail,
trustCenter.OrganizationID, compliancePortal.OrganizationID,
documents, documents,
reports, reports,
files, files,
@@ -197,26 +197,26 @@ func (s *Service) QueueSlackNotification(
ctx context.Context, ctx context.Context,
scope coredata.Scoper, scope coredata.Scoper,
identityID gid.GID, identityID gid.GID,
trustCenterID gid.GID, compliancePortalID gid.GID,
) error { ) error {
return s.pg.WithTx(ctx, func(ctx context.Context, tx pg.Tx) error { return s.pg.WithTx(ctx, func(ctx context.Context, tx pg.Tx) error {
var ( var (
identity = &coredata.Identity{} identity = &coredata.Identity{}
trustCenterAccess *coredata.TrustCenterAccess compliancePortalAccess *coredata.CompliancePortalAccess
) )
if err := identity.LoadByID(ctx, tx, identityID); err != nil { if err := identity.LoadByID(ctx, tx, identityID); err != nil {
return fmt.Errorf("cannot load identity: %w", err) return fmt.Errorf("cannot load identity: %w", err)
} }
trustCenterAccess = &coredata.TrustCenterAccess{} compliancePortalAccess = &coredata.CompliancePortalAccess{}
if err := trustCenterAccess.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, trustCenterID, identityID); err != nil { if err := compliancePortalAccess.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePortalID, identityID); err != nil {
return fmt.Errorf("cannot load trust center access: %w", err) return fmt.Errorf("cannot load compliance portal access: %w", err)
} }
var trustCenter coredata.TrustCenter var compliancePortal coredata.CompliancePortal
if err := trustCenter.LoadByID(ctx, tx, scope, trustCenterID); err != nil { if err := compliancePortal.LoadByID(ctx, tx, scope, compliancePortalID); err != nil {
return fmt.Errorf("cannot load trust center: %w", err) return fmt.Errorf("cannot load compliance portal: %w", err)
} }
var connectors coredata.Connectors var connectors coredata.Connectors
@@ -224,7 +224,7 @@ func (s *Service) QueueSlackNotification(
ctx, ctx,
tx, tx,
scope, scope,
trustCenter.OrganizationID, compliancePortal.OrganizationID,
); err != nil { ); err != nil {
return fmt.Errorf("cannot load connectors: %w", err) return fmt.Errorf("cannot load connectors: %w", err)
} }
@@ -242,7 +242,7 @@ func (s *Service) QueueSlackNotification(
return ErrNoSlackConnector return ErrNoSlackConnector
} }
documents, reports, files, err := s.loadDocumentsReportsAndFilesFromAccesses(ctx, tx, scope, trustCenterAccess.ID) documents, reports, files, err := s.loadDocumentsReportsAndFilesFromAccesses(ctx, tx, scope, compliancePortalAccess.ID)
if err != nil { if err != nil {
return fmt.Errorf("cannot load documents, reports and files: %w", err) return fmt.Errorf("cannot load documents, reports and files: %w", err)
} }
@@ -253,7 +253,7 @@ func (s *Service) QueueSlackNotification(
slackMessageID, slackMessageID,
identity.FullName, identity.FullName,
identity.EmailAddress, identity.EmailAddress,
trustCenter.OrganizationID, compliancePortal.OrganizationID,
documents, documents,
reports, reports,
files, files,
@@ -271,8 +271,8 @@ func (s *Service) QueueSlackNotification(
now := time.Now() now := time.Now()
slackMessage := &coredata.SlackMessage{ slackMessage := &coredata.SlackMessage{
ID: slackMessageID, ID: slackMessageID,
OrganizationID: trustCenter.OrganizationID, OrganizationID: compliancePortal.OrganizationID,
Type: coredata.SlackMessageTypeTrustCenterAccessRequest, Type: coredata.SlackMessageTypeCompliancePortalAccessRequest,
Body: body, Body: body,
RequesterEmail: &identity.EmailAddress, RequesterEmail: &identity.EmailAddress,
Metadata: metadata.toMap(), Metadata: metadata.toMap(),
@@ -288,9 +288,9 @@ func (s *Service) QueueSlackNotification(
ctx, ctx,
tx, tx,
scope, scope,
trustCenter.OrganizationID, compliancePortal.OrganizationID,
identity.EmailAddress, identity.EmailAddress,
coredata.SlackMessageTypeTrustCenterAccessRequest, coredata.SlackMessageTypeCompliancePortalAccessRequest,
sevenDaysAgo, sevenDaysAgo,
) )
if err == nil { if err == nil {
@@ -323,7 +323,7 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
ctx context.Context, ctx context.Context,
conn pg.Querier, conn pg.Querier,
scope coredata.Scoper, scope coredata.Scoper,
trustCenterAccessID gid.GID, compliancePortalAccessID gid.GID,
) ( ) (
documents []SlackMessageDocument, documents []SlackMessageDocument,
reports []SlackMessageReport, reports []SlackMessageReport,
@@ -336,14 +336,14 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
accesses, err := page.LoadAll( accesses, err := page.LoadAll(
ctx, ctx,
page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{ page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt, Field: coredata.CompliancePortalDocumentAccessOrderFieldCreatedAt,
Direction: page.OrderDirectionAsc, Direction: page.OrderDirectionAsc,
}, },
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField]) ([]*coredata.TrustCenterDocumentAccess, error) { func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField]) ([]*coredata.CompliancePortalDocumentAccess, error) {
var batch coredata.TrustCenterDocumentAccesses var batch coredata.CompliancePortalDocumentAccesses
if err := batch.LoadByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID, cursor); err != nil { if err := batch.LoadByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID, cursor); err != nil {
return nil, fmt.Errorf("cannot load trust center document accesses: %w", err) return nil, fmt.Errorf("cannot load compliance portal document accesses: %w", err)
} }
return batch, nil return batch, nil
@@ -360,7 +360,7 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
return nil, nil, nil, fmt.Errorf("cannot load document: %w", err) return nil, nil, nil, fmt.Errorf("cannot load document: %w", err)
} }
if doc.CurrentPublishedMajor == nil || doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone { if doc.CurrentPublishedMajor == nil || doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
continue continue
} }
@@ -401,16 +401,16 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
) )
} }
if access.TrustCenterFileID != nil { if access.CompliancePortalFileID != nil {
file := &coredata.TrustCenterFile{} file := &coredata.CompliancePortalFile{}
if err := file.LoadByID(ctx, conn, scope, *access.TrustCenterFileID); err != nil { if err := file.LoadByID(ctx, conn, scope, *access.CompliancePortalFileID); err != nil {
return nil, nil, nil, fmt.Errorf("cannot load trust center file: %w", err) return nil, nil, nil, fmt.Errorf("cannot load compliance portal file: %w", err)
} }
files = append( files = append(
files, files,
SlackMessageFile{ SlackMessageFile{
ID: access.TrustCenterFileID.String(), ID: access.CompliancePortalFileID.String(),
Name: file.Name, Name: file.Name,
Category: file.Category, Category: file.Category,
Status: access.Status.String(), Status: access.Status.String(),

View File

@@ -47,7 +47,7 @@ type ComplianceDocsResult struct {
SubprocessorsListURL EnrichedField `json:"subprocessors_list_url" jsonschema:"URL of the vendor's sub-processors list page."` SubprocessorsListURL EnrichedField `json:"subprocessors_list_url" jsonschema:"URL of the vendor's sub-processors list page."`
StatusPageURL EnrichedField `json:"status_page_url" jsonschema:"URL of the vendor's uptime/status page (e.g. status.vendor.com)."` StatusPageURL EnrichedField `json:"status_page_url" jsonschema:"URL of the vendor's uptime/status page (e.g. status.vendor.com)."`
SecurityPageURL EnrichedField `json:"security_page_url" jsonschema:"URL of the vendor's security page or security overview."` SecurityPageURL EnrichedField `json:"security_page_url" jsonschema:"URL of the vendor's security page or security overview."`
TrustPageURL EnrichedField `json:"trust_page_url" jsonschema:"URL of the vendor's trust center / trust portal (e.g. Vanta, SafeBase, Drata hosted)."` TrustPageURL EnrichedField `json:"trust_page_url" jsonschema:"URL of the vendor's compliance portal / trust portal (e.g. Vanta, SafeBase, Drata hosted)."`
Certifications CertificationsField `json:"certifications" jsonschema:"Certifications and compliance frameworks the vendor publicly claims."` Certifications CertificationsField `json:"certifications" jsonschema:"Certifications and compliance frameworks the vendor publicly claims."`
} }

View File

@@ -114,7 +114,7 @@ type (
BusinessAssociateAgreementURL string `json:"business_associate_agreement_url" jsonschema:"URL to the BAA page if HIPAA-eligible"` BusinessAssociateAgreementURL string `json:"business_associate_agreement_url" jsonschema:"URL to the BAA page if HIPAA-eligible"`
SubprocessorsListURL string `json:"subprocessors_list_url" jsonschema:"URL to the public subprocessors list"` SubprocessorsListURL string `json:"subprocessors_list_url" jsonschema:"URL to the public subprocessors list"`
SecurityPageURL string `json:"security_page_url" jsonschema:"URL to the third_party's security page"` SecurityPageURL string `json:"security_page_url" jsonschema:"URL to the third_party's security page"`
TrustPageURL string `json:"trust_page_url" jsonschema:"URL to the trust center"` TrustPageURL string `json:"trust_page_url" jsonschema:"URL to the compliance portal"`
TermsOfServiceURL string `json:"terms_of_service_url" jsonschema:"URL to the terms of service"` TermsOfServiceURL string `json:"terms_of_service_url" jsonschema:"URL to the terms of service"`
StatusPageURL string `json:"status_page_url" jsonschema:"URL to the third_party's status / uptime page"` StatusPageURL string `json:"status_page_url" jsonschema:"URL to the third_party's status / uptime page"`
BugBountyURL string `json:"bug_bounty_url" jsonschema:"URL to the bug bounty or responsible disclosure program"` BugBountyURL string `json:"bug_bounty_url" jsonschema:"URL to the bug bounty or responsible disclosure program"`

View File

@@ -143,19 +143,19 @@ func newOrchestratorAgent(
}, },
{ {
toolName: "assess_data_processing", toolName: "assess_data_processing",
description: "Assess data processing practices. Returns structured JSON with encryption, retention, deletion, data locations, transfer mechanisms, DPA status, DSAR handling, and rating. Input: a relevant page URL (privacy policy, DPA, security page, or trust center).", description: "Assess data processing practices. Returns structured JSON with encryption, retention, deletion, data locations, transfer mechanisms, DPA status, DSAR handling, and rating. Input: a relevant page URL (privacy policy, DPA, security page, or compliance portal).",
tools: readOnlyBrowserTools, tools: readOnlyBrowserTools,
build: buildDataProcessingAgent, build: buildDataProcessingAgent,
}, },
{ {
toolName: "assess_incident_response", toolName: "assess_incident_response",
description: "Evaluate incident response capabilities. Returns structured JSON with ir_plan, notification_timeline, status_page, post_mortems, recent_incidents, security_contact, and rating. Input: a relevant page URL (security page, trust center, or status page).", description: "Evaluate incident response capabilities. Returns structured JSON with ir_plan, notification_timeline, status_page, post_mortems, recent_incidents, security_contact, and rating. Input: a relevant page URL (security page, compliance portal, or status page).",
tools: readOnlyBrowserTools, tools: readOnlyBrowserTools,
build: buildIncidentResponseAgent, build: buildIncidentResponseAgent,
}, },
{ {
toolName: "assess_business_continuity", toolName: "assess_business_continuity",
description: "Evaluate business continuity and disaster recovery. Returns structured JSON with dr_plan, rto, rpo, cloud_providers, uptime_sla, regions, backup_strategy, and rating. Input: a relevant page URL (SLA page, trust center, or infrastructure docs).", description: "Evaluate business continuity and disaster recovery. Returns structured JSON with dr_plan, rto, rpo, cloud_providers, uptime_sla, regions, backup_strategy, and rating. Input: a relevant page URL (SLA page, compliance portal, or infrastructure docs).",
tools: readOnlyBrowserTools, tools: readOnlyBrowserTools,
build: buildBusinessContinuityAgent, build: buildBusinessContinuityAgent,
}, },
@@ -167,13 +167,13 @@ func newOrchestratorAgent(
}, },
{ {
toolName: "assess_ai_risk", toolName: "assess_ai_risk",
description: "Evaluate AI governance (ISO 42001). Returns structured JSON with ai_involvement, use_cases, model_transparency, bias_controls, customer_data_training, human_oversight, and rating. Input: relevant page URL (AI policy, trust center, responsible AI page, or main website).", description: "Evaluate AI governance (ISO 42001). Returns structured JSON with ai_involvement, use_cases, model_transparency, bias_controls, customer_data_training, human_oversight, and rating. Input: relevant page URL (AI policy, compliance portal, responsible AI page, or main website).",
tools: readOnlyBrowserTools, tools: readOnlyBrowserTools,
build: buildAIRiskAgent, build: buildAIRiskAgent,
}, },
{ {
toolName: "assess_regulatory_compliance", toolName: "assess_regulatory_compliance",
description: "Deep regulatory compliance check. Returns structured JSON with per-framework assessment (gdpr, hipaa, pci_dss, sox) each with articles, status, and notes. Input: relevant page URL (DPA, compliance page, trust center).", description: "Deep regulatory compliance check. Returns structured JSON with per-framework assessment (gdpr, hipaa, pci_dss, sox) each with articles, status, and notes. Input: relevant page URL (DPA, compliance page, compliance portal).",
tools: readOnlyBrowserTools, tools: readOnlyBrowserTools,
build: buildRegulatoryComplianceAgent, build: buildRegulatoryComplianceAgent,
}, },

View File

@@ -336,13 +336,13 @@ type (
// --- ThirdParty Comparison --- // --- ThirdParty Comparison ---
AlternativeThirdParty struct { AlternativeThirdParty struct {
Name string `json:"name" jsonschema:"Alternative third_party name"` Name string `json:"name" jsonschema:"Alternative third_party name"`
Website string `json:"website" jsonschema:"Alternative third_party website URL"` Website string `json:"website" jsonschema:"Alternative third_party website URL"`
Certifications []string `json:"certifications" jsonschema:"Visible certifications"` Certifications []string `json:"certifications" jsonschema:"Visible certifications"`
TrustCenter bool `json:"trust_center" jsonschema:"Whether a trust center page was found"` CompliancePortal bool `json:"compliance_portal" jsonschema:"Whether a compliance portal page was found"`
PrivacyPolicy bool `json:"privacy_policy" jsonschema:"Whether a privacy policy was found"` PrivacyPolicy bool `json:"privacy_policy" jsonschema:"Whether a privacy policy was found"`
CompanySize string `json:"company_size" jsonschema:"Estimated company size"` CompanySize string `json:"company_size" jsonschema:"Estimated company size"`
SecurityScore string `json:"security_score" jsonschema:"Quick security impression: Strong, Adequate, or Weak"` SecurityScore string `json:"security_score" jsonschema:"Quick security impression: Strong, Adequate, or Weak"`
} }
ComparisonSummary struct { ComparisonSummary struct {

View File

@@ -28,17 +28,17 @@ import (
) )
type Document struct { type Document struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
OrganizationID gid.GID `json:"organizationId"` OrganizationID gid.GID `json:"organizationId"`
Title string `json:"title"` Title string `json:"title"`
DocumentType coredata.DocumentType `json:"documentType"` DocumentType coredata.DocumentType `json:"documentType"`
Status coredata.DocumentStatus `json:"status"` Status coredata.DocumentStatus `json:"status"`
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"` CompliancePortalVisibility coredata.CompliancePortalVisibility `json:"compliancePortalVisibility"`
CurrentPublishedMajor *int `json:"currentPublishedMajor"` CurrentPublishedMajor *int `json:"currentPublishedMajor"`
CurrentPublishedMinor *int `json:"currentPublishedMinor"` CurrentPublishedMinor *int `json:"currentPublishedMinor"`
ArchivedAt *time.Time `json:"archivedAt"` ArchivedAt *time.Time `json:"archivedAt"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }
type DocumentVersion struct { type DocumentVersion struct {
@@ -91,17 +91,17 @@ type DocumentApprovalDecision struct {
func NewDocument(d *coredata.Document) *Document { func NewDocument(d *coredata.Document) *Document {
return &Document{ return &Document{
ID: d.ID, ID: d.ID,
OrganizationID: d.OrganizationID, OrganizationID: d.OrganizationID,
Title: d.Title, Title: d.Title,
DocumentType: d.DocumentType, DocumentType: d.DocumentType,
Status: d.Status, Status: d.Status,
TrustCenterVisibility: d.TrustCenterVisibility, CompliancePortalVisibility: d.CompliancePortalVisibility,
CurrentPublishedMajor: d.CurrentPublishedMajor, CurrentPublishedMajor: d.CurrentPublishedMajor,
CurrentPublishedMinor: d.CurrentPublishedMinor, CurrentPublishedMinor: d.CurrentPublishedMinor,
ArchivedAt: d.ArchivedAt, ArchivedAt: d.ArchivedAt,
CreatedAt: d.CreatedAt, CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt, UpdatedAt: d.UpdatedAt,
} }
} }