Repository navigation
fix(files): support a fully private S3 media bucket - #287
Merged
Merged
Conversation
- Drop the 'public' visibility from Utils::urlToStorefrontFile: a bucket with BucketOwnerEnforced rejects any PUT carrying an ACL, so put() returned false. - Add File::signStoredUrl()/s3KeyFromUrl(): turn absolute URLs stored as strings (legacy unsigned bucket URLs, expired signed URLs) back into a key and re-sign. - Re-sign template builder image src at render time. - Cache signed URLs for 60 of their 120 minutes so every URL handed out has at least an hour left; cut Extension icon_url cache from 24h to 30m.
This was referenced Oct 6, 2026
fix(files): store signatures without a public ACL; re-sign stored avatar URLs
fleetbase/fleetops#353
Merged
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #287 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 7931 7947 +16
===========================================
Files 438 438
Lines 25665 25693 +28
===========================================
+ Hits 25665 25693 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Lets Fleetbase run against an S3 bucket that is fully private: no public-read bucket policy,
BlockPublicAcls/RestrictPublicBucketson, andObjectOwnership=BucketOwnerEnforced. The app already serves S3/GCS files through presigned URLs (File::getUrlAttribute()→temporaryUrl()). A few paths still assumed a public bucket:'public'visibility, i.e. apublic-readACL. A bucket with BucketOwnerEnforced rejects any PUT that carries an ACL, and Laravel'sput()returnedfalsewithout an error, so the object was never stored;Self-hosters on
local/publicdisks are unaffected.Changes
Utils::urlToStorefrontFile: upload without'public'visibility.File::signStoredUrl()/File::s3KeyFromUrl(): recognise an absolute URL that points into the configureds3bucket (virtual-hosted, legacys3-region, path-style, or the disk'surl), strip any old query string and sign the key again. Every other value passes through unchanged: other buckets, other hosts, UUIDs and relative values.TemplateRenderService: re-signs template-builder imagesrcat render time.Extension::icon_urlcache cut from 24 h to 30 min. It was caching a 2-hour signed URL for a day.Companion PRs: fleetbase/fleetops#353 · fleetbase/storefront#112
Making a bucket private (operators)
services.awskeys) hass3:GetObjecton the bucket. Presigned URLs carry that identity's permissions.Principal: *s3:GetObjectstatement, then turn on all four Block Public Access settings.Known follow-ups (not policy-dependent)
These break once a signed URL expires, whether or not the bucket is public:
product_image_url, entitymeta.image_url, campaign notification payloads, AI task attachments, rich-text<img>HTML);avatar_urlback on save.Branding and logos may warrant a deliberately public prefix or a CDN path with a long-lived URL.
Tests
FileModelTestcovers key extraction for every URL form, rejection of lookalike hosts and other buckets, re-signing with per-key caching, and pass-through for other values. Verified via CI.