Repository navigation
fix(auth): only the Owner changes an admin's access policy - #1774
Conversation
An admin other than the server Owner could change the access-policy overrides on its own account, so a restricted shared admin could lift its own limits. CheckOwnerUpdate now refuses that on v1 and v2 when a policy field changes; re-sending the stored values and editing the account's other fields still work. The web admin shows those cards and dialog fields read-only to a non-Owner admin on its own account.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (14)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
The recorded C2 results predate this authorization change. Server #1196 ( Suggested fix: update the PR body's line to Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
# Conflicts: # internal/api/handlers/owner_test.go # internal/auth/owner.go
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: #1403
Validation tasks: changes #1196 C2; changes #1197 C2
Only the server Owner may change another admin's account, but any admin could still change the access-policy overrides on their own account. An Owner who restricted a shared admin (for example, no server-prepared downloads or a stream limit) could not keep that restriction: the admin could clear it from their own user page or through the API.
This change lets only the Owner change an admin's access policy, including a non-Owner admin's own.
Approach
auth.CheckOwnerUpdaterefuses a non-Owner caller whose update changes an access-policy field on an admin account: libraries, playback quality, the stream, transcode and bitrate limits, and the transcode, download and request switches. Other admins' accounts were already protected, so in practice this covers an admin editing itself. The v1 and v2 update paths both call this check, so both answer 403 (owner_protectedon v1,permission_deniedon v2).Selectin those fields gets its owndisabledprop, because Radix opens onpointerdownand does not honor a disabled<fieldset>.No Apple or Android change is needed: the clients do not edit admin access policy. The rule applies to the frozen
/api/v1update route too, because it shares the check and leaving it out would keep the bypass open.Validation
authtable tests cover a non-Owner admin changing, clearing and re-sending its own policy, editing other fields beside unchanged policy, and the Owner changing its own and another admin's policy; handler tests cover the v1 and v2 routes. Focused Go tests,make lint-changed,go vet,gofmt, and every contract, fixture, route and local-path check from the pre-PR gate pass.make test-go: the only failures are hardware-acceleration probe, VideoToolbox, transcode-timing and admin-resource tests that fail the same way onmainon the macOS machine used; none are in packages this change touches.format:checkandbuildpass.make test-webpassed apart from three tests in collection-template and request-routing files this change does not touch; they pass when rerun alone.budget:checkfails; see Risks.Risks
/api/v1as well as/api/v2. That is the intended change; an API client that relied on it now gets 403.budget:checkfails onmainbefore this change: the launch bundle is already 1,062 B overperf-budget.json. This PR adds about 120 B to it.Checklist
AI Disclosure
claude-opus-5-5[1m];gpt-6-astraandgpt-6.1-sol(Codex CLI, review only)gpt-6-astraandgpt-6.1-solthrough Codex CLI. The one finding, that a disabled fieldset does not stop RadixSelectmenus in the edit dialog, was fixed in this PR with an explicitdisabledprop and a test that fails without it.Note
Restrict administrator access-policy changes to the Owner
auth.ErrAdminPolicyProtectedand extendsauth.CheckOwnerUpdateto reject non-owner attempts to change an administrator's access policy (libraries, playback, stream, transcode, bitrate, download, request limits). Resubmitting unchanged values is allowed, and administrators can still change ordinary users' policies.changesAccessPolicyhelpers in owner.go that compare scalar overrides, library ID sets, and nil vs. empty library scopes.canChangeAccessPolicyin accountOwner.ts. When locked, the admin edit form disables policy fieldsets, shows an owner-only notice, and omits policy fields from the update request; other account fields stay editable.Macroscope summarized 7719e8c.