Repository navigation
Add a server-wide maximum file lifetime (GOKAPI_MAX_EXPIRY_SECONDS) - #440
D3strukt0r wants to merge 4 commits into
Conversation
b68142a to
b7434db
Compare
|
Thanks for working on this @D3strukt0r — we run Gokapi under a strict retention policy (no unlimited uploads, hard 90-day cap across all users) and currently have to enforce this via While reviewing the diff against our setup (and current 1. Capping File Request link expiry (
|
b7434db to
0593b11
Compare
|
Thanks a lot for the careful review, @daniele-doit, and for the snippets. I rebased the branch onto current 1. File request link expiry: done. With 2. Typed expiry days: done. 3. Clamping existing files: not in this PR. It rewrites existing users' data, and it would be a read-modify-save through 4. New commits on top of the rebased feature commit: a test for the file request save, the file request change, and the typed-days fix. All four CI tag sets pass. Checked in a browser against a local build with cc @Forceu |
Description
Closes #265. cc @Forceu, and @i0rt and @Str00pwafel, who asked for this in #265.
Adds
GOKAPI_MAX_EXPIRY_SECONDS, a server-wide maximum lifetime for files in seconds (0 or unset = no limit, behaviour unchanged). When it is set:ExpiryTooLong:/chunk/complete,/files/add,/files/modifyand/files/duplicate. Admins included.expiryDaysis refused, so the copy can't outlive the limit./info/configreportsMaxExpirySeconds. gokapi-cli uses it: when the server has a maximum and--expiry-daysisn't given, it leaves the expiry out so the server default applies instead of sending "unlimited". Without a maximum the CLI behaves as before.The check lives in one place,
fileupload.CheckMaxExpiry, withCapToMaxExpiryfor expiries the uploader didn't choose. The setting is environment-only likeGOKAPI_MAX_SIZE_GUESTUPLOAD, so there is no config or database change. Existing files keep their expiry when the maximum is switched on.This probably conflicts with your draft #405 in
routing.go,FileUpload.goandApi.go; happy to rebase onto it if you'd rather merge that first.Screenshots (
GOKAPI_MAX_EXPIRY_SECONDS=1209600, 14 days)Upload page: the expiry can't be switched off and is limited to 14 days.
Edit dialog: no "unlimited" option, the calendar ends at the maximum.
Type of Change
Technical Details
How Has This Been Tested?
GOKAPI_MAX_EXPIRY_SECONDS=3600and local storage: uploads withexpiryDays=0and30refused with 400, withoutexpiryDaysexpiring after one hour; editing to unlimited refused; duplicating an unlimited file withoutexpiryDaysrefused; a guest upload through a file request expires after one hour; gokapi-cli without--expiry-daysworks; admin upload page and edit dialog checked in Chrome (also with a 14-day maximum, see screenshots). With the variable unset everything behaves as before (unlimited uploads, 14-day default, unlimited guest uploads). File requests (added after review): the dialog locks the expiry on and caps the calendar at the maximum;/uploadrequest/saverefuses unlimited and over-limit expiries with 400ExpiryTooLong, and a request saved without an expiry gets 14 days capped to the maximum. A typed expiry above the maximum is clamped before the upload starts.go test ./... -parallel 8with the CI tag setstest,awsmock,test,noaws,test,noaws,integrationandtest,awstest, all passing (13 new tests each).golang:1.27, Go 1.27.4 as ingo.mod) on macOSChecklist