Clamp expires_in at API boundary (#60) #74

Merged
poslop merged 2 commits from issue-60-expiry-clamp into main 2026-09-09 14:26:07 +00:00
Showing only changes of commit bb5c4f0186 - Show all commits
+6
View File
@@ -40,6 +40,12 @@ func (a *apiServer) handleCreateCan(w http.ResponseWriter, r *http.Request) {
writeErr(w, 400, "invalid expires_in") writeErr(w, 400, "invalid expires_in")
return return
} }
// #60: clamp at the API boundary like the pastes API does -
// reject zero/negative and durations past the 1-year UI cap.
if !store.ValidExpiry(d) {
writeErr(w, 400, "expires_in must be between 1 minute and 1 year")
return
}
t := now + int64(d.Seconds()) t := now + int64(d.Seconds())
expiresAt = &t expiresAt = &t
} }