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:
@@ -57,7 +57,7 @@ func FetchSitemapTool() agent.Tool {
|
||||
|
||||
return agent.FunctionTool(
|
||||
"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) {
|
||||
if err := validatePublicURL(p.URL); err != nil {
|
||||
return agent.ResultJSON(
|
||||
|
||||
@@ -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"),
|
||||
HTTPSAddr: b.resolver.getEnv("PROBOD_TRUST_CENTER_HTTPS_ADDR"),
|
||||
BaseDomain: b.resolver.getEnv("PROBOD_TRUST_CENTER_BASE_DOMAIN"),
|
||||
|
||||
@@ -188,10 +188,10 @@ func TestBuilder_Build_Defaults(t *testing.T) {
|
||||
assert.Empty(t, cfg.Probod.Auth.SAML.DomainVerificationResolverAddr)
|
||||
|
||||
// Trust center config
|
||||
assert.Empty(t, cfg.Probod.TrustCenter.HTTPAddr)
|
||||
assert.Empty(t, cfg.Probod.TrustCenter.HTTPSAddr)
|
||||
assert.Empty(t, cfg.Probod.TrustCenter.BaseDomain)
|
||||
assert.Nil(t, cfg.Probod.TrustCenter.ProxyProtocol.TrustedProxies)
|
||||
assert.Empty(t, cfg.Probod.CompliancePortal.HTTPAddr)
|
||||
assert.Empty(t, cfg.Probod.CompliancePortal.HTTPSAddr)
|
||||
assert.Empty(t, cfg.Probod.CompliancePortal.BaseDomain)
|
||||
assert.Nil(t, cfg.Probod.CompliancePortal.ProxyProtocol.TrustedProxies)
|
||||
|
||||
// AWS config
|
||||
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, "1.1.1.1:53", cfg.Probod.Auth.SAML.DomainVerificationResolverAddr)
|
||||
// Trust center
|
||||
assert.Equal(t, ":8080", cfg.Probod.TrustCenter.HTTPAddr)
|
||||
assert.Equal(t, ":8443", cfg.Probod.TrustCenter.HTTPSAddr)
|
||||
assert.Equal(t, "probopage.example.com", cfg.Probod.TrustCenter.BaseDomain)
|
||||
assert.Equal(t, []string{"10.0.1.1", "10.0.1.2"}, cfg.Probod.TrustCenter.ProxyProtocol.TrustedProxies)
|
||||
assert.Equal(t, ":8080", cfg.Probod.CompliancePortal.HTTPAddr)
|
||||
assert.Equal(t, ":8443", cfg.Probod.CompliancePortal.HTTPSAddr)
|
||||
assert.Equal(t, "probopage.example.com", cfg.Probod.CompliancePortal.BaseDomain)
|
||||
assert.Equal(t, []string{"10.0.1.1", "10.0.1.2"}, cfg.Probod.CompliancePortal.ProxyProtocol.TrustedProxies)
|
||||
// AWS
|
||||
assert.Equal(t, "eu-west-1", cfg.Probod.AWS.Region)
|
||||
assert.Equal(t, "probo-files", cfg.Probod.AWS.Bucket)
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestWriteConfig_OmitsEmptyOptionalBlocks(t *testing.T) {
|
||||
Pepper: "pepper",
|
||||
},
|
||||
},
|
||||
TrustCenter: probodconfig.TrustCenterConfig{
|
||||
CompliancePortal: probodconfig.CompliancePortalConfig{
|
||||
HTTPAddr: ":80",
|
||||
},
|
||||
CustomDomains: probodconfig.CustomDomainsConfig{
|
||||
@@ -222,9 +222,9 @@ func TestWriteConfig_OmitsEmptyOptionalBlocks(t *testing.T) {
|
||||
require.True(t, ok)
|
||||
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)
|
||||
assert.NotContains(t, trustCenter, "proxy-protocol")
|
||||
assert.NotContains(t, compliancePortal, "proxy-protocol")
|
||||
|
||||
llm, ok := probod["llm"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
@@ -249,7 +249,7 @@ func TestWriteConfig_OmitsEmptyProxyProtocolAndCorsSlices(t *testing.T) {
|
||||
AllowedOrigins: []string{},
|
||||
},
|
||||
},
|
||||
TrustCenter: probodconfig.TrustCenterConfig{
|
||||
CompliancePortal: probodconfig.CompliancePortalConfig{
|
||||
HTTPAddr: ":10080",
|
||||
ProxyProtocol: probodconfig.ProxyProtocolConfig{
|
||||
TrustedProxies: make([]string, 0),
|
||||
@@ -277,9 +277,9 @@ func TestWriteConfig_OmitsEmptyProxyProtocolAndCorsSlices(t *testing.T) {
|
||||
assert.NotContains(t, api, "proxy-protocol")
|
||||
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)
|
||||
assert.NotContains(t, trustCenter, "proxy-protocol")
|
||||
assert.NotContains(t, compliancePortal, "proxy-protocol")
|
||||
}
|
||||
|
||||
func TestWriteConfig_OmitsEmptyExtraHeaderFieldsMap(t *testing.T) {
|
||||
|
||||
@@ -38,32 +38,32 @@ import (
|
||||
|
||||
type (
|
||||
CreateAccessRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
IdentityID gid.GID
|
||||
CompliancePortalID gid.GID
|
||||
IdentityID gid.GID
|
||||
}
|
||||
|
||||
UpdateDocumentAccessRequest struct {
|
||||
ID gid.GID
|
||||
Status coredata.TrustCenterDocumentAccessStatus
|
||||
Status coredata.CompliancePortalDocumentAccessStatus
|
||||
}
|
||||
|
||||
UpdateAccessRequest struct {
|
||||
ID gid.GID
|
||||
DocumentAccesses []UpdateDocumentAccessRequest
|
||||
ReportAccesses []UpdateDocumentAccessRequest
|
||||
TrustCenterFileAccesses []UpdateDocumentAccessRequest
|
||||
ID gid.GID
|
||||
DocumentAccesses []UpdateDocumentAccessRequest
|
||||
ReportAccesses []UpdateDocumentAccessRequest
|
||||
CompliancePortalFileAccesses []UpdateDocumentAccessRequest
|
||||
}
|
||||
|
||||
AccessData struct {
|
||||
TrustCenterID gid.GID `json:"trust_center_id"`
|
||||
Email mail.Addr `json:"email"`
|
||||
CompliancePortalID gid.GID `json:"trust_center_id"`
|
||||
Email mail.Addr `json:"email"`
|
||||
}
|
||||
)
|
||||
|
||||
func (utcar *UpdateAccessRequest) Validate() error {
|
||||
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 {
|
||||
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))
|
||||
}
|
||||
|
||||
for i, reportAccess := range utcar.TrustCenterFileAccesses {
|
||||
v.Check(reportAccess.ID, fmt.Sprintf("trustCenterFileAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.TrustCenterFileEntityType))
|
||||
for i, reportAccess := range utcar.CompliancePortalFileAccesses {
|
||||
v.Check(reportAccess.ID, fmt.Sprintf("compliancePortalFileAccesses[%d].ID", i), validator.Required(), validator.GID(coredata.CompliancePortalFileEntityType))
|
||||
}
|
||||
|
||||
return v.Error()
|
||||
@@ -84,14 +84,14 @@ func (s *Service) ListAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterAccessOrderField],
|
||||
) (*page.Page[*coredata.TrustCenterAccess, coredata.TrustCenterAccessOrderField], error) {
|
||||
var accesses coredata.TrustCenterAccesses
|
||||
cursor *page.Cursor[coredata.CompliancePortalAccessOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalAccess, coredata.CompliancePortalAccessOrderField], error) {
|
||||
var accesses coredata.CompliancePortalAccesses
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
@@ -104,15 +104,15 @@ func (s *Service) ListAccesses(
|
||||
func (s *Service) ListAvailableDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField],
|
||||
) (*page.Page[*coredata.TrustCenterDocumentAccess, coredata.TrustCenterDocumentAccessOrderField], error) {
|
||||
var documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
compliancePortalAccessID gid.GID,
|
||||
cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalDocumentAccess, coredata.CompliancePortalDocumentAccessOrderField], error) {
|
||||
var documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
@@ -126,8 +126,8 @@ func (s *Service) GetAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
accessID gid.GID,
|
||||
) (*coredata.TrustCenterAccess, error) {
|
||||
var access coredata.TrustCenterAccess
|
||||
) (*coredata.CompliancePortalAccess, error) {
|
||||
var access coredata.CompliancePortalAccess
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -145,7 +145,7 @@ func (s *Service) GetAccess(
|
||||
func (s *Service) CountDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -153,11 +153,11 @@ func (s *Service) CountDocumentAccesses(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var (
|
||||
documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
err error
|
||||
)
|
||||
|
||||
count, err = documentAccesses.CountByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID)
|
||||
count, err = documentAccesses.CountByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
|
||||
|
||||
return err
|
||||
},
|
||||
@@ -172,7 +172,7 @@ func (s *Service) CountDocumentAccesses(
|
||||
func (s *Service) CountPendingRequestDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -180,11 +180,11 @@ func (s *Service) CountPendingRequestDocumentAccesses(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var (
|
||||
documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
err error
|
||||
)
|
||||
|
||||
count, err = documentAccesses.CountPendingRequestByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID)
|
||||
count, err = documentAccesses.CountPendingRequestByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
|
||||
|
||||
return err
|
||||
},
|
||||
@@ -199,7 +199,7 @@ func (s *Service) CountPendingRequestDocumentAccesses(
|
||||
func (s *Service) CountActiveDocumentAccesses(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -207,11 +207,11 @@ func (s *Service) CountActiveDocumentAccesses(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
var (
|
||||
documentAccesses coredata.TrustCenterDocumentAccesses
|
||||
documentAccesses coredata.CompliancePortalDocumentAccesses
|
||||
err error
|
||||
)
|
||||
|
||||
count, err = documentAccesses.CountActiveByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID)
|
||||
count, err = documentAccesses.CountActiveByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID)
|
||||
|
||||
return err
|
||||
},
|
||||
@@ -227,34 +227,34 @@ func (s *Service) UpdateAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateAccessRequest,
|
||||
) (*coredata.TrustCenterAccess, error) {
|
||||
) (*coredata.CompliancePortalAccess, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
access *coredata.TrustCenterAccess
|
||||
trustCenterAcessActivated bool
|
||||
shouldUpdateSlackMessage bool
|
||||
access *coredata.CompliancePortalAccess
|
||||
compliancePortalAcessActivated bool
|
||||
shouldUpdateSlackMessage bool
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page access: %w", err)
|
||||
}
|
||||
|
||||
var tcdas coredata.TrustCenterDocumentAccesses
|
||||
var tcdas coredata.CompliancePortalDocumentAccesses
|
||||
|
||||
if len(req.DocumentAccesses) > 0 {
|
||||
var documentData []coredata.MergeTrustCenterDocumentAccessesData
|
||||
var documentData []coredata.MergeCompliancePortalDocumentAccessesData
|
||||
|
||||
documentIDs := make([]gid.GID, 0, len(req.DocumentAccesses))
|
||||
for _, d := range req.DocumentAccesses {
|
||||
documentData = append(documentData, coredata.MergeTrustCenterDocumentAccessesData{
|
||||
documentData = append(documentData, coredata.MergeCompliancePortalDocumentAccessesData{
|
||||
ID: d.ID,
|
||||
Status: d.Status,
|
||||
})
|
||||
@@ -273,11 +273,11 @@ func (s *Service) UpdateAccess(
|
||||
}
|
||||
|
||||
if len(req.ReportAccesses) > 0 {
|
||||
var reportData []coredata.MergeTrustCenterDocumentAccessesData
|
||||
var reportData []coredata.MergeCompliancePortalDocumentAccessesData
|
||||
|
||||
reportIDs := make([]gid.GID, 0, len(req.ReportAccesses))
|
||||
for _, d := range req.ReportAccesses {
|
||||
reportData = append(reportData, coredata.MergeTrustCenterDocumentAccessesData{
|
||||
reportData = append(reportData, coredata.MergeCompliancePortalDocumentAccessesData{
|
||||
ID: d.ID,
|
||||
Status: d.Status,
|
||||
})
|
||||
@@ -295,39 +295,39 @@ func (s *Service) UpdateAccess(
|
||||
}
|
||||
}
|
||||
|
||||
if len(req.TrustCenterFileAccesses) > 0 {
|
||||
var fileData []coredata.MergeTrustCenterDocumentAccessesData
|
||||
if len(req.CompliancePortalFileAccesses) > 0 {
|
||||
var fileData []coredata.MergeCompliancePortalDocumentAccessesData
|
||||
|
||||
trustCenterFileIDs := make([]gid.GID, 0, len(req.TrustCenterFileAccesses))
|
||||
for _, d := range req.TrustCenterFileAccesses {
|
||||
fileData = append(fileData, coredata.MergeTrustCenterDocumentAccessesData{
|
||||
compliancePortalFileIDs := make([]gid.GID, 0, len(req.CompliancePortalFileAccesses))
|
||||
for _, d := range req.CompliancePortalFileAccesses {
|
||||
fileData = append(fileData, coredata.MergeCompliancePortalDocumentAccessesData{
|
||||
ID: d.ID,
|
||||
Status: d.Status,
|
||||
})
|
||||
|
||||
trustCenterFileIDs = append(trustCenterFileIDs, d.ID)
|
||||
compliancePortalFileIDs = append(compliancePortalFileIDs, d.ID)
|
||||
}
|
||||
|
||||
trustCenterFiles := &coredata.TrustCenterFiles{}
|
||||
if err := trustCenterFiles.LoadByIDs(ctx, tx, scope, trustCenterFileIDs); err != nil {
|
||||
compliancePortalFiles := &coredata.CompliancePortalFiles{}
|
||||
if err := compliancePortalFiles.LoadByIDs(ctx, tx, scope, compliancePortalFileIDs); err != nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
if trustCenterAcessActivated {
|
||||
if compliancePortalAcessActivated {
|
||||
if err := s.sendAccessEmail(ctx, scope, tx, access); err != nil {
|
||||
return fmt.Errorf("cannot send access email: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
shouldUpdateSlackMessage = trustCenterAcessActivated ||
|
||||
shouldUpdateSlackMessage = compliancePortalAcessActivated ||
|
||||
len(req.DocumentAccesses) > 0 ||
|
||||
len(req.ReportAccesses) > 0 ||
|
||||
len(req.TrustCenterFileAccesses) > 0
|
||||
len(req.CompliancePortalFileAccesses) > 0
|
||||
|
||||
return nil
|
||||
},
|
||||
@@ -337,7 +337,7 @@ func (s *Service) UpdateAccess(
|
||||
}
|
||||
|
||||
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) {
|
||||
return nil, fmt.Errorf("cannot queue slack notification: %w", err)
|
||||
}
|
||||
@@ -350,14 +350,14 @@ func (s *Service) UpdateAccess(
|
||||
func (s *Service) DeleteAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ func (s *Service) sendAccessEmail(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
tx pg.Tx,
|
||||
access *coredata.TrustCenterAccess,
|
||||
access *coredata.CompliancePortalAccess,
|
||||
) error {
|
||||
organization := &coredata.Organization{}
|
||||
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)
|
||||
}
|
||||
|
||||
emailPresenterCfg, err := s.EmailPresenterConfig(ctx, scope, access.TrustCenterID)
|
||||
emailPresenterCfg, err := s.EmailPresenterConfig(ctx, scope, access.CompliancePortalID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
|
||||
}
|
||||
|
||||
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 {
|
||||
return fmt.Errorf("cannot render compliance page access email: %w", err)
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ import (
|
||||
|
||||
type (
|
||||
CreateCompliancePortalCommitmentGroupRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Title string
|
||||
Description string
|
||||
CompliancePortalID gid.GID
|
||||
Title string
|
||||
Description string
|
||||
}
|
||||
|
||||
UpdateCompliancePortalCommitmentGroupRequest struct {
|
||||
@@ -50,7 +50,7 @@ type (
|
||||
func (r *CreateCompliancePortalCommitmentGroupRequest) Validate() error {
|
||||
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.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
|
||||
@@ -70,7 +70,7 @@ func (r *UpdateCompliancePortalCommitmentGroupRequest) Validate() error {
|
||||
func (s *Service) ListCommitmentGroups(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) {
|
||||
var groups coredata.CompliancePortalCommitmentGroups
|
||||
@@ -78,7 +78,7 @@ func (s *Service) ListCommitmentGroups(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance portal commitment groups: %w", err)
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func (s *Service) ListCommitmentGroups(
|
||||
func (s *Service) CountCommitmentGroups(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
) (int, error) {
|
||||
var count int
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s *Service) CountCommitmentGroups(
|
||||
func(ctx context.Context, conn pg.Querier) (err error) {
|
||||
groups := coredata.CompliancePortalCommitmentGroups{}
|
||||
|
||||
count, err = groups.CountByTrustCenterID(ctx, conn, scope, trustCenterID)
|
||||
count, err = groups.CountByCompliancePortalID(ctx, conn, scope, compliancePortalID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot count compliance portal commitment groups: %w", err)
|
||||
}
|
||||
@@ -163,19 +163,19 @@ func (s *Service) CreateCommitmentGroup(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
trustCenter := &coredata.TrustCenter{}
|
||||
if err := trustCenter.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
compliancePortal := &coredata.CompliancePortal{}
|
||||
if err := compliancePortal.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal: %w", err)
|
||||
}
|
||||
|
||||
group = &coredata.CompliancePortalCommitmentGroup{
|
||||
ID: groupID,
|
||||
OrganizationID: trustCenter.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: groupID,
|
||||
OrganizationID: compliancePortal.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := group.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -181,16 +181,16 @@ func (s *Service) CreateCommitment(
|
||||
}
|
||||
|
||||
commitment = &coredata.CompliancePortalCommitment{
|
||||
ID: commitmentID,
|
||||
OrganizationID: group.OrganizationID,
|
||||
TrustCenterID: group.TrustCenterID,
|
||||
GroupID: req.GroupID,
|
||||
Icon: req.Icon,
|
||||
Eyebrow: req.Eyebrow,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: commitmentID,
|
||||
OrganizationID: group.OrganizationID,
|
||||
CompliancePortalID: group.CompliancePortalID,
|
||||
GroupID: req.GroupID,
|
||||
Icon: req.Icon,
|
||||
Eyebrow: req.Eyebrow,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := commitment.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -34,9 +34,9 @@ import (
|
||||
|
||||
type (
|
||||
CreateCustomLinkRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Name string
|
||||
URL string
|
||||
CompliancePortalID gid.GID
|
||||
Name string
|
||||
URL string
|
||||
}
|
||||
|
||||
UpdateCustomLinkRequest struct {
|
||||
@@ -53,7 +53,7 @@ type (
|
||||
|
||||
func (r *CreateCustomLinkRequest) Validate() error {
|
||||
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())
|
||||
|
||||
return v.Error()
|
||||
@@ -86,7 +86,7 @@ func (s *Service) ListCustomLinks(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -117,19 +117,19 @@ func (s *Service) CreateCustomLink(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
item = &coredata.ComplianceCustomLink{
|
||||
ID: id,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Name: req.Name,
|
||||
URL: req.URL,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: id,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
Name: req.Name,
|
||||
URL: req.URL,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := item.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -23,11 +23,11 @@ import (
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
)
|
||||
|
||||
func (s *Service) EffectiveDomainForCompliancePage(
|
||||
func (s *Service) EffectiveDomainForCompliancePortal(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (*coredata.CustomDomain, error) {
|
||||
byID, active, err := loadDomains(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
@@ -49,11 +49,11 @@ func (s *Service) EffectiveDomainForCompliancePage(
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Service) PublicURLForCompliancePage(
|
||||
func (s *Service) PublicURLForCompliancePortal(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (string, error) {
|
||||
byID, active, err := loadDomains(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
@@ -80,7 +80,7 @@ func loadDomains(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (map[gid.GID]*coredata.CustomDomain, map[gid.GID]bool, error) {
|
||||
var ids []gid.GID
|
||||
if compliancePage.CustomDomainID != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *Service) AddCustomDomain(
|
||||
domain string,
|
||||
) (*coredata.CustomDomain, error) {
|
||||
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())
|
||||
|
||||
if err := v.Error(); err != nil {
|
||||
@@ -47,7 +47,7 @@ func (s *Service) AddCustomDomain(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (s *Service) RemoveCustomDomain(
|
||||
return ErrCustomDomainManaged
|
||||
}
|
||||
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := compliancePage.LoadByDomainID(ctx, tx, customDomainID)
|
||||
switch {
|
||||
@@ -177,14 +177,14 @@ func (s *Service) PublicURL(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
publicURL, err = s.PublicURLForCompliancePage(ctx, conn, scope, compliancePage)
|
||||
publicURL, err = s.PublicURLForCompliancePortal(ctx, conn, scope, compliancePage)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot resolve public url: %w", err)
|
||||
}
|
||||
|
||||
@@ -41,18 +41,18 @@ import (
|
||||
|
||||
type (
|
||||
CreateFileRequest struct {
|
||||
OrganizationID gid.GID
|
||||
Name string
|
||||
Category string
|
||||
File File
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility
|
||||
OrganizationID gid.GID
|
||||
Name string
|
||||
Category string
|
||||
File File
|
||||
CompliancePortalVisibility coredata.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
UpdateFileRequest struct {
|
||||
ID gid.GID
|
||||
Name *string
|
||||
Category *string
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
ID gid.GID
|
||||
Name *string
|
||||
Category *string
|
||||
CompliancePortalVisibility *coredata.CompliancePortalVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -63,7 +63,7 @@ func (ctcfr *CreateFileRequest) Validate() error {
|
||||
v.Check(ctcfr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(ctcfr.Category, "category", validator.Required(), validator.SafeText(TitleMaxLength))
|
||||
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()
|
||||
}
|
||||
@@ -71,10 +71,10 @@ func (ctcfr *CreateFileRequest) Validate() error {
|
||||
func (utcfr *UpdateFileRequest) Validate() error {
|
||||
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.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()
|
||||
}
|
||||
@@ -83,10 +83,10 @@ func (s *Service) ListFilesForOrganizationID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterFileOrderField],
|
||||
filter *coredata.TrustCenterFileFilter,
|
||||
) (*page.Page[*coredata.TrustCenterFile, coredata.TrustCenterFileOrderField], error) {
|
||||
var files coredata.TrustCenterFiles
|
||||
cursor *page.Cursor[coredata.CompliancePortalFileOrderField],
|
||||
filter *coredata.CompliancePortalFileFilter,
|
||||
) (*page.Page[*coredata.CompliancePortalFile, coredata.CompliancePortalFileOrderField], error) {
|
||||
var files coredata.CompliancePortalFiles
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -116,7 +116,7 @@ func (s *Service) CountFilesForOrganizationID(
|
||||
func(ctx context.Context, conn pg.Querier) 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 {
|
||||
return fmt.Errorf("cannot count compliance page files: %w", err)
|
||||
}
|
||||
@@ -134,13 +134,13 @@ func (s *Service) GetFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
id gid.GID,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
var file *coredata.TrustCenterFile
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
var file *coredata.CompliancePortalFile
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
file = &coredata.TrustCenterFile{}
|
||||
file = &coredata.CompliancePortalFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, id); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func (s *Service) CreateFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *CreateFileRequest,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -179,32 +179,32 @@ func (s *Service) CreateFile(
|
||||
|
||||
now := time.Now()
|
||||
|
||||
trustCenterFileID := gid.New(scope.GetTenantID(), coredata.TrustCenterFileEntityType)
|
||||
compliancePortalFileID := gid.New(scope.GetTenantID(), coredata.CompliancePortalFileEntityType)
|
||||
|
||||
var (
|
||||
file *coredata.TrustCenterFile
|
||||
file *coredata.CompliancePortalFile
|
||||
s3Key string
|
||||
)
|
||||
|
||||
err = s.pg.WithTx(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot upload file: %w", err)
|
||||
}
|
||||
|
||||
s3Key = objectKey
|
||||
|
||||
file = &coredata.TrustCenterFile{
|
||||
ID: trustCenterFileID,
|
||||
OrganizationID: req.OrganizationID,
|
||||
Name: req.Name,
|
||||
Category: req.Category,
|
||||
FileID: fileID,
|
||||
TrustCenterVisibility: req.TrustCenterVisibility,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
file = &coredata.CompliancePortalFile{
|
||||
ID: compliancePortalFileID,
|
||||
OrganizationID: req.OrganizationID,
|
||||
Name: req.Name,
|
||||
Category: req.Category,
|
||||
FileID: fileID,
|
||||
CompliancePortalVisibility: req.CompliancePortalVisibility,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := file.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -226,19 +226,19 @@ func (s *Service) UpdateFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateFileRequest,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var file *coredata.TrustCenterFile
|
||||
var file *coredata.CompliancePortalFile
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
@@ -252,8 +252,8 @@ func (s *Service) UpdateFile(
|
||||
file.Category = *req.Category
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
file.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
if req.CompliancePortalVisibility != nil {
|
||||
file.CompliancePortalVisibility = *req.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
file.UpdatedAt = now
|
||||
@@ -275,14 +275,14 @@ func (s *Service) UpdateFile(
|
||||
func (s *Service) DeleteFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s *Service) DeleteFile(
|
||||
func (s *Service) GenerateFileURL(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
duration time.Duration,
|
||||
) (string, error) {
|
||||
var storedFile *coredata.File
|
||||
@@ -307,8 +307,8 @@ func (s *Service) GenerateFileURL(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
file := &coredata.TrustCenterFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, trustCenterFileID); err != nil {
|
||||
file := &coredata.CompliancePortalFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, compliancePortalFileID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func (s *Service) uploadFile(
|
||||
scope coredata.Scoper,
|
||||
tx pg.Tx,
|
||||
file File,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
organizationID gid.GID,
|
||||
now time.Time,
|
||||
) (gid.GID, string, error) {
|
||||
@@ -404,7 +404,7 @@ func (s *Service) uploadFile(
|
||||
CacheControl: new("private, max-age=3600"),
|
||||
Metadata: map[string]string{
|
||||
"type": "compliance-page-file",
|
||||
"compliance-page-file-id": trustCenterFileID.String(),
|
||||
"compliance-page-file-id": compliancePortalFileID.String(),
|
||||
"organization-id": organizationID.String(),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -34,8 +34,8 @@ import (
|
||||
|
||||
type (
|
||||
CreateFrameworkRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
FrameworkID gid.GID
|
||||
CompliancePortalID gid.GID
|
||||
FrameworkID gid.GID
|
||||
}
|
||||
|
||||
UpdateFrameworkRequest struct {
|
||||
@@ -51,7 +51,7 @@ type (
|
||||
func (r *CreateFrameworkRequest) Validate() error {
|
||||
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))
|
||||
|
||||
return v.Error()
|
||||
@@ -84,7 +84,7 @@ func (s *Service) ListFrameworksWithHidden(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ func (s *Service) CreateFramework(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
@@ -127,12 +127,12 @@ func (s *Service) CreateFramework(
|
||||
}
|
||||
|
||||
cf = &coredata.ComplianceFramework{
|
||||
ID: cfID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: cfID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := cf.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -54,15 +54,15 @@ type (
|
||||
}
|
||||
|
||||
UploadNDARequest struct {
|
||||
TrustCenterID gid.GID
|
||||
File io.Reader
|
||||
FileName string
|
||||
CompliancePortalID gid.GID
|
||||
File io.Reader
|
||||
FileName string
|
||||
}
|
||||
|
||||
UpdateBrandRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
LogoFile **FileUpload
|
||||
DarkLogoFile **FileUpload
|
||||
CompliancePortalID gid.GID
|
||||
LogoFile **FileUpload
|
||||
DarkLogoFile **FileUpload
|
||||
}
|
||||
)
|
||||
|
||||
@@ -71,7 +71,7 @@ const maxBrandFileSize = 5 * 1024 * 1024 // 5MB
|
||||
func (utcr *UpdateRequest) Validate() error {
|
||||
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.NonDisclosureAgreementFileID, "non_disclosure_agreement_file_id", validator.GID(coredata.FileEntityType))
|
||||
|
||||
@@ -101,7 +101,7 @@ func (utcr *UpdateRequest) Validate() error {
|
||||
func (utcndar *UploadNDARequest) Validate() error {
|
||||
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))
|
||||
|
||||
return v.Error()
|
||||
@@ -134,13 +134,13 @@ func (s *Service) Get(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
) (*coredata.TrustCenter, error) {
|
||||
var compliancePage *coredata.TrustCenter
|
||||
) (*coredata.CompliancePortal, error) {
|
||||
var compliancePage *coredata.CompliancePortal
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -159,13 +159,13 @@ func (s *Service) GetByOrganizationID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
) (*coredata.TrustCenter, error) {
|
||||
var compliancePage *coredata.TrustCenter
|
||||
) (*coredata.CompliancePortal, error) {
|
||||
var compliancePage *coredata.CompliancePortal
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByOrganizationID(ctx, conn, scope, organizationID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -184,20 +184,20 @@ func (s *Service) Update(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateRequest,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
compliancePage *coredata.TrustCenter
|
||||
compliancePage *coredata.CompliancePortal
|
||||
file *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -267,26 +267,26 @@ func (s *Service) UploadNDA(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UploadNDARequest,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
compliancePage *coredata.TrustCenter
|
||||
compliancePage *coredata.CompliancePortal
|
||||
file *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -320,7 +320,7 @@ func (s *Service) UploadNDA(
|
||||
req.File,
|
||||
map[string]string{
|
||||
"type": "compliance-page-nda",
|
||||
"compliance-page-id": req.TrustCenterID.String(),
|
||||
"compliance-page-id": req.CompliancePortalID.String(),
|
||||
"organization-id": compliancePage.OrganizationID.String(),
|
||||
},
|
||||
)
|
||||
@@ -355,13 +355,13 @@ func (s *Service) DeleteNDA(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
var compliancePage *coredata.TrustCenter
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
var compliancePage *coredata.CompliancePortal
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -387,21 +387,21 @@ func (s *Service) UpdateBrand(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateBrandRequest,
|
||||
) (*coredata.TrustCenter, *coredata.File, error) {
|
||||
) (*coredata.CompliancePortal, *coredata.File, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
compliancePage *coredata.TrustCenter
|
||||
compliancePage *coredata.CompliancePortal
|
||||
ndaFile *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Tx) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ func (s *Service) uploadBrandFile(
|
||||
conn pg.Tx,
|
||||
fileUpload *FileUpload,
|
||||
fileType string,
|
||||
compliancePage *coredata.TrustCenter,
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
) (*coredata.File, error) {
|
||||
objectKey, err := uuid.NewV7()
|
||||
if err != nil {
|
||||
@@ -529,7 +529,7 @@ func (s *Service) GenerateNDAFileURL(
|
||||
) (*string, error) {
|
||||
var file *coredata.File
|
||||
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -573,7 +573,7 @@ func (s *Service) GenerateLogoURL(
|
||||
expiresIn time.Duration,
|
||||
) (*string, error) {
|
||||
file := &coredata.File{}
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -620,7 +620,7 @@ func (s *Service) GenerateDarkLogoURL(
|
||||
expiresIn time.Duration,
|
||||
) (*string, error) {
|
||||
file := &coredata.File{}
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -666,7 +666,7 @@ func (s *Service) EmailPresenterConfig(
|
||||
compliancePageID gid.GID,
|
||||
) (emails.PresenterConfig, error) {
|
||||
var (
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
organization = &coredata.Organization{}
|
||||
logoFile = &coredata.File{}
|
||||
compliancePageURL string
|
||||
@@ -690,7 +690,7 @@ func (s *Service) EmailPresenterConfig(
|
||||
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 {
|
||||
return fmt.Errorf("cannot resolve compliance page URL: %w", err)
|
||||
}
|
||||
@@ -736,7 +736,7 @@ func (s *Service) GetMailingList(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ import (
|
||||
|
||||
type (
|
||||
CreateReferenceRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
Name string
|
||||
Description *string
|
||||
WebsiteURL string
|
||||
LogoFile File
|
||||
CompliancePortalID gid.GID
|
||||
Name string
|
||||
Description *string
|
||||
WebsiteURL string
|
||||
LogoFile File
|
||||
}
|
||||
|
||||
UpdateReferenceRequest struct {
|
||||
@@ -60,7 +60,7 @@ type (
|
||||
func (ctcrr *CreateReferenceRequest) Validate() error {
|
||||
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.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
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 {
|
||||
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.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(utcrr.WebsiteURL, "website_url", validator.SafeText(2048))
|
||||
@@ -83,14 +83,14 @@ func (s *Service) ListReferences(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterReferenceOrderField],
|
||||
) (*page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField], error) {
|
||||
var references coredata.TrustCenterReferences
|
||||
cursor *page.Cursor[coredata.CompliancePortalReferenceOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalReference, coredata.CompliancePortalReferenceOrderField], error) {
|
||||
var references coredata.CompliancePortalReferences
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page references: %w", err)
|
||||
}
|
||||
@@ -115,9 +115,9 @@ func (s *Service) CountReferences(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot count compliance page references: %w", err)
|
||||
}
|
||||
@@ -136,8 +136,8 @@ func (s *Service) GetReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
referenceID gid.GID,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
var reference coredata.TrustCenterReference
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
var reference coredata.CompliancePortalReference
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -161,44 +161,44 @@ func (s *Service) CreateReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *CreateReferenceRequest,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
|
||||
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 {
|
||||
return fmt.Errorf("cannot upload logo file: %w", err)
|
||||
}
|
||||
|
||||
logoKey = s3Key
|
||||
|
||||
reference = &coredata.TrustCenterReference{
|
||||
ID: referenceID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TrustCenterID: req.TrustCenterID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
WebsiteURL: req.WebsiteURL,
|
||||
LogoFileID: fileID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
reference = &coredata.CompliancePortalReference{
|
||||
ID: referenceID,
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
CompliancePortalID: req.CompliancePortalID,
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
WebsiteURL: req.WebsiteURL,
|
||||
LogoFileID: fileID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := reference.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -220,7 +220,7 @@ func (s *Service) UpdateReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *UpdateReferenceRequest,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func (s *Service) UpdateReference(
|
||||
now := time.Now()
|
||||
|
||||
var (
|
||||
reference *coredata.TrustCenterReference
|
||||
reference *coredata.CompliancePortalReference
|
||||
newFileID *gid.GID
|
||||
logoKey string
|
||||
)
|
||||
@@ -236,14 +236,14 @@ func (s *Service) UpdateReference(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page reference: %w", err)
|
||||
}
|
||||
|
||||
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 {
|
||||
return fmt.Errorf("cannot upload logo file: %w", err)
|
||||
}
|
||||
@@ -295,14 +295,14 @@ func (s *Service) UpdateReference(
|
||||
func (s *Service) DeleteReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterReferenceID gid.GID,
|
||||
compliancePortalReferenceID gid.GID,
|
||||
) error {
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ func (s *Service) GenerateReferenceLogoURL(
|
||||
scope coredata.Scoper,
|
||||
referenceID gid.GID,
|
||||
) (string, error) {
|
||||
reference := &coredata.TrustCenterReference{}
|
||||
reference := &coredata.CompliancePortalReference{}
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
@@ -358,7 +358,7 @@ func (s *Service) uploadReferenceLogoFile(
|
||||
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 {
|
||||
return gid.GID{}, "", fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (s *Service) ListAuditsForOrganizationID(
|
||||
var audits coredata.Audits
|
||||
|
||||
if filter == nil {
|
||||
filter = coredata.NewAuditTrustCenterFilter()
|
||||
filter = coredata.NewAuditCompliancePortalFilter()
|
||||
}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
|
||||
@@ -65,7 +65,7 @@ func PortalBaseURLFromCIMDClientID(clientIDURL string) (string, error) {
|
||||
}
|
||||
|
||||
func BuildClientMetadataDocument(
|
||||
portal *coredata.TrustCenter,
|
||||
portal *coredata.CompliancePortal,
|
||||
portalBaseURL string,
|
||||
) (oauth2.ClientMetadataDocument, error) {
|
||||
clientID, err := CIMDClientIDURL(portalBaseURL)
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestBuildClientMetadataDocument(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
websiteURL := "https://www.acme.com"
|
||||
portal := &coredata.TrustCenter{
|
||||
portal := &coredata.CompliancePortal{
|
||||
Title: "Acme Compliance Page",
|
||||
WebsiteURL: &websiteURL,
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func TestBuildClientMetadataDocument_LogoURIUsesBrandLogoEndpoint(t *testing.T)
|
||||
t.Parallel()
|
||||
|
||||
logoFileID := gid.MustParseGID("WR-qMrB5AAEAGQAAAZ9mIO8B8vDFQ-i3")
|
||||
portal := &coredata.TrustCenter{
|
||||
portal := &coredata.CompliancePortal{
|
||||
Title: "Acme Compliance Page",
|
||||
LogoFileID: &logoFileID,
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s *Service) ListComplianceFrameworksByPortalID(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance frameworks: %w", err)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
func (s *Service) ListCommitmentGroupsForPortalID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
cursor *page.Cursor[coredata.CompliancePortalCommitmentGroupOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalCommitmentGroup, coredata.CompliancePortalCommitmentGroupOrderField], error) {
|
||||
var groups coredata.CompliancePortalCommitmentGroups
|
||||
@@ -41,7 +41,7 @@ func (s *Service) ListCommitmentGroupsForPortalID(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance portal commitment groups: %w", err)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (s *Service) RenderCompliancePageMarkdown(
|
||||
func (s *Service) RenderCompliancePortalMarkdown(
|
||||
ctx context.Context,
|
||||
w io.Writer,
|
||||
compliancePageID gid.GID,
|
||||
@@ -286,7 +286,7 @@ func (s *Service) fetchDocumentIDs(
|
||||
}
|
||||
|
||||
for _, doc := range result.Data {
|
||||
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -308,8 +308,8 @@ func (s *Service) fetchDocumentIDs(
|
||||
page.MaxCursorSize,
|
||||
cursorKey,
|
||||
page.Head,
|
||||
page.OrderBy[coredata.TrustCenterFileOrderField]{
|
||||
Field: coredata.TrustCenterFileOrderFieldCreatedAt,
|
||||
page.OrderBy[coredata.CompliancePortalFileOrderField]{
|
||||
Field: coredata.CompliancePortalFileOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
},
|
||||
)
|
||||
@@ -319,14 +319,14 @@ func (s *Service) fetchDocumentIDs(
|
||||
scope,
|
||||
orgID,
|
||||
cursor,
|
||||
coredata.NewTrustCenterFileFilter(),
|
||||
coredata.NewCompliancePortalFileFilter(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot list compliance page files: %w", err)
|
||||
}
|
||||
|
||||
for _, file := range result.Data {
|
||||
if file.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if file.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ func (s *Service) fetchDocumentIDs(
|
||||
}
|
||||
|
||||
last := result.Data[len(result.Data)-1]
|
||||
ck := last.CursorKey(coredata.TrustCenterFileOrderFieldCreatedAt)
|
||||
ck := last.CursorKey(coredata.CompliancePortalFileOrderFieldCreatedAt)
|
||||
cursorKey = &ck
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ func (s *Service) fetchDocumentIDs(
|
||||
}
|
||||
|
||||
for _, audit := range result.Data {
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if audit.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ func (s *Service) fetchDocuments(
|
||||
}
|
||||
|
||||
for _, doc := range result.Data {
|
||||
if doc.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if doc.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ func (s *Service) fetchAudits(
|
||||
}
|
||||
|
||||
for _, audit := range result.Data {
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if audit.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -631,8 +631,8 @@ func (s *Service) fetchReferences(
|
||||
page.MaxCursorSize,
|
||||
cursorKey,
|
||||
page.Head,
|
||||
page.OrderBy[coredata.TrustCenterReferenceOrderField]{
|
||||
Field: coredata.TrustCenterReferenceOrderFieldRank,
|
||||
page.OrderBy[coredata.CompliancePortalReferenceOrderField]{
|
||||
Field: coredata.CompliancePortalReferenceOrderFieldRank,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
},
|
||||
)
|
||||
@@ -659,7 +659,7 @@ func (s *Service) fetchReferences(
|
||||
}
|
||||
|
||||
last := result.Data[len(result.Data)-1]
|
||||
ck := last.CursorKey(coredata.TrustCenterReferenceOrderFieldRank)
|
||||
ck := last.CursorKey(coredata.CompliancePortalReferenceOrderFieldRank)
|
||||
cursorKey = &ck
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (s *Service) ListCustomLinksForPortalID(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load custom links: %w", err)
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s *Service) ListDocumentsForOrganizationID(
|
||||
var documents coredata.Documents
|
||||
|
||||
if filter == nil {
|
||||
filter = coredata.NewDocumentTrustCenterFilter()
|
||||
filter = coredata.NewDocumentCompliancePortalFilter()
|
||||
}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
@@ -131,7 +131,7 @@ func (s *Service) GetDocument(
|
||||
return nil, ErrDocumentNotFound
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if document.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
return nil, ErrDocumentNotVisible
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ func (s *Service) exportDocumentPDFData(
|
||||
return &ErrDocumentArchived{}
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if document.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
return fmt.Errorf("document not visible on compliance page")
|
||||
}
|
||||
|
||||
|
||||
@@ -36,37 +36,37 @@ import (
|
||||
)
|
||||
|
||||
type PortalAccessRequest struct {
|
||||
TrustCenterID gid.GID
|
||||
IdentityID gid.GID
|
||||
DocumentIDs []gid.GID
|
||||
ReportIDs []gid.GID
|
||||
TrustCenterFileIDs []gid.GID
|
||||
CompliancePortalID gid.GID
|
||||
IdentityID gid.GID
|
||||
DocumentIDs []gid.GID
|
||||
ReportIDs []gid.GID
|
||||
CompliancePortalFileIDs []gid.GID
|
||||
}
|
||||
|
||||
const (
|
||||
PortalAccessURLFormat = "https://%s/organizations/%s/trust-center/access"
|
||||
PortalAccessURLFormat = "https://%s/organizations/%s/compliance-page/access"
|
||||
)
|
||||
|
||||
func (s *Service) RequestPortalAccess(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
req *PortalAccessRequest,
|
||||
) (*coredata.TrustCenterAccess, error) {
|
||||
) (*coredata.CompliancePortalAccess, error) {
|
||||
var (
|
||||
now = time.Now()
|
||||
access *coredata.TrustCenterAccess
|
||||
access *coredata.CompliancePortalAccess
|
||||
)
|
||||
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.TrustCenterID); err != nil {
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, req.CompliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
|
||||
access = &coredata.TrustCenterAccess{}
|
||||
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, req.TrustCenterID, req.IdentityID); err != nil {
|
||||
access = &coredata.CompliancePortalAccess{}
|
||||
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, req.CompliancePortalID, req.IdentityID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page membership: %w", err)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (s *Service) RequestPortalAccess(
|
||||
|
||||
documentIDs := req.DocumentIDs
|
||||
if req.DocumentIDs == nil {
|
||||
filter := coredata.NewDocumentTrustCenterFilter()
|
||||
filter := coredata.NewDocumentCompliancePortalFilter()
|
||||
|
||||
allDocuments, err := page.LoadAll(
|
||||
ctx,
|
||||
@@ -102,7 +102,7 @@ func (s *Service) RequestPortalAccess(
|
||||
|
||||
reportIDs := req.ReportIDs
|
||||
if req.ReportIDs == nil {
|
||||
auditFilter := coredata.NewAuditTrustCenterFilter()
|
||||
auditFilter := coredata.NewAuditCompliancePortalFilter()
|
||||
|
||||
allAudits, err := page.LoadAll(
|
||||
ctx,
|
||||
@@ -130,20 +130,20 @@ func (s *Service) RequestPortalAccess(
|
||||
}
|
||||
}
|
||||
|
||||
trustCenterFileIDs := req.TrustCenterFileIDs
|
||||
if req.TrustCenterFileIDs == nil {
|
||||
filter := coredata.NewTrustCenterFileFilter(
|
||||
coredata.WithTrustCenterFileVisibilities(coredata.TrustCenterVisibilityPrivate, coredata.TrustCenterVisibilityNone),
|
||||
compliancePortalFileIDs := req.CompliancePortalFileIDs
|
||||
if req.CompliancePortalFileIDs == nil {
|
||||
filter := coredata.NewCompliancePortalFileFilter(
|
||||
coredata.WithCompliancePortalFileVisibilities(coredata.CompliancePortalVisibilityPrivate, coredata.CompliancePortalVisibilityNone),
|
||||
)
|
||||
|
||||
allTrustCenterFiles, err := page.LoadAll(
|
||||
allCompliancePortalFiles, err := page.LoadAll(
|
||||
ctx,
|
||||
page.OrderBy[coredata.TrustCenterFileOrderField]{
|
||||
Field: coredata.TrustCenterFileOrderFieldCreatedAt,
|
||||
page.OrderBy[coredata.CompliancePortalFileOrderField]{
|
||||
Field: coredata.CompliancePortalFileOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
},
|
||||
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterFileOrderField]) ([]*coredata.TrustCenterFile, error) {
|
||||
var batch coredata.TrustCenterFiles
|
||||
func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalFileOrderField]) ([]*coredata.CompliancePortalFile, error) {
|
||||
var batch coredata.CompliancePortalFiles
|
||||
if err := batch.LoadByOrganizationID(ctx, tx, scope, organizationID, cursor, filter); err != nil {
|
||||
return nil, fmt.Errorf("cannot list compliance page files: %w", err)
|
||||
}
|
||||
@@ -155,20 +155,20 @@ func (s *Service) RequestPortalAccess(
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range allTrustCenterFiles {
|
||||
trustCenterFileIDs = append(trustCenterFileIDs, file.ID)
|
||||
for _, file := range allCompliancePortalFiles {
|
||||
compliancePortalFileIDs = append(compliancePortalFileIDs, file.ID)
|
||||
}
|
||||
}
|
||||
|
||||
existingAccesses, err := page.LoadAll(
|
||||
ctx,
|
||||
page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{
|
||||
Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt,
|
||||
page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
|
||||
Field: coredata.CompliancePortalDocumentAccessOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
},
|
||||
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField]) ([]*coredata.TrustCenterDocumentAccess, error) {
|
||||
var batch coredata.TrustCenterDocumentAccesses
|
||||
if err := batch.LoadByTrustCenterAccessID(ctx, tx, scope, access.ID, cursor); err != nil {
|
||||
func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField]) ([]*coredata.CompliancePortalDocumentAccess, error) {
|
||||
var batch coredata.CompliancePortalDocumentAccesses
|
||||
if err := batch.LoadByCompliancePortalAccessID(ctx, tx, scope, access.ID, cursor); err != nil {
|
||||
return nil, fmt.Errorf("cannot load existing access records: %w", err)
|
||||
}
|
||||
|
||||
@@ -179,12 +179,12 @@ func (s *Service) RequestPortalAccess(
|
||||
return err
|
||||
}
|
||||
|
||||
existingDocumentIDs, existingReportIDs, existingTrustCenterFileIDs := extractExistingIDs(existingAccesses)
|
||||
existingDocumentIDs, existingReportIDs, existingCompliancePortalFileIDs := extractExistingIDs(existingAccesses)
|
||||
newDocumentIDs := filterExistingIDs(documentIDs, existingDocumentIDs)
|
||||
newReportIDs := filterExistingIDs(reportIDs, existingReportIDs)
|
||||
newTrustCenterFileIDs := filterExistingIDs(trustCenterFileIDs, existingTrustCenterFileIDs)
|
||||
newCompliancePortalFileIDs := filterExistingIDs(compliancePortalFileIDs, existingCompliancePortalFileIDs)
|
||||
|
||||
var accesses coredata.TrustCenterDocumentAccesses
|
||||
var accesses coredata.CompliancePortalDocumentAccesses
|
||||
|
||||
if err := accesses.BulkInsertDocumentAccesses(
|
||||
ctx,
|
||||
@@ -193,7 +193,7 @@ func (s *Service) RequestPortalAccess(
|
||||
access.ID,
|
||||
access.OrganizationID,
|
||||
newDocumentIDs,
|
||||
coredata.TrustCenterDocumentAccessStatusRequested,
|
||||
coredata.CompliancePortalDocumentAccessStatusRequested,
|
||||
now,
|
||||
); err != nil {
|
||||
return fmt.Errorf("cannot bulk insert compliance page document accesses: %w", err)
|
||||
@@ -206,20 +206,20 @@ func (s *Service) RequestPortalAccess(
|
||||
access.ID,
|
||||
access.OrganizationID,
|
||||
newReportIDs,
|
||||
coredata.TrustCenterDocumentAccessStatusRequested,
|
||||
coredata.CompliancePortalDocumentAccessStatusRequested,
|
||||
now,
|
||||
); err != nil {
|
||||
return fmt.Errorf("cannot bulk insert compliance page report accesses: %w", err)
|
||||
}
|
||||
|
||||
if err := accesses.BulkInsertTrustCenterFileAccesses(
|
||||
if err := accesses.BulkInsertCompliancePortalFileAccesses(
|
||||
ctx,
|
||||
tx,
|
||||
scope,
|
||||
access.ID,
|
||||
access.OrganizationID,
|
||||
newTrustCenterFileIDs,
|
||||
coredata.TrustCenterDocumentAccessStatusRequested,
|
||||
newCompliancePortalFileIDs,
|
||||
coredata.CompliancePortalDocumentAccessStatusRequested,
|
||||
now,
|
||||
); err != nil {
|
||||
return fmt.Errorf("cannot bulk insert compliance page file accesses: %w", err)
|
||||
@@ -232,7 +232,7 @@ func (s *Service) RequestPortalAccess(
|
||||
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))
|
||||
}
|
||||
|
||||
@@ -244,13 +244,13 @@ func (s *Service) GetPortalAccess(
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
identityID gid.GID,
|
||||
) (coredata.TrustCenterAccess, error) {
|
||||
var access coredata.TrustCenterAccess
|
||||
) (coredata.CompliancePortalAccess, error) {
|
||||
var access coredata.CompliancePortalAccess
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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,
|
||||
identityID gid.GID,
|
||||
documentID gid.GID,
|
||||
) (*coredata.TrustCenterDocumentAccess, error) {
|
||||
var documentAccess *coredata.TrustCenterDocumentAccess
|
||||
) (*coredata.CompliancePortalDocumentAccess, error) {
|
||||
var documentAccess *coredata.CompliancePortalDocumentAccess
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrMembershipNotFound
|
||||
@@ -291,9 +291,9 @@ func (s *Service) GetPortalDocumentAccess(
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrDocumentAccessNotFound
|
||||
@@ -318,15 +318,15 @@ func (s *Service) GetPortalReportFileAccess(
|
||||
compliancePageID gid.GID,
|
||||
identityID gid.GID,
|
||||
reportFileID gid.GID,
|
||||
) (*coredata.TrustCenterDocumentAccess, error) {
|
||||
var reportAccess *coredata.TrustCenterDocumentAccess
|
||||
) (*coredata.CompliancePortalDocumentAccess, error) {
|
||||
var reportAccess *coredata.CompliancePortalDocumentAccess
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrMembershipNotFound
|
||||
@@ -346,9 +346,9 @@ func (s *Service) GetPortalReportFileAccess(
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrDocumentAccessNotFound
|
||||
@@ -372,16 +372,16 @@ func (s *Service) GetPortalFileAccess(
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
identityID gid.GID,
|
||||
trustCenterFileID gid.GID,
|
||||
) (*coredata.TrustCenterDocumentAccess, error) {
|
||||
var fileAccess *coredata.TrustCenterDocumentAccess
|
||||
compliancePortalFileID gid.GID,
|
||||
) (*coredata.CompliancePortalDocumentAccess, error) {
|
||||
var fileAccess *coredata.CompliancePortalDocumentAccess
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrMembershipNotFound
|
||||
@@ -401,9 +401,9 @@ func (s *Service) GetPortalFileAccess(
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return ErrDocumentAccessNotFound
|
||||
@@ -434,7 +434,7 @@ func (s *Service) GrantPortalAccessByIDs(
|
||||
return s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
access := &coredata.TrustCenterAccess{}
|
||||
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
|
||||
access := &coredata.CompliancePortalAccess{}
|
||||
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page access: %w", err)
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ func (s *Service) GrantPortalAccessByIDs(
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -503,7 +503,7 @@ func (s *Service) sendPortalAccessEmail(
|
||||
ctx context.Context,
|
||||
tx pg.Tx,
|
||||
scope coredata.Scoper,
|
||||
access *coredata.TrustCenterAccess,
|
||||
access *coredata.CompliancePortalAccess,
|
||||
profile *coredata.MembershipProfile,
|
||||
) error {
|
||||
organization := &coredata.Organization{}
|
||||
@@ -518,14 +518,14 @@ func (s *Service) sendPortalAccessEmail(
|
||||
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 {
|
||||
return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
|
||||
}
|
||||
|
||||
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 {
|
||||
return fmt.Errorf("cannot render compliance page access email: %w", err)
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
|
||||
return s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByOrganizationID(ctx, tx, scope, organizationID); err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
access := &coredata.TrustCenterAccess{}
|
||||
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
|
||||
access := &coredata.CompliancePortalAccess{}
|
||||
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePage.ID, identity.ID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page access: %w", err)
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ func (s *Service) RejectOrRevokePortalAccessByIDs(
|
||||
if len(fileIDs) > 0 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -622,7 +622,7 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
|
||||
ctx context.Context,
|
||||
tx pg.Tx,
|
||||
scope coredata.Scoper,
|
||||
access *coredata.TrustCenterAccess,
|
||||
access *coredata.CompliancePortalAccess,
|
||||
profile *coredata.MembershipProfile,
|
||||
documentIDs []gid.GID,
|
||||
reportIDs []gid.GID,
|
||||
@@ -657,7 +657,7 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
|
||||
fileNames = append(fileNames, reportLabels...)
|
||||
}
|
||||
|
||||
var files coredata.TrustCenterFiles
|
||||
var files coredata.CompliancePortalFiles
|
||||
if len(fileIDs) > 0 {
|
||||
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)
|
||||
@@ -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 {
|
||||
return fmt.Errorf("cannot get compliance page email presenter config: %w", err)
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, profile.FullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterDocumentAccessRejected(
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderCompliancePortalDocumentAccessRejected(
|
||||
ctx,
|
||||
fileNames,
|
||||
organization.Name,
|
||||
@@ -702,11 +702,11 @@ func (s *Service) sendPortalDocumentAccessRejectedEmail(
|
||||
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 (
|
||||
documentIDs []gid.GID
|
||||
reportIDs []gid.GID
|
||||
trustCenterFileIDs []gid.GID
|
||||
documentIDs []gid.GID
|
||||
reportIDs []gid.GID
|
||||
compliancePortalFileIDs []gid.GID
|
||||
)
|
||||
|
||||
for _, access := range accesses {
|
||||
@@ -718,12 +718,12 @@ func extractExistingIDs(accesses coredata.TrustCenterDocumentAccesses) ([]gid.GI
|
||||
reportIDs = append(reportIDs, *access.ReportFileID)
|
||||
}
|
||||
|
||||
if access.TrustCenterFileID != nil {
|
||||
trustCenterFileIDs = append(trustCenterFileIDs, *access.TrustCenterFileID)
|
||||
if access.CompliancePortalFileID != nil {
|
||||
compliancePortalFileIDs = append(compliancePortalFileIDs, *access.CompliancePortalFileID)
|
||||
}
|
||||
}
|
||||
|
||||
return documentIDs, reportIDs, trustCenterFileIDs
|
||||
return documentIDs, reportIDs, compliancePortalFileIDs
|
||||
}
|
||||
|
||||
func filterExistingIDs(allIDs []gid.GID, existingIDs []gid.GID) []gid.GID {
|
||||
|
||||
@@ -38,14 +38,14 @@ func (s *Service) GetPortalFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
trustCenterFileID gid.GID,
|
||||
) (*coredata.TrustCenterFile, error) {
|
||||
trustCenterFile := &coredata.TrustCenterFile{}
|
||||
compliancePortalFileID gid.GID,
|
||||
) (*coredata.CompliancePortalFile, error) {
|
||||
compliancePortalFile := &coredata.CompliancePortalFile{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
@@ -57,30 +57,30 @@ func (s *Service) GetPortalFile(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if trustCenterFile.OrganizationID != organizationID {
|
||||
if compliancePortalFile.OrganizationID != organizationID {
|
||||
return nil, ErrPortalFileNotFound
|
||||
}
|
||||
|
||||
if trustCenterFile.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
if compliancePortalFile.CompliancePortalVisibility == coredata.CompliancePortalVisibilityNone {
|
||||
return nil, ErrPortalFileNotVisible
|
||||
}
|
||||
|
||||
return trustCenterFile, nil
|
||||
return compliancePortalFile, nil
|
||||
}
|
||||
|
||||
func (s *Service) ListPortalFilesForOrganizationID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterFileOrderField],
|
||||
filter *coredata.TrustCenterFileFilter,
|
||||
) (*page.Page[*coredata.TrustCenterFile, coredata.TrustCenterFileOrderField], error) {
|
||||
var trustCenterFiles coredata.TrustCenterFiles
|
||||
cursor *page.Cursor[coredata.CompliancePortalFileOrderField],
|
||||
filter *coredata.CompliancePortalFileFilter,
|
||||
) (*page.Page[*coredata.CompliancePortalFile, coredata.CompliancePortalFileOrderField], error) {
|
||||
var compliancePortalFiles coredata.CompliancePortalFiles
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page files: %w", err)
|
||||
}
|
||||
@@ -92,16 +92,16 @@ func (s *Service) ListPortalFilesForOrganizationID(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return page.NewPage(trustCenterFiles, cursor), nil
|
||||
return page.NewPage(compliancePortalFiles, cursor), nil
|
||||
}
|
||||
|
||||
func (s *Service) ExportPortalFile(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
email mail.Addr,
|
||||
) ([]byte, string, error) {
|
||||
fileData, mimeType, err := s.exportPortalFileData(ctx, scope, trustCenterFileID)
|
||||
fileData, mimeType, err := s.exportPortalFileData(ctx, scope, compliancePortalFileID)
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("cannot export compliance page file: %w", err)
|
||||
}
|
||||
@@ -121,31 +121,31 @@ func (s *Service) ExportPortalFile(
|
||||
func (s *Service) ExportPortalFileWithoutWatermark(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
) ([]byte, string, error) {
|
||||
return s.exportPortalFileData(ctx, scope, trustCenterFileID)
|
||||
return s.exportPortalFileData(ctx, scope, compliancePortalFileID)
|
||||
}
|
||||
|
||||
func (s *Service) exportPortalFileData(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
trustCenterFileID gid.GID,
|
||||
compliancePortalFileID gid.GID,
|
||||
) ([]byte, string, error) {
|
||||
var (
|
||||
trustCenterFile *coredata.TrustCenterFile
|
||||
file *coredata.File
|
||||
compliancePortalFile *coredata.CompliancePortalFile
|
||||
file *coredata.File
|
||||
)
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
trustCenterFile = &coredata.TrustCenterFile{}
|
||||
if err := trustCenterFile.LoadByID(ctx, conn, scope, trustCenterFileID); err != nil {
|
||||
compliancePortalFile = &coredata.CompliancePortalFile{}
|
||||
if err := compliancePortalFile.LoadByID(ctx, conn, scope, compliancePortalFileID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page file: %w", err)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,16 +34,16 @@ func (s *Service) ListPortalReferencesForPortalID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
cursor *page.Cursor[coredata.TrustCenterReferenceOrderField],
|
||||
) (*page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField], error) {
|
||||
var references coredata.TrustCenterReferences
|
||||
cursor *page.Cursor[coredata.CompliancePortalReferenceOrderField],
|
||||
) (*page.Page[*coredata.CompliancePortalReference, coredata.CompliancePortalReferenceOrderField], error) {
|
||||
var references coredata.CompliancePortalReferences
|
||||
|
||||
err := s.pg.WithConn(
|
||||
|
||||
ctx,
|
||||
|
||||
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 {
|
||||
return fmt.Errorf("cannot load compliance page references: %w", err)
|
||||
}
|
||||
@@ -62,8 +62,8 @@ func (s *Service) GetPortalReference(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
referenceID gid.GID,
|
||||
) (*coredata.TrustCenterReference, error) {
|
||||
reference := &coredata.TrustCenterReference{}
|
||||
) (*coredata.CompliancePortalReference, error) {
|
||||
reference := &coredata.CompliancePortalReference{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
|
||||
@@ -36,13 +36,13 @@ func (s *Service) GetPortal(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
compliancePageID gid.GID,
|
||||
) (*coredata.TrustCenter, error) {
|
||||
var compliancePage *coredata.TrustCenter
|
||||
) (*coredata.CompliancePortal, error) {
|
||||
var compliancePage *coredata.CompliancePortal
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (s *Service) GetPortalNDAFile(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func (s *Service) GeneratePortalNDAFileURL(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance page: %w", err)
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (s *Service) GetPortalEmailPresenterConfig(
|
||||
compliancePageID gid.GID,
|
||||
) (emails.PresenterConfig, error) {
|
||||
var (
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
organization = &coredata.Organization{}
|
||||
logoFile = &coredata.File{}
|
||||
compliancePageURL string
|
||||
@@ -161,7 +161,7 @@ func (s *Service) GetPortalEmailPresenterConfig(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
publicURL, err := s.management.PublicURLForCompliancePage(
|
||||
publicURL, err := s.management.PublicURLForCompliancePortal(
|
||||
ctx,
|
||||
conn,
|
||||
scope,
|
||||
|
||||
@@ -95,8 +95,8 @@ func NewService(
|
||||
func (s *Service) GetPortalByID(
|
||||
ctx context.Context,
|
||||
id gid.GID,
|
||||
) (*coredata.TrustCenter, error) {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
) (*coredata.CompliancePortal, error) {
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -130,12 +130,12 @@ func (s *Service) GetPortalEffectiveCanonicalHost(ctx context.Context, complianc
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
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 {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@@ -186,8 +186,8 @@ func (s *Service) GetPortalCanonicalBaseURL(
|
||||
return parsed.String(), nil
|
||||
}
|
||||
|
||||
func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*coredata.TrustCenter, error) {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*coredata.CompliancePortal, error) {
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
@@ -201,7 +201,7 @@ func (s *Service) GetPortalByDomainName(ctx context.Context, domain string) (*co
|
||||
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 errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
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
|
||||
// esign certificate worker which needs per-org branding at render time.
|
||||
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)
|
||||
|
||||
@@ -265,13 +265,13 @@ func (s *Service) GetPortalOrganization(
|
||||
return org, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.GID, identityID gid.GID) (*coredata.TrustCenterAccess, error) {
|
||||
membership := &coredata.TrustCenterAccess{}
|
||||
func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid.GID, identityID gid.GID) (*coredata.CompliancePortalAccess, error) {
|
||||
membership := &coredata.CompliancePortalAccess{}
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
return membership.LoadByTrustCenterIDAndIdentityID(
|
||||
return membership.LoadByCompliancePortalIDAndIdentityID(
|
||||
ctx,
|
||||
conn,
|
||||
coredata.NewScopeFromObjectID(compliancePageID),
|
||||
@@ -295,9 +295,9 @@ func (s *Service) ProvisionPortalMember(
|
||||
ctx context.Context,
|
||||
compliancePageID gid.GID,
|
||||
identityID gid.GID,
|
||||
) (*coredata.TrustCenterAccess, error) {
|
||||
) (*coredata.CompliancePortalAccess, error) {
|
||||
var (
|
||||
access *coredata.TrustCenterAccess
|
||||
access *coredata.CompliancePortalAccess
|
||||
now = time.Now()
|
||||
scope = coredata.NewScopeFromObjectID(compliancePageID)
|
||||
)
|
||||
@@ -305,7 +305,7 @@ func (s *Service) ProvisionPortalMember(
|
||||
err := s.pg.WithTx(
|
||||
ctx,
|
||||
func(ctx context.Context, tx pg.Tx) error {
|
||||
compliancePage := &coredata.TrustCenter{}
|
||||
compliancePage := &coredata.CompliancePortal{}
|
||||
if err := compliancePage.LoadByID(ctx, tx, scope, compliancePageID); err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
access = &coredata.TrustCenterAccess{}
|
||||
if err := access.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, compliancePageID, identityID); err != nil {
|
||||
access = &coredata.CompliancePortalAccess{}
|
||||
if err := access.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePageID, identityID); err != nil {
|
||||
if !errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return fmt.Errorf("cannot load compliance page access: %w", err)
|
||||
}
|
||||
|
||||
access = &coredata.TrustCenterAccess{
|
||||
ID: gid.New(scope.GetTenantID(), coredata.TrustCenterAccessEntityType),
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TenantID: scope.GetTenantID(),
|
||||
IdentityID: identityID,
|
||||
TrustCenterID: compliancePageID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
access = &coredata.CompliancePortalAccess{
|
||||
ID: gid.New(scope.GetTenantID(), coredata.CompliancePortalAccessEntityType),
|
||||
OrganizationID: compliancePage.OrganizationID,
|
||||
TenantID: scope.GetTenantID(),
|
||||
IdentityID: identityID,
|
||||
CompliancePortalID: compliancePageID,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
var sig *coredata.ElectronicSignature
|
||||
|
||||
@@ -63,8 +63,8 @@ func (s *Service) ListThirdPartiesForOrganizationID(
|
||||
filter *coredata.ThirdPartyFilter,
|
||||
) (*page.Page[*coredata.ThirdParty, coredata.ThirdPartyOrderField], error) {
|
||||
if filter == nil {
|
||||
showOnTrustCenter := true
|
||||
filter = coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, nil, nil, nil)
|
||||
showOnCompliancePortal := true
|
||||
filter = coredata.NewThirdPartyFilter(&showOnCompliancePortal, nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
var thirdParties coredata.ThirdParties
|
||||
@@ -99,7 +99,7 @@ func (s *Service) ListDistinctPortalCategoriesForOrganizationID(
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
thirdParties := &coredata.ThirdParties{}
|
||||
|
||||
result, err := thirdParties.LoadDistinctTrustCenterCategoriesByOrganizationID(ctx, conn, scope, organizationID)
|
||||
result, err := thirdParties.LoadDistinctCompliancePortalCategoriesByOrganizationID(ctx, conn, scope, organizationID)
|
||||
if err != nil {
|
||||
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 {
|
||||
thirdParties := &coredata.ThirdParties{}
|
||||
|
||||
result, err := thirdParties.LoadDistinctTrustCenterCountriesByOrganizationID(ctx, conn, scope, organizationID)
|
||||
result, err := thirdParties.LoadDistinctCompliancePortalCountriesByOrganizationID(ctx, conn, scope, organizationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load thirdParty countries: %w", err)
|
||||
}
|
||||
@@ -152,8 +152,8 @@ func (s *Service) CountThirdPartiesForPortalID(
|
||||
filter *coredata.ThirdPartyFilter,
|
||||
) (int, error) {
|
||||
if filter == nil {
|
||||
showOnTrustCenter := true
|
||||
filter = coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, nil, nil, nil)
|
||||
showOnCompliancePortal := true
|
||||
filter = coredata.NewThirdPartyFilter(&showOnCompliancePortal, nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
var count int
|
||||
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
)
|
||||
|
||||
// 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 completionCertificateHandler struct {
|
||||
|
||||
@@ -608,8 +608,8 @@ func (s *OrganizationService) CreateOrganization(
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
trustCenter = &coredata.TrustCenter{
|
||||
ID: gid.New(tenantID, coredata.TrustCenterEntityType),
|
||||
compliancePortal = &coredata.CompliancePortal{
|
||||
ID: gid.New(tenantID, coredata.CompliancePortalEntityType),
|
||||
OrganizationID: organization.ID,
|
||||
TenantID: organization.TenantID,
|
||||
Active: false,
|
||||
@@ -726,7 +726,7 @@ func (s *OrganizationService) CreateOrganization(
|
||||
}
|
||||
|
||||
organization.LogoFileID = &logoFile.ID
|
||||
trustCenter.LogoFileID = &logoFile.ID
|
||||
compliancePortal.LogoFileID = &logoFile.ID
|
||||
}
|
||||
|
||||
if horizontalLogoFile != nil {
|
||||
@@ -760,8 +760,8 @@ func (s *OrganizationService) CreateOrganization(
|
||||
// a default managed domain: there is no suffix to mint a
|
||||
// "{slug}." hostname from, so the compliance page stays without
|
||||
// a domain until the organization adds a custom one.
|
||||
if s.trustCenterBaseDomain != "" {
|
||||
defaultDomainHostname := trustCenter.Slug + "." + s.trustCenterBaseDomain
|
||||
if s.compliancePortalBaseDomain != "" {
|
||||
defaultDomainHostname := compliancePortal.Slug + "." + s.compliancePortalBaseDomain
|
||||
|
||||
defaultDomain := coredata.NewCustomDomain(
|
||||
tenantID,
|
||||
@@ -781,29 +781,29 @@ func (s *OrganizationService) CreateOrganization(
|
||||
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 {
|
||||
return fmt.Errorf("cannot insert trust center: %w", err)
|
||||
if err := compliancePortal.Insert(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot insert compliance portal: %w", err)
|
||||
}
|
||||
|
||||
proboData := &coredata.ThirdParty{
|
||||
ID: gid.New(scope.GetTenantID(), coredata.ThirdPartyEntityType),
|
||||
OrganizationID: organization.ID,
|
||||
Name: proboThirdParty.Name,
|
||||
Description: &proboThirdParty.Description,
|
||||
Category: coredata.ThirdPartyCategorySecurity,
|
||||
HeadquarterAddress: &proboThirdParty.HeadquarterAddress,
|
||||
LegalName: &proboThirdParty.LegalName,
|
||||
WebsiteURL: &proboThirdParty.WebsiteURL,
|
||||
PrivacyPolicyURL: &proboThirdParty.PrivacyPolicyURL,
|
||||
TermsOfServiceURL: &proboThirdParty.TermsOfServiceURL,
|
||||
SubprocessorsListURL: &proboThirdParty.SubprocessorsListURL,
|
||||
ShowOnTrustCenter: false,
|
||||
Level: 1,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: gid.New(scope.GetTenantID(), coredata.ThirdPartyEntityType),
|
||||
OrganizationID: organization.ID,
|
||||
Name: proboThirdParty.Name,
|
||||
Description: &proboThirdParty.Description,
|
||||
Category: coredata.ThirdPartyCategorySecurity,
|
||||
HeadquarterAddress: &proboThirdParty.HeadquarterAddress,
|
||||
LegalName: &proboThirdParty.LegalName,
|
||||
WebsiteURL: &proboThirdParty.WebsiteURL,
|
||||
PrivacyPolicyURL: &proboThirdParty.PrivacyPolicyURL,
|
||||
TermsOfServiceURL: &proboThirdParty.TermsOfServiceURL,
|
||||
SubprocessorsListURL: &proboThirdParty.SubprocessorsListURL,
|
||||
ShowOnCompliancePortal: false,
|
||||
Level: 1,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := proboData.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -832,7 +832,7 @@ func (s *OrganizationService) UpdateOrganization(ctx context.Context, organizati
|
||||
tenantID = organizationID.TenantID()
|
||||
scope = coredata.NewScopeFromObjectID(organizationID)
|
||||
organization = &coredata.Organization{}
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
)
|
||||
|
||||
// TODO: s3 upload happen before we validate the tenantID
|
||||
|
||||
@@ -62,7 +62,7 @@ type (
|
||||
magicLinkTokenValidity time.Duration
|
||||
sessionDuration time.Duration
|
||||
bucket string
|
||||
trustCenterBaseDomain string
|
||||
compliancePortalBaseDomain string
|
||||
certManager *certmanager.Service
|
||||
certificate *x509.Certificate
|
||||
privateKey *rsa.PrivateKey
|
||||
@@ -92,7 +92,7 @@ type (
|
||||
Bucket string
|
||||
TokenSecret string
|
||||
BaseURL *baseurl.BaseURL
|
||||
TrustCenterBaseDomain string
|
||||
CompliancePortalBaseDomain string
|
||||
CertManager *certmanager.Service
|
||||
EncryptionKey cipher.EncryptionKey
|
||||
Certificate *x509.Certificate
|
||||
@@ -166,7 +166,7 @@ func NewService(
|
||||
magicLinkTokenValidity: cfg.MagicLinkTokenValidity,
|
||||
sessionDuration: cfg.SessionDuration,
|
||||
bucket: cfg.Bucket,
|
||||
trustCenterBaseDomain: cfg.TrustCenterBaseDomain,
|
||||
compliancePortalBaseDomain: cfg.CompliancePortalBaseDomain,
|
||||
certManager: cfg.CertManager,
|
||||
certificate: cfg.Certificate,
|
||||
privateKey: cfg.PrivateKey,
|
||||
|
||||
@@ -63,7 +63,7 @@ func (s *Service) mailingListEmailConfig(
|
||||
) (emails.PresenterConfig, string, string, *mail.Addr, error) {
|
||||
var (
|
||||
mailingList = &coredata.MailingList{}
|
||||
compliancePage = &coredata.TrustCenter{}
|
||||
compliancePage = &coredata.CompliancePortal{}
|
||||
organization = &coredata.Organization{}
|
||||
compliancePageURL string
|
||||
logoFile = &coredata.File{}
|
||||
@@ -97,7 +97,7 @@ func (s *Service) mailingListEmailConfig(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
publicURL, err := s.compliancePortal.PublicURLForCompliancePage(
|
||||
publicURL, err := s.compliancePortal.PublicURLForCompliancePortal(
|
||||
ctx,
|
||||
conn,
|
||||
scope,
|
||||
@@ -116,7 +116,7 @@ func (s *Service) mailingListEmailConfig(
|
||||
return defaultCfg, "", "", nil, err
|
||||
}
|
||||
|
||||
cfg, err := s.presenterConfigFromTrustCenter(compliancePage, organization, compliancePageURL, logoFile)
|
||||
cfg, err := s.presenterConfigFromCompliancePortal(compliancePage, organization, compliancePageURL, logoFile)
|
||||
if err != nil {
|
||||
return defaultCfg, "", "", nil, err
|
||||
}
|
||||
@@ -134,8 +134,8 @@ func (s *Service) mailingListEmailConfig(
|
||||
return cfg, organization.Name, updatesPageURL, mailingList.ReplyTo, nil
|
||||
}
|
||||
|
||||
func (s *Service) presenterConfigFromTrustCenter(
|
||||
compliancePage *coredata.TrustCenter,
|
||||
func (s *Service) presenterConfigFromCompliancePortal(
|
||||
compliancePage *coredata.CompliancePortal,
|
||||
organization *coredata.Organization,
|
||||
compliancePageURL string,
|
||||
logoFile *coredata.File,
|
||||
|
||||
@@ -405,6 +405,6 @@ const (
|
||||
ActionCommonThirdPartyList = "core:common-third-party:list"
|
||||
|
||||
// ElectronicSignature actions (tenant-scoped via the related document
|
||||
// version signature / trust center access).
|
||||
// version signature / compliance portal access).
|
||||
ActionElectronicSignatureGet = "core:electronic-signature:get"
|
||||
)
|
||||
|
||||
@@ -39,22 +39,22 @@ type AuditService struct {
|
||||
|
||||
type (
|
||||
CreateAuditRequest struct {
|
||||
OrganizationID gid.GID
|
||||
FrameworkID gid.GID
|
||||
Name *string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
OrganizationID gid.GID
|
||||
FrameworkID gid.GID
|
||||
Name *string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
CompliancePortalVisibility *coredata.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
UpdateAuditRequest struct {
|
||||
ID gid.GID
|
||||
Name **string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
ID gid.GID
|
||||
Name **string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
CompliancePortalVisibility *coredata.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
UploadAuditReportRequest struct {
|
||||
@@ -71,7 +71,7 @@ func (car *CreateAuditRequest) Validate() error {
|
||||
v.Check(car.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(car.ValidUntil, "valid_until", validator.After(car.ValidFrom))
|
||||
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()
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (uar *UpdateAuditRequest) Validate() error {
|
||||
v.Check(uar.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(uar.ValidUntil, "valid_until", validator.After(uar.ValidFrom))
|
||||
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()
|
||||
}
|
||||
@@ -164,24 +164,24 @@ func (s *AuditService) Create(
|
||||
|
||||
now := time.Now()
|
||||
audit := &coredata.Audit{
|
||||
ID: gid.New(scope.GetTenantID(), coredata.AuditEntityType),
|
||||
Name: req.Name,
|
||||
OrganizationID: req.OrganizationID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
ValidFrom: req.ValidFrom,
|
||||
ValidUntil: req.ValidUntil,
|
||||
State: coredata.AuditStateNotStarted,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: gid.New(scope.GetTenantID(), coredata.AuditEntityType),
|
||||
Name: req.Name,
|
||||
OrganizationID: req.OrganizationID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
ValidFrom: req.ValidFrom,
|
||||
ValidUntil: req.ValidUntil,
|
||||
State: coredata.AuditStateNotStarted,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.State != nil {
|
||||
audit.State = *req.State
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
audit.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
if req.CompliancePortalVisibility != nil {
|
||||
audit.CompliancePortalVisibility = *req.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
@@ -244,8 +244,8 @@ func (s *AuditService) Update(
|
||||
audit.State = *req.State
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
audit.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
if req.CompliancePortalVisibility != nil {
|
||||
audit.CompliancePortalVisibility = *req.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
audit.UpdatedAt = time.Now()
|
||||
|
||||
@@ -105,23 +105,23 @@ type (
|
||||
}
|
||||
|
||||
CreateDocumentRequest struct {
|
||||
OrganizationID gid.GID
|
||||
Title string
|
||||
Content string
|
||||
Classification coredata.DocumentClassification
|
||||
DocumentType coredata.DocumentType
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
DefaultApproverIDs []gid.GID
|
||||
OrganizationID gid.GID
|
||||
Title string
|
||||
Content string
|
||||
Classification coredata.DocumentClassification
|
||||
DocumentType coredata.DocumentType
|
||||
CompliancePortalVisibility *coredata.CompliancePortalVisibility
|
||||
DefaultApproverIDs []gid.GID
|
||||
}
|
||||
|
||||
UpdateDocumentRequest struct {
|
||||
DocumentID gid.GID
|
||||
Title *string
|
||||
Content *string
|
||||
Classification *coredata.DocumentClassification
|
||||
DocumentType *coredata.DocumentType
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
DefaultApproverIDs *[]gid.GID
|
||||
DocumentID gid.GID
|
||||
Title *string
|
||||
Content *string
|
||||
Classification *coredata.DocumentClassification
|
||||
DocumentType *coredata.DocumentType
|
||||
CompliancePortalVisibility *coredata.CompliancePortalVisibility
|
||||
DefaultApproverIDs *[]gid.GID
|
||||
}
|
||||
|
||||
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.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(cdr.DefaultApproverIDs, "default_approver_ids", validator.NoDuplicates())
|
||||
v.CheckEach(cdr.DefaultApproverIDs, "default_approver_ids", func(_ int, item any) {
|
||||
@@ -231,7 +231,7 @@ func (udr *UpdateDocumentRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
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 {
|
||||
v.Check(len(*udr.DefaultApproverIDs), "default_approver_ids", validator.Max(100))
|
||||
@@ -791,16 +791,16 @@ func (s *DocumentService) Create(
|
||||
organization := &coredata.Organization{}
|
||||
|
||||
document := &coredata.Document{
|
||||
ID: documentID,
|
||||
WriteMode: coredata.DocumentWriteModeAuthored,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
WriteMode: coredata.DocumentWriteModeAuthored,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
if req.CompliancePortalVisibility != nil {
|
||||
document.CompliancePortalVisibility = *req.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
content := req.Content
|
||||
@@ -2209,8 +2209,8 @@ func (s *DocumentService) Update(
|
||||
|
||||
previousDocument := *document
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
if req.CompliancePortalVisibility != nil {
|
||||
document.CompliancePortalVisibility = *req.CompliancePortalVisibility
|
||||
}
|
||||
|
||||
document.UpdatedAt = now
|
||||
@@ -2225,7 +2225,7 @@ func (s *DocumentService) Update(
|
||||
}
|
||||
|
||||
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 {
|
||||
return &ErrDocumentVersionGenerated{}
|
||||
@@ -2498,7 +2498,7 @@ func (s *DocumentService) Archive(
|
||||
document.Status = coredata.DocumentStatusArchived
|
||||
document.ArchivedAt = &now
|
||||
document.UpdatedAt = now
|
||||
document.TrustCenterVisibility = coredata.TrustCenterVisibilityNone
|
||||
document.CompliancePortalVisibility = coredata.CompliancePortalVisibilityNone
|
||||
|
||||
if err := document.Update(ctx, tx, scope); err != nil {
|
||||
return fmt.Errorf("cannot archive document: %w", err)
|
||||
|
||||
@@ -98,13 +98,13 @@ func (s *GeneratedDocumentService) PublishStatementOfApplicability(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: soa.OrganizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: soa.OrganizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -371,13 +371,13 @@ func (s *GeneratedDocumentService) PublishDataList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -643,13 +643,13 @@ func (s *GeneratedDocumentService) PublishAssetList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -938,13 +938,13 @@ func (s *GeneratedDocumentService) PublishFindingList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -1264,13 +1264,13 @@ func (s *GeneratedDocumentService) PublishObligationList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -1558,13 +1558,13 @@ func (s *GeneratedDocumentService) PublishProcessingActivityList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -1953,13 +1953,13 @@ func (s *GeneratedDocumentService) PublishDataProtectionImpactAssessmentList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -2185,13 +2185,13 @@ func (s *GeneratedDocumentService) PublishTransferImpactAssessmentList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -2433,13 +2433,13 @@ func (s *GeneratedDocumentService) PublishThirdPartyList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
@@ -2984,13 +2984,13 @@ func (s *GeneratedDocumentService) PublishRiskList(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -85,7 +85,7 @@ type (
|
||||
StatusPageURL **string
|
||||
BusinessOwnerID **gid.GID
|
||||
SecurityOwnerID **gid.GID
|
||||
ShowOnTrustCenter *bool
|
||||
ShowOnCompliancePortal *bool
|
||||
}
|
||||
|
||||
CreateThirdPartyRiskAssessmentRequest struct {
|
||||
@@ -416,8 +416,8 @@ func (s ThirdPartyService) Update(
|
||||
thirdParty.SecurityPageURL = *req.SecurityPageURL
|
||||
}
|
||||
|
||||
if req.ShowOnTrustCenter != nil {
|
||||
thirdParty.ShowOnTrustCenter = *req.ShowOnTrustCenter
|
||||
if req.ShowOnCompliancePortal != nil {
|
||||
thirdParty.ShowOnCompliancePortal = *req.ShowOnCompliancePortal
|
||||
}
|
||||
|
||||
if req.TrustPageURL != nil {
|
||||
@@ -607,7 +607,7 @@ func (s ThirdPartyService) Create(
|
||||
TrustPageURL: req.TrustPageURL,
|
||||
StatusPageURL: req.StatusPageURL,
|
||||
TermsOfServiceURL: req.TermsOfServiceURL,
|
||||
ShowOnTrustCenter: false,
|
||||
ShowOnCompliancePortal: false,
|
||||
Level: 1,
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ func (s ThirdPartyService) ImportFromCommon(
|
||||
TermsOfServiceURL: commonParty.TermsOfServiceURL,
|
||||
SecurityPageURL: commonParty.SecurityPageURL,
|
||||
TrustPageURL: commonParty.TrustPageURL,
|
||||
ShowOnTrustCenter: false,
|
||||
ShowOnCompliancePortal: false,
|
||||
Level: 1,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
|
||||
@@ -76,7 +76,7 @@ func BuildTrackerPolicyDocument(data docgen.TrackerPolicyData) (string, error) {
|
||||
// PublishTrackerPolicy generates (or regenerates) the cookie and tracking
|
||||
// technologies policy document for a banner from its latest published version
|
||||
// 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.
|
||||
func (s *GeneratedDocumentService) PublishTrackerPolicy(
|
||||
ctx context.Context,
|
||||
@@ -164,13 +164,13 @@ func (s *GeneratedDocumentService) PublishTrackerPolicy(
|
||||
documentID := gid.New(scope.GetTenantID(), coredata.DocumentEntityType)
|
||||
|
||||
document = &coredata.Document{
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityPrivate,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
OrganizationID: organizationID,
|
||||
WriteMode: coredata.DocumentWriteModeGenerated,
|
||||
CompliancePortalVisibility: coredata.CompliancePortalVisibilityPrivate,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if err := document.Insert(ctx, tx, scope); err != nil {
|
||||
|
||||
@@ -29,7 +29,7 @@ type (
|
||||
MetricsConfig = probodconfig.MetricsConfig
|
||||
TracingConfig = probodconfig.TracingConfig
|
||||
ESignConfig = probodconfig.ESignConfig
|
||||
TrustCenterConfig = probodconfig.TrustCenterConfig
|
||||
CompliancePortalConfig = probodconfig.CompliancePortalConfig
|
||||
APIConfig = probodconfig.APIConfig
|
||||
CorsConfig = probodconfig.CorsConfig
|
||||
GraphQLConfig = probodconfig.GraphQLConfig
|
||||
|
||||
@@ -145,7 +145,7 @@ func New() *Implm {
|
||||
DomainVerificationResolverAddr: "8.8.8.8:53",
|
||||
},
|
||||
},
|
||||
TrustCenter: TrustCenterConfig{
|
||||
CompliancePortal: CompliancePortalConfig{
|
||||
HTTPAddr: ":80",
|
||||
HTTPSAddr: ":443",
|
||||
BaseDomain: "probopage.com",
|
||||
@@ -547,7 +547,7 @@ func (impl *Implm) Run(
|
||||
CnameTarget: impl.cfg.CustomDomains.CnameTarget,
|
||||
CAAIssuerDomain: impl.cfg.CustomDomains.CAAIssuerDomain,
|
||||
ResolverAddr: impl.cfg.CustomDomains.ResolverAddr,
|
||||
ManagedBaseDomain: impl.cfg.TrustCenter.BaseDomain,
|
||||
ManagedBaseDomain: impl.cfg.CompliancePortal.BaseDomain,
|
||||
RenewalInterval: customDomainRenewalInterval,
|
||||
ProvisionInterval: customDomainProvisionInterval,
|
||||
},
|
||||
@@ -568,7 +568,7 @@ func (impl *Implm) Run(
|
||||
Bucket: impl.cfg.AWS.Bucket,
|
||||
TokenSecret: impl.cfg.Auth.Cookie.Secret,
|
||||
BaseURL: baseURL,
|
||||
TrustCenterBaseDomain: impl.cfg.TrustCenter.BaseDomain,
|
||||
CompliancePortalBaseDomain: impl.cfg.CompliancePortal.BaseDomain,
|
||||
EncryptionKey: encryptionKey,
|
||||
Certificate: samlCert,
|
||||
PrivateKey: samlKey,
|
||||
@@ -624,7 +624,7 @@ func (impl *Implm) Run(
|
||||
s3Client,
|
||||
impl.cfg.AWS.Bucket,
|
||||
baseURL.String(),
|
||||
impl.cfg.TrustCenter.BaseDomain,
|
||||
impl.cfg.CompliancePortal.BaseDomain,
|
||||
fileManagerService,
|
||||
certManagerService,
|
||||
slackService,
|
||||
@@ -671,7 +671,7 @@ func (impl *Implm) Run(
|
||||
return fmt.Errorf("cannot create probo service: %w", err)
|
||||
}
|
||||
|
||||
trustService := visitor.NewService(
|
||||
visitorService := visitor.NewService(
|
||||
pgClient,
|
||||
s3Client,
|
||||
impl.cfg.AWS.Bucket,
|
||||
@@ -691,7 +691,7 @@ func (impl *Implm) Run(
|
||||
func(ctx context.Context, clientIDURL string) (oauth2.CIMDAllowance, error) {
|
||||
host, ok := oauth2.CIMDClientIDHost(clientIDURL)
|
||||
if ok {
|
||||
_, err := trustService.GetPortalByDomainName(ctx, host)
|
||||
_, err := visitorService.GetPortalByDomainName(ctx, host)
|
||||
if err == nil {
|
||||
return oauth2.CIMDAllowanceAllowedSkipConsent, nil
|
||||
}
|
||||
@@ -727,7 +727,7 @@ func (impl *Implm) Run(
|
||||
ResourceAlias: resourceAliasService,
|
||||
File: fileManagerService,
|
||||
IAM: iamService,
|
||||
Trust: trustService,
|
||||
Visitor: visitorService,
|
||||
ESign: esignService,
|
||||
Management: managementService,
|
||||
CertManager: certManagerService,
|
||||
@@ -773,7 +773,7 @@ func (impl *Implm) Run(
|
||||
ExtraHeaderFields: impl.cfg.Api.ExtraHeaderFields,
|
||||
Logger: l.Named("compliance-portal"),
|
||||
IAM: iamService,
|
||||
Visitor: trustService,
|
||||
Visitor: visitorService,
|
||||
ResourceAlias: resourceAliasService,
|
||||
File: fileManagerService,
|
||||
ESign: esignService,
|
||||
@@ -798,7 +798,7 @@ func (impl *Implm) Run(
|
||||
},
|
||||
)
|
||||
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())
|
||||
@@ -958,7 +958,7 @@ func (impl *Implm) Run(
|
||||
|
||||
wg.Go(
|
||||
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))
|
||||
}
|
||||
},
|
||||
@@ -1133,22 +1133,22 @@ func (impl *Implm) Run(
|
||||
},
|
||||
)
|
||||
|
||||
trustCenterServerCtx, stopTrustCenterServer := context.WithCancel(context.Background())
|
||||
defer stopTrustCenterServer()
|
||||
compliancePortalServerCtx, stopCompliancePortalServer := context.WithCancel(context.Background())
|
||||
defer stopCompliancePortalServer()
|
||||
|
||||
wg.Go(
|
||||
func() {
|
||||
if err := impl.runTrustCenterServer(
|
||||
trustCenterServerCtx,
|
||||
if err := impl.runCompliancePortalServer(
|
||||
compliancePortalServerCtx,
|
||||
l,
|
||||
r,
|
||||
tp,
|
||||
pgClient,
|
||||
compliancePortalHandler,
|
||||
trustService,
|
||||
visitorService,
|
||||
encryptionKey,
|
||||
); 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()
|
||||
|
||||
stopApiServer()
|
||||
stopTrustCenterServer()
|
||||
stopCompliancePortalServer()
|
||||
stopWebhookWorker()
|
||||
stopESignService()
|
||||
stopCertManagerService()
|
||||
@@ -1298,7 +1298,7 @@ func (impl *Implm) runApiServer(
|
||||
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) {
|
||||
ctx := r.Context()
|
||||
|
||||
@@ -1314,10 +1314,10 @@ func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Log
|
||||
return
|
||||
}
|
||||
|
||||
// Check if this domain is a trust center custom domain
|
||||
if _, err := trustService.GetPortalByDomainName(ctx, domain); err != nil {
|
||||
// Check if this domain is a compliance portal custom domain
|
||||
if _, err := visitorService.GetPortalByDomainName(ctx, domain); err != nil {
|
||||
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"))
|
||||
return
|
||||
}
|
||||
@@ -1327,7 +1327,7 @@ func newTrustCenterHTTPRedirectHandler(trustService *visitor.Service, l *log.Log
|
||||
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)
|
||||
if err != nil {
|
||||
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()
|
||||
l.InfoCtx(
|
||||
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("path", r.URL.Path),
|
||||
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,
|
||||
l *log.Logger,
|
||||
r prometheus.Registerer,
|
||||
tp trace.TracerProvider,
|
||||
pgClient *pg.Client,
|
||||
trustRouter http.Handler,
|
||||
trustService *visitor.Service,
|
||||
visitorService *visitor.Service,
|
||||
encryptionKey cipher.EncryptionKey,
|
||||
) error {
|
||||
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()
|
||||
|
||||
certSelector := certmanager.NewSelector(pgClient, encryptionKey)
|
||||
@@ -1371,7 +1371,7 @@ func (impl *Implm) runTrustCenterServer(
|
||||
|
||||
g, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
l.Info("starting trust center services")
|
||||
l.Info("starting compliance portal services")
|
||||
span.AddEvent("Trust center services starting")
|
||||
|
||||
httpACMEHandler := certmanager.NewACMEChallengeHandler(
|
||||
@@ -1379,10 +1379,10 @@ func (impl *Implm) runTrustCenterServer(
|
||||
l.Named("http_acme_handler"),
|
||||
)
|
||||
|
||||
httpRedirectHandler := newTrustCenterHTTPRedirectHandler(trustService, l.Named("http_redirect"))
|
||||
httpRedirectHandler := newCompliancePortalHTTPRedirectHandler(visitorService, l.Named("http_redirect"))
|
||||
|
||||
httpServer := httpserver.NewServer(
|
||||
impl.cfg.TrustCenter.HTTPAddr,
|
||||
impl.cfg.CompliancePortal.HTTPAddr,
|
||||
httpACMEHandler.Handle(httpRedirectHandler),
|
||||
httpserver.WithLogger(l),
|
||||
httpserver.WithRegisterer(r),
|
||||
@@ -1401,8 +1401,8 @@ func (impl *Implm) runTrustCenterServer(
|
||||
|
||||
defer func() { _ = listener.Close() }()
|
||||
|
||||
if len(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies) > 0 {
|
||||
policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies)
|
||||
if len(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies) > 0 {
|
||||
policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot build proxy protocol policy: %w", err)
|
||||
}
|
||||
@@ -1413,7 +1413,7 @@ func (impl *Implm) runTrustCenterServer(
|
||||
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 {
|
||||
@@ -1446,7 +1446,7 @@ func (impl *Implm) runTrustCenterServer(
|
||||
}
|
||||
httpServerLogger := l.Named("", log.SkipMatch(ignoreTLSHandshakeErrors))
|
||||
httpsServer := httpserver.NewServer(
|
||||
impl.cfg.TrustCenter.HTTPSAddr,
|
||||
impl.cfg.CompliancePortal.HTTPSAddr,
|
||||
handler,
|
||||
httpserver.WithLogger(httpServerLogger),
|
||||
httpserver.WithRegisterer(r),
|
||||
@@ -1482,7 +1482,7 @@ func (impl *Implm) runTrustCenterServer(
|
||||
|
||||
g.Go(
|
||||
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")
|
||||
|
||||
listener, err := net.Listen("tcp", httpsServer.Addr)
|
||||
@@ -1492,8 +1492,8 @@ func (impl *Implm) runTrustCenterServer(
|
||||
|
||||
defer func() { _ = listener.Close() }()
|
||||
|
||||
if len(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies) > 0 {
|
||||
policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.TrustCenter.ProxyProtocol.TrustedProxies)
|
||||
if len(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies) > 0 {
|
||||
policy, err := proxyproto.ConnStrictWhiteListPolicy(impl.cfg.CompliancePortal.ProxyProtocol.TrustedProxies)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot build proxy protocol policy: %w", err)
|
||||
}
|
||||
@@ -1504,7 +1504,7 @@ func (impl *Implm) runTrustCenterServer(
|
||||
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 {
|
||||
@@ -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")
|
||||
|
||||
go func() {
|
||||
@@ -1524,7 +1524,7 @@ func (impl *Implm) runTrustCenterServer(
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
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")
|
||||
|
||||
if err := httpsServer.Shutdown(shutdownCtx); err != nil {
|
||||
|
||||
@@ -60,7 +60,7 @@ type (
|
||||
Pg PgConfig `json:"pg"`
|
||||
Api APIConfig `json:"api"`
|
||||
Auth AuthConfig `json:"auth"`
|
||||
TrustCenter TrustCenterConfig `json:"trust-center"`
|
||||
CompliancePortal CompliancePortalConfig `json:"trust-center"`
|
||||
AWS AWSConfig `json:"aws"`
|
||||
Notifications NotificationsConfig `json:"notifications"`
|
||||
Connectors []ConnectorConfig `json:"connectors,omitempty"`
|
||||
@@ -79,8 +79,8 @@ type (
|
||||
Branding bool `json:"branding"`
|
||||
}
|
||||
|
||||
// TrustCenterConfig contains trust center server configuration.
|
||||
TrustCenterConfig struct {
|
||||
// CompliancePortalConfig contains compliance portal server configuration.
|
||||
CompliancePortalConfig struct {
|
||||
HTTPAddr string `json:"http-addr,omitempty"`
|
||||
HTTPSAddr string `json:"https-addr,omitempty"`
|
||||
BaseDomain string `json:"base-domain,omitempty"`
|
||||
|
||||
@@ -123,9 +123,9 @@ func (s *Service) UpdateSlackAccessMessage(
|
||||
return fmt.Errorf("cannot load slack message: %w", err)
|
||||
}
|
||||
|
||||
var trustCenter coredata.TrustCenter
|
||||
if err := trustCenter.LoadByOrganizationID(ctx, tx, scope, slackMessage.OrganizationID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
var compliancePortal coredata.CompliancePortal
|
||||
if err := compliancePortal.LoadByOrganizationID(ctx, tx, scope, slackMessage.OrganizationID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal: %w", err)
|
||||
}
|
||||
|
||||
identity := &coredata.Identity{}
|
||||
@@ -133,12 +133,12 @@ func (s *Service) UpdateSlackAccessMessage(
|
||||
return fmt.Errorf("cannot load identity: %w", err)
|
||||
}
|
||||
|
||||
var trustCenterAccess coredata.TrustCenterAccess
|
||||
if err := trustCenterAccess.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, trustCenter.ID, identity.ID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
var compliancePortalAccess coredata.CompliancePortalAccess
|
||||
if err := compliancePortalAccess.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePortal.ID, identity.ID); err != nil {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (s *Service) UpdateSlackAccessMessage(
|
||||
newSlackMessageID,
|
||||
identity.FullName,
|
||||
requesterEmail,
|
||||
trustCenter.OrganizationID,
|
||||
compliancePortal.OrganizationID,
|
||||
documents,
|
||||
reports,
|
||||
files,
|
||||
@@ -197,26 +197,26 @@ func (s *Service) QueueSlackNotification(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
identityID gid.GID,
|
||||
trustCenterID gid.GID,
|
||||
compliancePortalID gid.GID,
|
||||
) error {
|
||||
return s.pg.WithTx(ctx, func(ctx context.Context, tx pg.Tx) error {
|
||||
var (
|
||||
identity = &coredata.Identity{}
|
||||
trustCenterAccess *coredata.TrustCenterAccess
|
||||
identity = &coredata.Identity{}
|
||||
compliancePortalAccess *coredata.CompliancePortalAccess
|
||||
)
|
||||
|
||||
if err := identity.LoadByID(ctx, tx, identityID); err != nil {
|
||||
return fmt.Errorf("cannot load identity: %w", err)
|
||||
}
|
||||
|
||||
trustCenterAccess = &coredata.TrustCenterAccess{}
|
||||
if err := trustCenterAccess.LoadByTrustCenterIDAndIdentityID(ctx, tx, scope, trustCenterID, identityID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center access: %w", err)
|
||||
compliancePortalAccess = &coredata.CompliancePortalAccess{}
|
||||
if err := compliancePortalAccess.LoadByCompliancePortalIDAndIdentityID(ctx, tx, scope, compliancePortalID, identityID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal access: %w", err)
|
||||
}
|
||||
|
||||
var trustCenter coredata.TrustCenter
|
||||
if err := trustCenter.LoadByID(ctx, tx, scope, trustCenterID); err != nil {
|
||||
return fmt.Errorf("cannot load trust center: %w", err)
|
||||
var compliancePortal coredata.CompliancePortal
|
||||
if err := compliancePortal.LoadByID(ctx, tx, scope, compliancePortalID); err != nil {
|
||||
return fmt.Errorf("cannot load compliance portal: %w", err)
|
||||
}
|
||||
|
||||
var connectors coredata.Connectors
|
||||
@@ -224,7 +224,7 @@ func (s *Service) QueueSlackNotification(
|
||||
ctx,
|
||||
tx,
|
||||
scope,
|
||||
trustCenter.OrganizationID,
|
||||
compliancePortal.OrganizationID,
|
||||
); err != nil {
|
||||
return fmt.Errorf("cannot load connectors: %w", err)
|
||||
}
|
||||
@@ -242,7 +242,7 @@ func (s *Service) QueueSlackNotification(
|
||||
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 {
|
||||
return fmt.Errorf("cannot load documents, reports and files: %w", err)
|
||||
}
|
||||
@@ -253,7 +253,7 @@ func (s *Service) QueueSlackNotification(
|
||||
slackMessageID,
|
||||
identity.FullName,
|
||||
identity.EmailAddress,
|
||||
trustCenter.OrganizationID,
|
||||
compliancePortal.OrganizationID,
|
||||
documents,
|
||||
reports,
|
||||
files,
|
||||
@@ -271,8 +271,8 @@ func (s *Service) QueueSlackNotification(
|
||||
now := time.Now()
|
||||
slackMessage := &coredata.SlackMessage{
|
||||
ID: slackMessageID,
|
||||
OrganizationID: trustCenter.OrganizationID,
|
||||
Type: coredata.SlackMessageTypeTrustCenterAccessRequest,
|
||||
OrganizationID: compliancePortal.OrganizationID,
|
||||
Type: coredata.SlackMessageTypeCompliancePortalAccessRequest,
|
||||
Body: body,
|
||||
RequesterEmail: &identity.EmailAddress,
|
||||
Metadata: metadata.toMap(),
|
||||
@@ -288,9 +288,9 @@ func (s *Service) QueueSlackNotification(
|
||||
ctx,
|
||||
tx,
|
||||
scope,
|
||||
trustCenter.OrganizationID,
|
||||
compliancePortal.OrganizationID,
|
||||
identity.EmailAddress,
|
||||
coredata.SlackMessageTypeTrustCenterAccessRequest,
|
||||
coredata.SlackMessageTypeCompliancePortalAccessRequest,
|
||||
sevenDaysAgo,
|
||||
)
|
||||
if err == nil {
|
||||
@@ -323,7 +323,7 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
|
||||
ctx context.Context,
|
||||
conn pg.Querier,
|
||||
scope coredata.Scoper,
|
||||
trustCenterAccessID gid.GID,
|
||||
compliancePortalAccessID gid.GID,
|
||||
) (
|
||||
documents []SlackMessageDocument,
|
||||
reports []SlackMessageReport,
|
||||
@@ -336,14 +336,14 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
|
||||
|
||||
accesses, err := page.LoadAll(
|
||||
ctx,
|
||||
page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{
|
||||
Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt,
|
||||
page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
|
||||
Field: coredata.CompliancePortalDocumentAccessOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
},
|
||||
func(ctx context.Context, cursor *page.Cursor[coredata.TrustCenterDocumentAccessOrderField]) ([]*coredata.TrustCenterDocumentAccess, error) {
|
||||
var batch coredata.TrustCenterDocumentAccesses
|
||||
if err := batch.LoadByTrustCenterAccessID(ctx, conn, scope, trustCenterAccessID, cursor); err != nil {
|
||||
return nil, fmt.Errorf("cannot load trust center document accesses: %w", err)
|
||||
func(ctx context.Context, cursor *page.Cursor[coredata.CompliancePortalDocumentAccessOrderField]) ([]*coredata.CompliancePortalDocumentAccess, error) {
|
||||
var batch coredata.CompliancePortalDocumentAccesses
|
||||
if err := batch.LoadByCompliancePortalAccessID(ctx, conn, scope, compliancePortalAccessID, cursor); err != nil {
|
||||
return nil, fmt.Errorf("cannot load compliance portal document accesses: %w", err)
|
||||
}
|
||||
|
||||
return batch, nil
|
||||
@@ -360,7 +360,7 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
|
||||
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
|
||||
}
|
||||
|
||||
@@ -401,16 +401,16 @@ func (s *Service) loadDocumentsReportsAndFilesFromAccesses(
|
||||
)
|
||||
}
|
||||
|
||||
if access.TrustCenterFileID != nil {
|
||||
file := &coredata.TrustCenterFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, *access.TrustCenterFileID); err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("cannot load trust center file: %w", err)
|
||||
if access.CompliancePortalFileID != nil {
|
||||
file := &coredata.CompliancePortalFile{}
|
||||
if err := file.LoadByID(ctx, conn, scope, *access.CompliancePortalFileID); err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("cannot load compliance portal file: %w", err)
|
||||
}
|
||||
|
||||
files = append(
|
||||
files,
|
||||
SlackMessageFile{
|
||||
ID: access.TrustCenterFileID.String(),
|
||||
ID: access.CompliancePortalFileID.String(),
|
||||
Name: file.Name,
|
||||
Category: file.Category,
|
||||
Status: access.Status.String(),
|
||||
|
||||
@@ -47,7 +47,7 @@ type ComplianceDocsResult struct {
|
||||
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)."`
|
||||
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."`
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ type (
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
|
||||
@@ -143,19 +143,19 @@ func newOrchestratorAgent(
|
||||
},
|
||||
{
|
||||
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,
|
||||
build: buildDataProcessingAgent,
|
||||
},
|
||||
{
|
||||
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,
|
||||
build: buildIncidentResponseAgent,
|
||||
},
|
||||
{
|
||||
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,
|
||||
build: buildBusinessContinuityAgent,
|
||||
},
|
||||
@@ -167,13 +167,13 @@ func newOrchestratorAgent(
|
||||
},
|
||||
{
|
||||
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,
|
||||
build: buildAIRiskAgent,
|
||||
},
|
||||
{
|
||||
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,
|
||||
build: buildRegulatoryComplianceAgent,
|
||||
},
|
||||
|
||||
@@ -336,13 +336,13 @@ type (
|
||||
// --- ThirdParty Comparison ---
|
||||
|
||||
AlternativeThirdParty struct {
|
||||
Name string `json:"name" jsonschema:"Alternative third_party name"`
|
||||
Website string `json:"website" jsonschema:"Alternative third_party website URL"`
|
||||
Certifications []string `json:"certifications" jsonschema:"Visible certifications"`
|
||||
TrustCenter bool `json:"trust_center" jsonschema:"Whether a trust center page was found"`
|
||||
PrivacyPolicy bool `json:"privacy_policy" jsonschema:"Whether a privacy policy was found"`
|
||||
CompanySize string `json:"company_size" jsonschema:"Estimated company size"`
|
||||
SecurityScore string `json:"security_score" jsonschema:"Quick security impression: Strong, Adequate, or Weak"`
|
||||
Name string `json:"name" jsonschema:"Alternative third_party name"`
|
||||
Website string `json:"website" jsonschema:"Alternative third_party website URL"`
|
||||
Certifications []string `json:"certifications" jsonschema:"Visible certifications"`
|
||||
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"`
|
||||
CompanySize string `json:"company_size" jsonschema:"Estimated company size"`
|
||||
SecurityScore string `json:"security_score" jsonschema:"Quick security impression: Strong, Adequate, or Weak"`
|
||||
}
|
||||
|
||||
ComparisonSummary struct {
|
||||
|
||||
@@ -28,17 +28,17 @@ import (
|
||||
)
|
||||
|
||||
type Document struct {
|
||||
ID gid.GID `json:"id"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
Status coredata.DocumentStatus `json:"status"`
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
|
||||
CurrentPublishedMajor *int `json:"currentPublishedMajor"`
|
||||
CurrentPublishedMinor *int `json:"currentPublishedMinor"`
|
||||
ArchivedAt *time.Time `json:"archivedAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
Status coredata.DocumentStatus `json:"status"`
|
||||
CompliancePortalVisibility coredata.CompliancePortalVisibility `json:"compliancePortalVisibility"`
|
||||
CurrentPublishedMajor *int `json:"currentPublishedMajor"`
|
||||
CurrentPublishedMinor *int `json:"currentPublishedMinor"`
|
||||
ArchivedAt *time.Time `json:"archivedAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type DocumentVersion struct {
|
||||
@@ -91,17 +91,17 @@ type DocumentApprovalDecision struct {
|
||||
|
||||
func NewDocument(d *coredata.Document) *Document {
|
||||
return &Document{
|
||||
ID: d.ID,
|
||||
OrganizationID: d.OrganizationID,
|
||||
Title: d.Title,
|
||||
DocumentType: d.DocumentType,
|
||||
Status: d.Status,
|
||||
TrustCenterVisibility: d.TrustCenterVisibility,
|
||||
CurrentPublishedMajor: d.CurrentPublishedMajor,
|
||||
CurrentPublishedMinor: d.CurrentPublishedMinor,
|
||||
ArchivedAt: d.ArchivedAt,
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
ID: d.ID,
|
||||
OrganizationID: d.OrganizationID,
|
||||
Title: d.Title,
|
||||
DocumentType: d.DocumentType,
|
||||
Status: d.Status,
|
||||
CompliancePortalVisibility: d.CompliancePortalVisibility,
|
||||
CurrentPublishedMajor: d.CurrentPublishedMajor,
|
||||
CurrentPublishedMinor: d.CurrentPublishedMinor,
|
||||
ArchivedAt: d.ArchivedAt,
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user