mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-06-22 10:02:15 +00:00
chore: refactor REST API permission check (refactor comparison)
- All middleware enforcing permissions are refactored to use the `apiv1_permissions1 interface rather than accessing data members. Unless specified below, their logic is otherwise unmodified. - `repoAssignment()` permissions is split out in `repoAccess()` and they are verified to always be used together with `FollowedBy`. - `commentAssignment()` permissions is split out in `ReqValidCommentID()` and they are verified to always be used together with `FollowedBy`. - `checkPermission()` is a helper for permission middleware that do not have arguments other than the context. - `tokenRequiresScopes()` and `tokenRequiresRepoOwnerScope()` both rely on the determination of the permission leve (read or write) based on the HTTP method (`GET`, `PUT`, etc.). This logic was moved to the `requiredScopeLevel()` function and the result provided in argument to the permission function. The permission functions do not know about the HTTP method. - `ReqSelfOrAdmin` has a new anonymous function helper to compare the user names instead of the pointers because it is more correct. This is not a bug fix but it is more robust.
This commit is contained in:
parent
17616708fd
commit
172e1d75cf
1 changed files with 405 additions and 462 deletions
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue