Get rid of old trust-auth config
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -44,7 +44,6 @@ type (
|
||||
NDAFileID *gid.GID `db:"nda_file_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
LastTokenExpiresAt *time.Time `db:"last_token_expires_at"`
|
||||
}
|
||||
|
||||
TrustCenterAccesses []*TrustCenterAccess
|
||||
@@ -92,8 +91,7 @@ SELECT
|
||||
has_accepted_non_disclosure_agreement_metadata,
|
||||
nda_file_id,
|
||||
created_at,
|
||||
updated_at,
|
||||
last_token_expires_at
|
||||
updated_at
|
||||
FROM
|
||||
trust_center_accesses
|
||||
WHERE
|
||||
@@ -146,8 +144,7 @@ SELECT
|
||||
has_accepted_non_disclosure_agreement_metadata,
|
||||
nda_file_id,
|
||||
created_at,
|
||||
updated_at,
|
||||
last_token_expires_at
|
||||
updated_at
|
||||
FROM
|
||||
trust_center_accesses
|
||||
WHERE
|
||||
@@ -254,8 +251,7 @@ UPDATE trust_center_accesses SET
|
||||
updated_at = @updated_at,
|
||||
has_accepted_non_disclosure_agreement = @has_accepted_non_disclosure_agreement,
|
||||
has_accepted_non_disclosure_agreement_metadata = @has_accepted_non_disclosure_agreement_metadata,
|
||||
nda_file_id = @nda_file_id,
|
||||
last_token_expires_at = @last_token_expires_at
|
||||
nda_file_id = @nda_file_id
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
@@ -270,8 +266,7 @@ WHERE
|
||||
"updated_at": tca.UpdatedAt,
|
||||
"has_accepted_non_disclosure_agreement": tca.HasAcceptedNonDisclosureAgreement,
|
||||
"has_accepted_non_disclosure_agreement_metadata": tca.HasAcceptedNonDisclosureAgreementMetadata,
|
||||
"nda_file_id": tca.NDAFileID,
|
||||
"last_token_expires_at": tca.LastTokenExpiresAt,
|
||||
"nda_file_id": tca.NDAFileID,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -330,8 +325,7 @@ SELECT
|
||||
has_accepted_non_disclosure_agreement_metadata,
|
||||
nda_file_id,
|
||||
created_at,
|
||||
updated_at,
|
||||
last_token_expires_at
|
||||
updated_at
|
||||
FROM
|
||||
trust_center_accesses
|
||||
WHERE
|
||||
|
||||
@@ -48,12 +48,6 @@ type ExportService interface {
|
||||
}
|
||||
|
||||
type (
|
||||
TrustConfig struct {
|
||||
TokenSecret string
|
||||
TokenDuration time.Duration
|
||||
TokenType string
|
||||
}
|
||||
|
||||
Service struct {
|
||||
pg *pg.Client
|
||||
s3 *s3.Client
|
||||
@@ -61,7 +55,6 @@ type (
|
||||
encryptionKey cipher.EncryptionKey
|
||||
baseURL string
|
||||
tokenSecret string
|
||||
trustConfig TrustConfig
|
||||
agentConfig agents.Config
|
||||
html2pdfConverter *html2pdf.Converter
|
||||
acmeService *certmanager.ACMEService
|
||||
@@ -78,7 +71,6 @@ type (
|
||||
scope coredata.Scoper
|
||||
baseURL string
|
||||
tokenSecret string
|
||||
trustConfig TrustConfig
|
||||
agent *agents.Agent
|
||||
fileManager *filemanager.Service
|
||||
Frameworks *FrameworkService
|
||||
@@ -129,7 +121,6 @@ func NewService(
|
||||
bucket string,
|
||||
baseURL string,
|
||||
tokenSecret string,
|
||||
trustConfig TrustConfig,
|
||||
agentConfig agents.Config,
|
||||
html2pdfConverter *html2pdf.Converter,
|
||||
acmeService *certmanager.ACMEService,
|
||||
@@ -151,7 +142,6 @@ func NewService(
|
||||
encryptionKey: encryptionKey,
|
||||
baseURL: baseURL,
|
||||
tokenSecret: tokenSecret,
|
||||
trustConfig: trustConfig,
|
||||
agentConfig: agentConfig,
|
||||
html2pdfConverter: html2pdfConverter,
|
||||
acmeService: acmeService,
|
||||
@@ -172,7 +162,6 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
baseURL: s.baseURL,
|
||||
scope: coredata.NewScope(tenantID),
|
||||
tokenSecret: s.tokenSecret,
|
||||
trustConfig: s.trustConfig,
|
||||
agent: agents.NewAgent(nil, s.agentConfig),
|
||||
fileManager: s.fileManager,
|
||||
}
|
||||
|
||||
@@ -443,8 +443,6 @@ func (s TrustCenterAccessService) sendAccessEmail(ctx context.Context, tx pg.Con
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
expiresAt := now.Add(s.svc.trustConfig.TokenDuration)
|
||||
access.LastTokenExpiresAt = &expiresAt
|
||||
access.UpdatedAt = now
|
||||
|
||||
if err := access.Update(ctx, tx, s.svc.scope); err != nil {
|
||||
@@ -467,7 +465,6 @@ func (s TrustCenterAccessService) sendTrustCenterAccessEmail(
|
||||
name,
|
||||
companyName,
|
||||
accessURL,
|
||||
s.svc.trustConfig.TokenDuration,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot render trust center access email: %w", err)
|
||||
|
||||
@@ -73,7 +73,6 @@ type (
|
||||
Pg pgConfig `json:"pg"`
|
||||
Api apiConfig `json:"api"`
|
||||
Auth authConfig `json:"auth"`
|
||||
TrustAuth trustAuthConfig `json:"trust-auth"`
|
||||
TrustCenter trustCenterConfig `json:"trust-center"`
|
||||
AWS awsConfig `json:"aws"`
|
||||
Notifications notificationsConfig `json:"notifications"`
|
||||
@@ -133,16 +132,6 @@ func New() *Implm {
|
||||
DomainVerificationResolverAddr: "8.8.8.8:53",
|
||||
},
|
||||
},
|
||||
TrustAuth: trustAuthConfig{
|
||||
CookieName: "TCT",
|
||||
CookieDomain: "localhost",
|
||||
CookieDuration: 24,
|
||||
TokenDuration: 720,
|
||||
ReportURLDuration: 15,
|
||||
TokenSecret: "this-is-a-secure-secret-for-trust-token-signing-at-least-32-bytes",
|
||||
Scope: "trust_center_readonly",
|
||||
TokenType: "trust_center_access",
|
||||
},
|
||||
TrustCenter: trustCenterConfig{
|
||||
HTTPAddr: ":80",
|
||||
HTTPSAddr: ":443",
|
||||
@@ -220,12 +209,6 @@ func (impl *Implm) Run(
|
||||
return fmt.Errorf("cannot get cookie secret bytes: %w", err)
|
||||
}
|
||||
|
||||
_, err = impl.cfg.TrustAuth.GetTokenSecretBytes()
|
||||
if err != nil {
|
||||
rootSpan.RecordError(err)
|
||||
return fmt.Errorf("cannot get trust auth token secret bytes: %w", err)
|
||||
}
|
||||
|
||||
awsConfig := awsconfig.NewConfig(
|
||||
l,
|
||||
httpclient.DefaultPooledClient(
|
||||
@@ -274,12 +257,6 @@ func (impl *Implm) Run(
|
||||
ModelName: impl.cfg.OpenAI.ModelName,
|
||||
}
|
||||
|
||||
trustConfig := probo.TrustConfig{
|
||||
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
||||
TokenDuration: time.Duration(impl.cfg.TrustAuth.TokenDuration) * time.Hour,
|
||||
TokenType: impl.cfg.TrustAuth.TokenType,
|
||||
}
|
||||
|
||||
agent := agents.NewAgent(l.Named("agent"), agentConfig)
|
||||
|
||||
fileManagerService := filemanager.NewService(s3Client)
|
||||
@@ -383,7 +360,6 @@ func (impl *Implm) Run(
|
||||
impl.cfg.AWS.Bucket,
|
||||
impl.cfg.BaseURL.String(),
|
||||
impl.cfg.Auth.Cookie.Secret,
|
||||
trustConfig,
|
||||
agentConfig,
|
||||
html2pdfConverter,
|
||||
acmeService,
|
||||
@@ -402,17 +378,11 @@ func (impl *Implm) Run(
|
||||
impl.cfg.AWS.Bucket,
|
||||
impl.cfg.BaseURL.String(),
|
||||
impl.cfg.EncryptionKey,
|
||||
impl.cfg.TrustAuth.TokenSecret,
|
||||
impl.cfg.GetSlackSigningSecret(),
|
||||
iamService,
|
||||
html2pdfConverter,
|
||||
fileManagerService,
|
||||
l,
|
||||
trust.TrustConfig{
|
||||
TokenSecret: impl.cfg.TrustAuth.TokenSecret,
|
||||
TokenDuration: time.Duration(impl.cfg.TrustAuth.TokenDuration) * time.Hour,
|
||||
TokenType: impl.cfg.TrustAuth.TokenType,
|
||||
},
|
||||
slackService,
|
||||
)
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ func NewTrustCenterAccess(tca *coredata.TrustCenterAccess) *TrustCenterAccess {
|
||||
HasAcceptedNonDisclosureAgreement: tca.HasAcceptedNonDisclosureAgreement,
|
||||
CreatedAt: tca.CreatedAt,
|
||||
UpdatedAt: tca.UpdatedAt,
|
||||
LastTokenExpiresAt: tca.LastTokenExpiresAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
"go.gearno.de/kit/log"
|
||||
@@ -35,12 +34,6 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
TrustConfig struct {
|
||||
TokenSecret string
|
||||
TokenDuration time.Duration
|
||||
TokenType string
|
||||
}
|
||||
|
||||
Service struct {
|
||||
pg *pg.Client
|
||||
s3 *s3.Client
|
||||
@@ -54,7 +47,6 @@ type (
|
||||
html2pdfConverter *html2pdf.Converter
|
||||
fileManager *filemanager.Service
|
||||
logger *log.Logger
|
||||
trustConfig TrustConfig
|
||||
slack *slack.Service
|
||||
}
|
||||
|
||||
@@ -65,13 +57,11 @@ type (
|
||||
scope coredata.Scoper
|
||||
proboSvc *probo.Service
|
||||
encryptionKey cipher.EncryptionKey
|
||||
tokenSecret string
|
||||
baseURL string
|
||||
iam *iam.Service
|
||||
html2pdfConverter *html2pdf.Converter
|
||||
fileManager *filemanager.Service
|
||||
logger *log.Logger
|
||||
trustConfig TrustConfig
|
||||
TrustCenters *TrustCenterService
|
||||
Documents *DocumentService
|
||||
Audits *AuditService
|
||||
@@ -92,13 +82,11 @@ func NewService(
|
||||
bucket string,
|
||||
baseURL string,
|
||||
encryptionKey cipher.EncryptionKey,
|
||||
tokenSecret string,
|
||||
slackSigningSecret string,
|
||||
iam *iam.Service,
|
||||
html2pdfConverter *html2pdf.Converter,
|
||||
fileManagerService *filemanager.Service,
|
||||
logger *log.Logger,
|
||||
trustConfig TrustConfig,
|
||||
slack *slack.Service,
|
||||
) *Service {
|
||||
return &Service{
|
||||
@@ -106,14 +94,12 @@ func NewService(
|
||||
s3: s3Client,
|
||||
bucket: bucket,
|
||||
encryptionKey: encryptionKey,
|
||||
tokenSecret: tokenSecret,
|
||||
slackSigningSecret: slackSigningSecret,
|
||||
baseURL: baseURL,
|
||||
iam: iam,
|
||||
html2pdfConverter: html2pdfConverter,
|
||||
fileManager: fileManagerService,
|
||||
logger: logger,
|
||||
trustConfig: trustConfig,
|
||||
slack: slack,
|
||||
}
|
||||
}
|
||||
@@ -126,13 +112,11 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
scope: coredata.NewScope(tenantID),
|
||||
proboSvc: s.proboSvc,
|
||||
encryptionKey: s.encryptionKey,
|
||||
tokenSecret: s.tokenSecret,
|
||||
baseURL: s.baseURL,
|
||||
iam: s.iam,
|
||||
html2pdfConverter: s.html2pdfConverter,
|
||||
fileManager: s.fileManager,
|
||||
logger: s.logger,
|
||||
trustConfig: s.trustConfig,
|
||||
}
|
||||
|
||||
tenantService.TrustCenters = &TrustCenterService{svc: tenantService}
|
||||
|
||||
@@ -485,8 +485,6 @@ func (s *TrustCenterAccessService) sendAccessEmail(ctx context.Context, tx pg.Co
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
expiresAt := now.Add(s.svc.trustConfig.TokenDuration)
|
||||
access.LastTokenExpiresAt = &expiresAt
|
||||
access.UpdatedAt = now
|
||||
|
||||
if err := access.Update(ctx, tx, s.svc.scope); err != nil {
|
||||
@@ -509,7 +507,6 @@ func (s *TrustCenterAccessService) sendTrustCenterAccessEmail(
|
||||
name,
|
||||
companyName,
|
||||
accessURL,
|
||||
s.svc.trustConfig.TokenDuration,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot render trust center access email: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user