fleet/server/datastore/s3/software_installer.go
Victor Lyuboslavsky 68b7cf9141
Added signed URLs (#25197)
For #24869 

This subtask contains code to sign the CloudFront software installer and
bootstrap package URL using AWS SDK URL signer.
It works with the current bootstrap package delivery. For software
installers, fleetd will need to be modified to take advantage of this
URL in a future subtask (which will also include updated API contributor
docs).

My article on signed URLs, for context:
https://victoronsoftware.com/posts/cloudfront-signed-urls/

# Checklist for submitter

- [x] Added/updated automated tests
- [x] Manual QA for all new/changed functionality
2025-01-09 12:56:54 -06:00

45 lines
1.2 KiB
Go

package s3
import (
"github.com/fleetdm/fleet/v4/server/config"
)
const softwareInstallersPrefix = "software-installers"
type SoftwareInstallerStore struct {
*commonFileStore
}
// NewSoftwareInstallerStore creates a new instance with the given S3 config.
func NewSoftwareInstallerStore(config config.S3Config) (*SoftwareInstallerStore, error) {
s3store, err := newS3store(config.SoftwareInstallersToInternalCfg())
if err != nil {
return nil, err
}
return &SoftwareInstallerStore{
&commonFileStore{
s3store: s3store,
pathPrefix: softwareInstallersPrefix,
fileLabel: "software installer",
},
}, nil
}
// NewTestSoftwareInstallerStore is used in tests.
func NewTestSoftwareInstallerStore(conf config.S3Config) (*SoftwareInstallerStore, error) {
store := &s3store{
bucket: "test-bucket",
cloudFrontConfig: &config.S3CloudFrontConfig{
BaseURL: conf.SoftwareInstallersCloudFrontURL,
SigningPublicKeyID: conf.SoftwareInstallersCloudFrontURLSigningPublicKeyID,
Signer: conf.SoftwareInstallersCloudFrontSigner,
},
}
return &SoftwareInstallerStore{
&commonFileStore{
s3store: store,
pathPrefix: softwareInstallersPrefix,
fileLabel: "software installer",
},
}, nil
}