fix(19.3-06): refuse protected uploads into a public_url bucket (WR-07)
- attach.Store returns attach.ErrProtectedNeedsPrivateBucket for an is_public false upload while storage.uploads.public_url is set, before any blob is written - OpenBucket's public_url line becomes a warning naming the refusal
This commit is contained in:
@@ -115,7 +115,8 @@ func checkS3Driver(bucketURL string) error {
|
||||
// binary built with S3BuildTag) and records
|
||||
// storage.uploads.public_path_prefix and storage.uploads.public_url. An
|
||||
// empty bucket_url or a malformed public_url fails boot; a set public_url
|
||||
// logs one info line saying the bucket behind it must hold only public files.
|
||||
// logs one warning saying the bucket behind it must hold only public files
|
||||
// and that Store refuses protected uploads (ErrProtectedNeedsPrivateBucket).
|
||||
func OpenBucket(ctx context.Context, cfg *compass.Config) (*blob.Bucket, error) {
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("attach: config is nil")
|
||||
@@ -149,8 +150,9 @@ func OpenBucket(ctx context.Context, cfg *compass.Config) (*blob.Bucket, error)
|
||||
return bucket, nil
|
||||
}
|
||||
setPublicURLBase(publicURL.String())
|
||||
slog.Default().InfoContext(ctx, "attach: storage.uploads.public_url is set; every file and thumbnail URL points at this host, "+
|
||||
"which serves any key without the is_public check, so the bucket behind it must hold only public files",
|
||||
slog.Default().WarnContext(ctx, "attach: storage.uploads.public_url is set; every file and thumbnail URL points at this host, "+
|
||||
"which serves any key without the is_public check, so the bucket behind it must hold only public files: "+
|
||||
"protected (is_public false) uploads are refused",
|
||||
slog.String("host", publicURL.Host))
|
||||
return bucket, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user