Skip to content

fix(auth): only the Owner changes an admin's access policy - #1774

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/admin-policy-owner-only
Oct 3, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/admin-policy-owner-only

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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.CheckOwnerUpdate refuses 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_protected on v1, permission_denied on v2).
  • Only a change is refused. An update that re-sends the stored values passes, so a form that submits every field still saves an email or password change. Library lists are compared as sets.
  • Permissions and the profile limit are not part of this rule: admins hold every permission by role, and the profile limit is not access policy.
  • Web: on a non-Owner admin's own page, the Library access, Downloads, Playback and Requests cards are view-only with a note that only the server owner can change them; Sign-in & role stays editable. The Users list's edit dialog disables the same fields and leaves them out of the save. Each Radix Select in those fields gets its own disabled prop, because Radix opens on pointerdown and 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/v1 update route too, because it shares the check and leaving it out would keep the bypass open.

Validation

  • Go: auth table 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 on main on the macOS machine used; none are in packages this change touches.
  • Web: lint, format:check and build pass. make test-web passed apart from three tests in collection-template and request-routing files this change does not touch; they pass when rerun alone. budget:check fails; see Risks.
  • End to end on a local Docker deployment built from this branch together with the admin full-access change: a non-Owner admin got 403 on v1 and v2 when lifting its own restriction, saved an email change, and saw the four cards view-only; the edit dialog showed every policy control disabled and saved the email change without policy fields. The Owner could still change that admin's policy and its own.

Risks

  • A non-Owner admin can no longer change its own access policy through the web or the API, on /api/v1 as well as /api/v2. That is the intended change; an API client that relied on it now gets 403.
  • User management / access groups / invites — Server #1196 C2 ("reject ... unauthorized management") and User management / access groups / invites — Web admin #1197 C2 were validated before this boundary existed: a non-Owner admin could then edit its own policy. The cases' criteria still hold, and this narrows what an admin may change, so both need re-validation after merge.
  • Request quota and approval for an account are saved through the separate request-limit endpoints and are not covered by this rule.
  • budget:check fails on main before this change: the launch bundle is already 1,062 B over perf-budget.json. This PR adds about 120 B to it.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code, run from T3 Code
  • Tool(s): Claude Code, Codex CLI, GitHub CLI, T3 Code browser preview
  • Model(s): claude-opus-5-5[1m]; gpt-6-astra and gpt-6.1-sol (Codex CLI, review only)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: the combined diff of this PR and the admin full-access change was reviewed by Claude Code's code review and, independently, by gpt-6-astra and gpt-6.1-sol through Codex CLI. The one finding, that a disabled fieldset does not stop Radix Select menus in the edit dialog, was fixed in this PR with an explicit disabled prop and a test that fails without it.

Note

Restrict administrator access-policy changes to the Owner

  • Adds auth.ErrAdminPolicyProtected and extends auth.CheckOwnerUpdate to 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.
  • Adds changesAccessPolicy helpers in owner.go that compare scalar overrides, library ID sets, and nil vs. empty library scopes.
  • API handlers map the new error to the existing forbidden owner-protection code in owner.go.
  • The UI adds canChangeAccessPolicy in 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.
  • Behavioral Change: a non-owner administrator editing their own account can no longer change their own access policy via API or UI; the form now drops policy fields from self-edit requests.

Macroscope summarized 7719e8c.

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.
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e978e40-0b3f-4ea9-a42b-2845d5cdf75f
📥 Commits

Reviewing files that changed from the base of the PR and between 2ea6838 and 7719e8c.

📒 Files selected for processing (14)
  • docs/admin-users-api.md
  • internal/api/handlers/owner.go
  • internal/api/handlers/owner_test.go
  • internal/auth/owner.go
  • internal/auth/owner_test.go
  • web/src/components/StreamBitrateLimitInput.tsx
  • web/src/components/UserPolicyFields.tsx
  • web/src/lib/accountOwner.test.ts
  • web/src/lib/accountOwner.ts
  • web/src/pages/AdminUserDetail.tsx
  • web/src/pages/AdminUsers.test.tsx
  • web/src/pages/AdminUsers.tsx
  • web/src/pages/admin-users/detail/access/AccessTab.test.tsx
  • web/src/pages/admin-users/detail/access/AccessTab.tsx
 _________________________________________________________________
< Never bring a script to a dependency battle - bring a lockfile. >
 -----------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kody-ai

kody-ai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Access your configuration settings here.

@macroscopeapp

macroscopeapp Bot commented Oct 1, 2026

Copy link
Copy Markdown

The recorded C2 results predate this authorization change. Server #1196 (7cc2c1f2) now has an Owner-only policy check on admin-account updates, and Web admin #1197 (build 807 · d4e35ba9) has read-only policy controls for non-Owner admins; its C2 is linked to the #1403 admin-override finding. The earlier evidence does not cover this permission boundary, so both are major changes. The PR must explain why the validated permission behavior changes, and both cases need re-validation after merge.

Suggested fix: update the PR body's line to Validation tasks: changes #1196 C2; changes #1197 C2.

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

silo-kody Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 1a17974 into Silo-Server:main Oct 3, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants