diff --git a/pkg/complianceportal/visitor/errors.go b/pkg/complianceportal/visitor/errors.go index ca539acfb..26a25d184 100644 --- a/pkg/complianceportal/visitor/errors.go +++ b/pkg/complianceportal/visitor/errors.go @@ -30,7 +30,6 @@ var ( ErrUserNotFound = errors.New("user not found") ErrUserInactive = errors.New("user inactive") ErrDocumentAccessNotFound = errors.New("document access not found") - ErrNDAFileNotFound = errors.New("NDA file not found") ErrDocumentNotFound = errors.New("document not found") ErrDocumentNotVisible = errors.New("document not visible") ErrReportNotFound = errors.New("report not found") diff --git a/pkg/complianceportal/visitor/framework_service.go b/pkg/complianceportal/visitor/framework_service.go index 12b95843f..4da6b04e9 100644 --- a/pkg/complianceportal/visitor/framework_service.go +++ b/pkg/complianceportal/visitor/framework_service.go @@ -23,7 +23,6 @@ package visitor import ( "context" "fmt" - "time" "go.gearno.de/kit/pg" "go.probo.inc/probo/pkg/coredata" @@ -54,89 +53,3 @@ func (s *Service) GetFramework( return framework, nil } - -func (s *Service) GenerateFrameworkLightLogoURL( - ctx context.Context, - scope coredata.Scoper, - frameworkID gid.GID, - expiresIn time.Duration, -) (*string, error) { - file := &coredata.File{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - framework := &coredata.Framework{} - if err := framework.LoadByID(ctx, conn, scope, frameworkID); err != nil { - return fmt.Errorf("cannot load framework: %w", err) - } - - if framework.LightLogoFileID == nil { - return nil - } - - if err := file.LoadByID(ctx, conn, scope, *framework.LightLogoFileID); err != nil { - return fmt.Errorf("cannot load file: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - if file.FileKey == "" { - return nil, nil - } - - presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn) - if err != nil { - return nil, fmt.Errorf("cannot generate file URL: %w", err) - } - - return &presignedURL, nil -} - -func (s *Service) GenerateFrameworkDarkLogoURL( - ctx context.Context, - scope coredata.Scoper, - frameworkID gid.GID, - expiresIn time.Duration, -) (*string, error) { - file := &coredata.File{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - framework := &coredata.Framework{} - if err := framework.LoadByID(ctx, conn, scope, frameworkID); err != nil { - return fmt.Errorf("cannot load framework: %w", err) - } - - if framework.DarkLogoFileID == nil { - return nil - } - - if err := file.LoadByID(ctx, conn, scope, *framework.DarkLogoFileID); err != nil { - return fmt.Errorf("cannot load file: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - if file.FileKey == "" { - return nil, nil - } - - presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn) - if err != nil { - return nil, fmt.Errorf("cannot generate file URL: %w", err) - } - - return &presignedURL, nil -} diff --git a/pkg/complianceportal/visitor/organization_service.go b/pkg/complianceportal/visitor/organization_service.go deleted file mode 100644 index 7db9c917e..000000000 --- a/pkg/complianceportal/visitor/organization_service.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2025-2026 Probo Inc . -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -package visitor - -import ( - "context" - "fmt" - "net/url" - "time" - - "github.com/aws/aws-sdk-go-v2/service/s3" - "go.gearno.de/kit/pg" - "go.probo.inc/probo/pkg/coredata" - "go.probo.inc/probo/pkg/gid" -) - -func (s *Service) GetOrganization( - ctx context.Context, - scope coredata.Scoper, - organizationID gid.GID, -) (*coredata.Organization, error) { - organization := &coredata.Organization{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - err := organization.LoadByID( - ctx, - conn, - scope, - organizationID, - ) - if err != nil { - return fmt.Errorf("cannot load organization: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - return organization, nil -} - -func (s *Service) GenerateOrganizationLogoURL( - ctx context.Context, - scope coredata.Scoper, - organizationID gid.GID, - expiresIn time.Duration, -) (*string, error) { - organization, err := s.GetOrganization(ctx, scope, organizationID) - if err != nil { - return nil, fmt.Errorf("cannot get organization: %w", err) - } - - if organization.LogoFileID == nil { - return nil, nil - } - - file := &coredata.File{} - - err = s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - return file.LoadByID(ctx, conn, scope, *organization.LogoFileID) - }, - ) - if err != nil { - return nil, fmt.Errorf("cannot load file: %w", err) - } - - presignClient := s3.NewPresignClient(s.s3) - - encodedFilename := url.QueryEscape(file.FileName) - contentDisposition := fmt.Sprintf("attachment; filename=\"%s\"; filename*=UTF-8''%s", - encodedFilename, encodedFilename) - - presignedReq, err := presignClient.PresignGetObject( - ctx, - &s3.GetObjectInput{ - Bucket: new(s.bucket), - Key: new(file.FileKey), - ResponseCacheControl: new("max-age=3600, public"), - ResponseContentDisposition: new(contentDisposition), - }, func(opts *s3.PresignOptions) { - opts.Expires = expiresIn - }, - ) - if err != nil { - return nil, fmt.Errorf("cannot presign GetObject request: %w", err) - } - - return &presignedReq.URL, nil -} diff --git a/pkg/complianceportal/visitor/portal_reference_service.go b/pkg/complianceportal/visitor/portal_reference_service.go index 88498ddd2..ec0ff0dc1 100644 --- a/pkg/complianceportal/visitor/portal_reference_service.go +++ b/pkg/complianceportal/visitor/portal_reference_service.go @@ -58,31 +58,6 @@ func (s *Service) ListPortalReferencesForPortalID( return page.NewPage(references, cursor), nil } -func (s *Service) GeneratePortalReferenceLogoURL( - ctx context.Context, - scope coredata.Scoper, - referenceID gid.GID, -) (string, error) { - reference := &coredata.TrustCenterReference{} - - err := s.pg.WithTx( - ctx, - func(ctx context.Context, tx pg.Tx) error { - return reference.LoadByID(ctx, tx, scope, referenceID) - }, - ) - if err != nil { - return "", fmt.Errorf("cannot load compliance page reference: %w", err) - } - - file, err := s.fileManager.GetPublicFile(ctx, reference.LogoFileID) - if err != nil { - return "", err - } - - return s.fileManager.GenerateFileURL(file), nil -} - func (s *Service) GetPortalReference( ctx context.Context, scope coredata.Scoper, diff --git a/pkg/complianceportal/visitor/portal_service.go b/pkg/complianceportal/visitor/portal_service.go index 23d02c2a5..364daf49b 100644 --- a/pkg/complianceportal/visitor/portal_service.go +++ b/pkg/complianceportal/visitor/portal_service.go @@ -57,31 +57,6 @@ func (s *Service) GetPortal( return compliancePage, nil } -func (s *Service) GetPortalByOrganizationID( - ctx context.Context, - scope coredata.Scoper, - organizationID gid.GID, -) (*coredata.TrustCenter, error) { - compliancePage := &coredata.TrustCenter{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - err := compliancePage.LoadByOrganizationID(ctx, conn, scope, organizationID) - if err != nil { - return fmt.Errorf("cannot load compliance page: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - return compliancePage, nil -} - func (s *Service) GetPortalNDAFile( ctx context.Context, scope coredata.Scoper, @@ -156,100 +131,6 @@ func (s *Service) GeneratePortalNDAFileURL( return presignedURL, nil } -func (s *Service) GeneratePortalLogoURL( - ctx context.Context, - scope coredata.Scoper, - compliancePageID gid.GID, - expiresIn time.Duration, -) (*string, error) { - file := &coredata.File{} - compliancePage := &coredata.TrustCenter{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { - return fmt.Errorf("cannot load compliance page: %w", err) - } - - if compliancePage.LogoFileID == nil { - return nil - } - - if err := file.LoadByID(ctx, conn, scope, *compliancePage.LogoFileID); err != nil { - return fmt.Errorf("cannot load file: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - if compliancePage.LogoFileID == nil { - return nil, nil - } - - if file.FileKey == "" { - return nil, nil - } - - presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn) - if err != nil { - return nil, fmt.Errorf("cannot generate file URL: %w", err) - } - - return &presignedURL, nil -} - -func (s *Service) GeneratePortalDarkLogoURL( - ctx context.Context, - scope coredata.Scoper, - compliancePageID gid.GID, - expiresIn time.Duration, -) (*string, error) { - file := &coredata.File{} - compliancePage := &coredata.TrustCenter{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { - return fmt.Errorf("cannot load compliance page: %w", err) - } - - if compliancePage.DarkLogoFileID == nil { - return nil - } - - if err := file.LoadByID(ctx, conn, scope, *compliancePage.DarkLogoFileID); err != nil { - return fmt.Errorf("cannot load file: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - if compliancePage.DarkLogoFileID == nil { - return nil, nil - } - - if file.FileKey == "" { - return nil, nil - } - - presignedURL, err := s.fileManager.GeneratePresignedURL(ctx, file, expiresIn) - if err != nil { - return nil, fmt.Errorf("cannot generate file URL: %w", err) - } - - return &presignedURL, nil -} - func (s *Service) GetPortalEmailPresenterConfig( ctx context.Context, scope coredata.Scoper, @@ -321,37 +202,3 @@ func (s *Service) GetPortalEmailPresenterConfig( return emailPresenterCfg, nil } - -func (s *Service) GetPortalMailingList( - ctx context.Context, - scope coredata.Scoper, - compliancePageID gid.GID, -) (*coredata.MailingList, error) { - var mailingList *coredata.MailingList - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - compliancePage := &coredata.TrustCenter{} - if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { - return fmt.Errorf("cannot load compliance page: %w", err) - } - - if compliancePage.MailingListID == nil { - return nil - } - - mailingList = &coredata.MailingList{} - if err := mailingList.LoadByID(ctx, conn, scope, *compliancePage.MailingListID); err != nil { - return fmt.Errorf("cannot load mailing list: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - return mailingList, nil -} diff --git a/pkg/complianceportal/visitor/report_service.go b/pkg/complianceportal/visitor/report_service.go index f3d778860..e635c6162 100644 --- a/pkg/complianceportal/visitor/report_service.go +++ b/pkg/complianceportal/visitor/report_service.go @@ -25,7 +25,6 @@ import ( "errors" "fmt" "io" - "time" "github.com/aws/aws-sdk-go-v2/service/s3" "go.gearno.de/kit/pg" @@ -88,38 +87,6 @@ func (s *Service) loadReportByID( return file, nil } -func (s *Service) GenerateReportDownloadURL( - ctx context.Context, - scope coredata.Scoper, - fileID gid.GID, - expiresIn time.Duration, -) (*string, error) { - file, err := s.loadReportByID(ctx, scope, fileID) - if err != nil { - return nil, fmt.Errorf("cannot get file: %w", err) - } - - presignClient := s3.NewPresignClient(s.s3) - - presignedReq, err := presignClient.PresignGetObject( - ctx, - &s3.GetObjectInput{ - Bucket: new(s.bucket), - Key: new(file.FileKey), - ResponseCacheControl: new("max-age=3600, public"), - ResponseContentType: new(file.MimeType), - ResponseContentDisposition: new(fmt.Sprintf("attachment; filename=\"%s\"", file.FileName)), - }, func(opts *s3.PresignOptions) { - opts.Expires = expiresIn - }, - ) - if err != nil { - return nil, fmt.Errorf("cannot presign GetObject request: %w", err) - } - - return &presignedReq.URL, nil -} - func (s *Service) ExportReportPDF( ctx context.Context, scope coredata.Scoper, diff --git a/pkg/complianceportal/visitor/service.go b/pkg/complianceportal/visitor/service.go index d3429ab94..e6fc22dfe 100644 --- a/pkg/complianceportal/visitor/service.go +++ b/pkg/complianceportal/visitor/service.go @@ -36,7 +36,6 @@ import ( "go.probo.inc/probo/pkg/filemanager" "go.probo.inc/probo/pkg/gid" "go.probo.inc/probo/pkg/html2pdf" - "go.probo.inc/probo/pkg/iam" "go.probo.inc/probo/pkg/resourcealias" "go.probo.inc/probo/pkg/slack" ) @@ -48,20 +47,17 @@ type ( // public read operations for the compliance page and its related resources as // methods on a single type. Service struct { - pg *pg.Client - s3 *s3.Client - bucket string - slackSigningSecret string - baseURL string - baseDomain string - iam *iam.Service - esign *esign.Service - html2pdfConverter *html2pdf.Converter - fileManager *filemanager.Service - logger *log.Logger - slack *slack.Service - resourceAlias *resourcealias.Service - management *management.Service + pg *pg.Client + s3 *s3.Client + bucket string + baseURL string + esign *esign.Service + html2pdfConverter *html2pdf.Converter + fileManager *filemanager.Service + logger *log.Logger + slack *slack.Service + resourceAlias *resourcealias.Service + management *management.Service } ) @@ -70,9 +66,6 @@ func NewService( s3Client *s3.Client, bucket string, baseURL string, - baseDomain string, - slackSigningSecret string, - iam *iam.Service, esignSvc *esign.Service, html2pdfConverter *html2pdf.Converter, fileManagerService *filemanager.Service, @@ -82,20 +75,17 @@ func NewService( managementSvc *management.Service, ) *Service { svc := &Service{ - pg: pgClient, - s3: s3Client, - bucket: bucket, - slackSigningSecret: slackSigningSecret, - baseURL: baseURL, - baseDomain: baseDomain, - iam: iam, - esign: esignSvc, - html2pdfConverter: html2pdfConverter, - fileManager: fileManagerService, - logger: logger, - slack: slack, - resourceAlias: resourceAliasSvc, - management: managementSvc, + pg: pgClient, + s3: s3Client, + bucket: bucket, + baseURL: baseURL, + esign: esignSvc, + html2pdfConverter: html2pdfConverter, + fileManager: fileManagerService, + logger: logger, + slack: slack, + resourceAlias: resourceAliasSvc, + management: managementSvc, } return svc @@ -129,34 +119,6 @@ func (s *Service) GetPortalByID( return compliancePage, nil } -func (s *Service) GetPortalBySlug( - ctx context.Context, - slug string, -) (*coredata.TrustCenter, error) { - compliancePage := &coredata.TrustCenter{} - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - err := compliancePage.LoadBySlug(ctx, conn, slug) - if err != nil { - if errors.Is(err, coredata.ErrResourceNotFound) { - return ErrPageNotFound - } - - return fmt.Errorf("cannot load compliance page: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - return compliancePage, nil -} - // GetEffectiveCanonicalHost returns the host a compliance page should be // served under. It prefers the primary domain when its certificate is active, // and otherwise falls back to the managed probopage subdomain. An empty string @@ -296,46 +258,6 @@ func (s *Service) GetPortalMembership(ctx context.Context, compliancePageID gid. return membership, nil } -func (s *Service) GetPortalNDAFileByID( - ctx context.Context, - compliancePageID gid.GID, -) (*coredata.File, error) { - var ( - file *coredata.File - scope = coredata.NewScopeFromObjectID(compliancePageID) - ) - - err := s.pg.WithConn( - ctx, - func(ctx context.Context, conn pg.Querier) error { - compliancePage := &coredata.TrustCenter{} - if err := compliancePage.LoadByID(ctx, conn, scope, compliancePageID); err != nil { - return fmt.Errorf("cannot load compliance page: %w", err) - } - - if compliancePage.NonDisclosureAgreementFileID == nil { - return ErrNDAFileNotFound - } - - file = &coredata.File{} - if err := file.LoadByID(ctx, conn, scope, *compliancePage.NonDisclosureAgreementFileID); err != nil { - if errors.Is(err, coredata.ErrResourceNotFound) { - return ErrNDAFileNotFound - } - - return fmt.Errorf("cannot load file: %w", err) - } - - return nil - }, - ) - if err != nil { - return nil, err - } - - return file, nil -} - func (s *Service) ProvisionPortalMember( ctx context.Context, compliancePageID gid.GID, diff --git a/pkg/probod/probod.go b/pkg/probod/probod.go index b1e8b4d1b..53769fdd3 100644 --- a/pkg/probod/probod.go +++ b/pkg/probod/probod.go @@ -676,9 +676,6 @@ func (impl *Implm) Run( s3Client, impl.cfg.AWS.Bucket, baseURL.String(), - impl.cfg.TrustCenter.BaseDomain, - impl.cfg.GetSlackSigningSecret(), - iamService, esignService, html2pdfConverter, fileManagerService,