forgejo/services
Gergely Nagy 67fa52dedb
feat(quota): Quota enforcement
The previous commit laid out the foundation of the quota engine, this
one builds on top of it, and implements the actual enforcement.

Enforcement happens at the route decoration level, whenever possible. In
case of the API, when over quota, a 413 error is returned, with an
appropriate JSON payload. In case of web routes, a 413 HTML page is
rendered with similar information.

This implementation is for a **soft quota**: quota usage is checked
before an operation is to be performed, and the operation is *only*
denied if the user is already over quota. This makes it possible to go
over quota, but has the significant advantage of being practically
implementable within the current Forgejo architecture.

The goal of enforcement is to deny actions that can make the user go
over quota, and allow the rest. As such, deleting things should - in
almost all cases - be possible. A prime exemption is deleting files via
the web ui: that creates a new commit, which in turn increases repo
size, thus, is denied if the user is over quota.

Limitations
-----------

Because we generally work at a route decorator level, and rarely
look *into* the operation itself, `size:repos:public` and
`size:repos:private` are not enforced at this level, the engine enforces
against `size:repos:all`. This will be improved in the future.

AGit does not play very well with this system, because AGit PRs count
toward the repo they're opened against, while in the GitHub-style fork +
pull model, it counts against the fork. This too, can be improved in the
future.

There's very little done on the UI side to guard against going over
quota. What this patch implements, is enforcement, not prevention. The
UI will still let you *try* operations that *will* result in a denial.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2024-08-02 11:10:34 +02:00
..
actions Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
agit fix(hook): ignore unknown push options instead of failing 2024-07-02 21:39:01 +02:00
asymkey Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
attachment Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
auth Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
automerge Fix automerge will not work because of some events haven't been triggered (#30780) 2024-05-26 19:01:36 +02:00
context feat(quota): Quota enforcement 2024-08-02 11:10:34 +02:00
contexttest Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
convert feat(quota): Humble beginnings of a quota engine 2024-08-02 11:10:34 +02:00
cron Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
doctor Replace Gitea with Forgejo 2024-07-24 14:17:23 +00:00
externalaccount allow synchronizing user status from OAuth2 login providers (#31572) 2024-07-22 15:44:13 +02:00
f3 Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
federation feat(federated-star) star repositories via ActivityPub (#1680) 2024-06-06 08:58:11 +02:00
feed Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
forgejo Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
forms Fix: Allow org team names of length 255 in create team form (#31564) 2024-07-14 11:16:34 +02:00
gitdiff Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
indexer Update issue indexer after merging a PR (#30715) 2024-05-12 20:03:10 +02:00
issue Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
lfs feat(quota): Quota enforcement 2024-08-02 11:10:34 +02:00
mailer Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
markup Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
migrations Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
mirror feat(quota): Quota enforcement 2024-08-02 11:10:34 +02:00
notify Clean up log messages (#30313) 2024-04-15 20:01:35 +02:00
org Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
packages Add signature support for the RPM module (#4780) 2024-08-02 05:56:57 +00:00
pull fix: use url.JoinPath to join url parts 2024-07-31 14:45:37 +02:00
release Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
remote Enable unparam linter (#31277) 2024-06-16 13:42:58 +02:00
repository Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
secrets Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
task feat(quota): Quota enforcement 2024-08-02 11:10:34 +02:00
uinotification Penultimate round of db.DefaultContext refactor (#27414) 2023-10-11 04:24:07 +00:00
user Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
webhook Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00
wiki Add testifylint to lint checks (#4535) 2024-07-30 19:41:10 +00:00