Repository navigation
fix(auth): enforce current role permissions on custom API keys - #1004
T3ST3ST3R0N merged 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughAPI-key authentication now caps non-owner admins’ stored key permissions by their current role permissions. A new helper intersects requested permissions with a ceiling. Owner admins retain the stored key permissions. ChangesAPI-Key Permission Capping
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant APIKeyAuthentication
participant AdminRole
participant intersect_permissions
APIKeyAuthentication->>AdminRole: read current role permissions
APIKeyAuthentication->>intersect_permissions: intersect stored key permissions with role permissions
intersect_permissions-->>APIKeyAuthentication: return capped permissions
APIKeyAuthentication->>APIKeyAuthentication: assign permissions to key role data
Suggested reviewers: Merge Risk: ⚪ Minimal · up to Custom API keys are capped by their owner’s current role permissions, with no established issue requiring a fix before merge. Pre-merge checks |
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…am up to 2026-10-17 Owner rule of 2026-10-14: upstream changes are ported only from final upstream releases. Checked with git ls-remote on 2026-10-17 20:53 UTC; no new release since panel v5.4.1, node v0.5.4 and node_bridge_py v0.9.2 (GitHub releases, PyPI and npm also unchanged). Panel: the 79 Port queue entries are all dev-only, so they move to the new "Held for an upstream release" section with their security classification and without deadlines, and the queue is empty. Upstream dev moved to a2fb313 with 25 commits: PasarGuard#1019 is waived (the fork deleted the notifier workflow), the other 24 are held, three of them classified security: yes (PasarGuard#1004 role permissions on custom API keys, PasarGuard#1005 role limits on bulk updates, PasarGuard#1008 role disconnect policy). New branches feat/live-core-apply and two masque commits are UNMERGED-WIP; fix/xray-wg-allocation-view is the same patch as held ba27c1cc6. Node: five earlier dev-only picks are on fork main 0071e2c with trailers and leave the queue; the other eight queue entries and four new dev commits (PasarGuard#58, PasarGuard#55, PasarGuard#104, PasarGuard#106) are held, with f72ac0ef (PasarGuard#99) and a3d2d2fe (PasarGuard#101) marked as fixed by the fork's own fixes per the 2026-10-14 decisions. PasarGuard#100 (refuse to start without a valid API_KEY) is ported by design: fork commit 88162e2 already fails fast. node_bridge_py: 27be206 is ported on fork main 6116922; 22f1ef79 and the v0.9.2 bump bec9cb22 are recorded as ported by design (the one flagged line belongs to the fork's own add_backend, and the fork labels itself 0.9.2+singbox); upstream main's new PasarGuard#24 (9fa9f264) is held. scripts: fork main 51edabb has upstream main bba95f274 as an ancestor, so its thirteen queue lines are ported (decision 7 keeps them). Against live upstream the panel gate is green (282 commits, 0 unported, 103 held, 0 owed) and every fork tracker is green.
…Guard#1004) (cherry picked from commit 180b4dd)
Summary
A custom API key currently retains its stored permission snapshot after the owner's role loses that permission or its scope is reduced. JWT requests respect the current role while the existing key can still access other admins' users.
Intersect custom key grants with the owning admin's current role during authentication. Missing/disabled permissions deny access and scoped grants use the narrower scope. An owner's custom key retains only its own grants and never receives owner privileges; inherited keys retain their existing behavior.
Type of change
Testing
git diff --checkpassed.Notes for reviewers
Two production Python files change. No test files, documentation files, schema changes or dependencies are included. Stored key snapshots remain intact; effective access follows the current role on each request.
Integration validation of the five open audit PRs on current dev: all patches applied together without conflicts, and 400 local tests passed in isolated fresh SQLite runs. Ruff passed on all 11 touched production files.
Summary by CodeRabbit