Skip to content

fix(auth): require marker grants for secondary admin profiles - #2177

Merged
Quick104 merged 7 commits into
Silo-Server:mainfrom
Rhainland:fix/markers-1150-profile-gate
Nov 2, 2026
Merged

Quick104 merged 7 commits into
Silo-Server:mainfrom
Rhainland:fix/markers-1150-profile-gate

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #1911
Related issue: #1150; #1911
Validation tasks: changes #1196 C1, #1196 C2, #1199 C1, #1200 C1; unblocks #1151 C1, #1152 C1, #1153 C1

An administrator acting through a secondary household profile can edit markers without an assigned grant. This change limits the role bypass to acting-admin requests and otherwise requires the effective assigned permission.

Approach

Use the existing acting-admin check in the legacy gate and the matching Rego decision. Enforce enabled accounts and permission-payload parity, and regenerate the vendor-policy API fixture. This is a narrow follow-up to #1906. The policy-backed marker gate now passes the household fact, as the metadata-curation gate already does, so a household lookup failure returns 500 in both gates. That reverses #2019's skip of the household lookup on the marker gate, which only held while marker editing ignored the profile. The account payload's permissions list differs by version: v2 Account.permissions lists only the admin's assigned permissions, while the frozen /api/v1 account responses keep listing every assignable permission for an enabled admin. No gate reads either list.

Validation

  • Marker authoring & editing — Server #1151 C1, Marker authoring & editing — Web admin #1152 C1 and Marker authoring & editing — Web #1153 C1 cover the marker gate and have not been run yet. The account payload change reaches recorded passes: User management / access groups / invites — Server #1196 C1 and C2 (an invited or grouped account now reports only the permissions its group allows, which User management / access groups / invites — Server #1196 C2's run noted as a mismatch), and Admin impersonation — Server #1199 C1 and Admin impersonation — Web admin #1200 C1 (an impersonated account reports the same masked list). The gates already enforced the mask, so no enforcement those cases checked changes.
  • Review follow-up on 726e8f796: merged current main (which needed one test conflict resolved and fix(access): take admin reach on profile routes from the acting profile #2370's secondary-admin file-path check moved onto the masked check), corrected the v2 Account.permissions description and the admin policy page wording, and skipped the access-group lookup in file-path visibility when the account lacks metadata_curation. Focused tests for the auth, middleware, policy, access, apiv2 and handlers packages, changed-line lint, and the v2 OpenAPI, web-type and contract checks pass on that head. The new Rego tests and legacy-gate tests fail on main for the reported reason.
  • Follow-up on ddd31252a: the frozen /api/v1 account responses keep the role-derived admin list, and v2 keeps the assigned-only list. The recorded scenarios login.admin_permissions and .r1 (v1 and v2) fail on 726e8f796 and pass here. Two other scenario failures also happen on main and are filed as [bug] Auth scenario acceptance targets fail on main: stale session field count and login rate-limit scenario #3408. The auth, apiv2, handlers and scenariocatalog package tests, changed-line lint and the OpenAPI check pass, and CI is green. A sandbox before and after (main 07f0ae21c, then ddd31252a) is on the evidence page.
  • After merging current main: build, vet, focused tests for the middleware, policy, access, auth and handler packages, changed-line lint, and the v2 fixture, OpenAPI, contract and route-inventory checks pass. On unchanged main, an admin without a marker grant writing through a non-primary profile still gets 204 from both gates.
  • Focused changed-package tests and changed-line lint passed.
  • The combined current-main integration passed Go build/vet, web lint/format/build/budget and every generated-contract, fixture and documentation hygiene check. The fresh database pin gate passed all 87 pins; the manual deletion database regression passed.
  • The full web gate passed under CI's Node 22: 834 files and 7,186 tests. Full local Go runs did not pass: macOS hit platform/probe/timing failures, and the isolated Linux attempt hit compile memory limits and two Jellyfin Dolby Vision cases. These local runs are not reported as passed.
  • B4 runtime: primary-admin role access passed; a secondary admin without a grant received 403, an explicit grant restored access, and revocation denied the already issued token. Non-admin grant/revoke and group masking passed on direct requests and fresh editor visibility.
  • Runtime observations use the coordinated local validation build, including upstream fix(auth): apply the access-group permission mask to account permissions #1906/fix(playback): send stored skip markers when a player reconnects #1787. They are agent evidence, not integrated release-build acceptance, human task results or RC certification.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2177/

Evidence

The evidence page compares current main with this branch on one sandbox and the same seeded data: an admin account, with no assigned permissions, that has a secondary profile.

Before After
The secondary profile's marker writes (PUT v1/v2, DELETE v2) return 200 and change the markers. The same writes return 403 and leave the markers unchanged. The primary profile still writes. Assigning marker_edit restores the writes, and revoking it denies them again.
v1 and v2 login and current-account responses report ["marker_edit","metadata_curation"]. v1 still reports ["marker_edit","metadata_curation"]. v2 reports only assigned permissions: [], or ["marker_edit"] once assigned.
On the secondary profile, the web movie menu's Manage panel shows Edit Metadata, Match Item, Refresh Metadata, Edit Markers and Media Info. The menu shows none of them. With marker_edit assigned, Edit Markers returns on its own.
The admin policy page says "Marker editing: admins automatically". It says admins edit markers automatically only while acting as admin.

Surface and build: native API v1 and v2, the web movie detail page and the admin policy page at desktop (1440 px) and phone width (393 px). Before is main 07f0ae21c; after is ddd31252a. The recorded scenario results for both heads are on the page too.

Risks

#1906 was closed without merging, so this PR now lands its two commits, with their author credit. The account payload reports the access-group-masked permissions. On v2, an admin's list holds only its assigned permissions, and clients apply the admin grant from role and profile, as the web client does. The frozen /api/v1 responses keep the role-derived list for enabled admins, so v1 clients see no change for admins. A non-admin's v1 list is now group-masked, matching the v1 gates. Apple decodes the field without using its values and Android doesn't model it. No native editor or Jellyfin write route is introduced.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: OpenAI Codex through T3 Code
  • Tool(s): Codex, Claude Code (claude-opus-5-5, merged main, moved this PR from a fork to upstream, and made the review fixes on 726e8f796 and the v1/v2 permissions split on ddd31252a), Go, PostgreSQL, Docker, pnpm, local browser/device tools, GitHub CLI
  • Model(s): gpt-6.1-sol
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Reviewed the scoped diff and traced authorization, eligible-library writes, automatic-write precedence, file identity, empty marker semantics and reconnect ordering through the surrounding code. The Android TV input-priority finding is corrected in the client companion change. Pre-PR contract checks exposed the vendor-policy fixture, which was regenerated; no unrelated redesign is included. Maintainer review on 726e8f796: Claude Code (claude-opus-5-5) with finder subagents and a cross-provider round (Codex, gpt-6.1-sol) on the merged head; four findings fixed. Follow-up on ddd31252a: the /api/v1 permissions list was restored under the frozen-v1 rule, and a cross-provider round (Codex, gpt-6.1-sol) on that change found nothing.

Note

Require marker_edit grants for admins outside their primary profile

  • The marker_edit administrator bypass now applies only to an enabled admin acting as administrator on the primary profile (or with no profile in a household that allows it). Other admins, including non-acting admins, need an assigned marker_edit grant. See permission.rego and permissions.go.
  • New auth.PolicyPermissions normalizes effective-policy permissions (assignable-only, deduped, sorted), and effectiveAccountPolicy replaces effectiveDownloadAllowed across auth, admin, device, invitation, and password-reset handlers, so all account views carry resolved permissions.
  • The v2 Account projection (apiv2.accountFromView) now serializes policy permissions, while the v1 permissions list keeps the all-assignable-permissions value for enabled admins via v1AccountPermissions.
  • Metadata-curation gates (canViewFilePaths, RequireMetadataCurationForItem) now resolve the effective policy including access-group masks and deny on resolution failure.
  • Behavioral Change: auth.EffectivePermissions, HasEffectivePermission, and HasAssignedPermission are removed; admins no longer implicitly hold marker_edit or metadata_curation by role, and policy-backed marker-edit now performs a household lookup it previously skipped.

Macroscope summarized ddd3125.

tomislav and others added 4 commits October 4, 2026 13:49
The account payload reported permissions from the account's own list and
ignored the access group's allowed_permissions mask that the marker and
metadata curation gates enforce, so clients showed controls the server
rejected with 403. Resolve the payload's permissions, and file-path
visibility, from the same group-masked effective policy. Admins report
their assigned permissions; clients add the admin role grant only while
the admin acts through the primary profile.
…ates

The legacy marker and metadata curation gates, used when no policy system
is wired, checked the account's raw permissions, so they disagreed with the
now-masked account payload. Resolve both through the effective policy and
pass the access-group store to the legacy marker gate. Remove the
HasEffectivePermission and HasAssignedPermission helpers, which have no
remaining callers.
Resolve conflicts with the household-aware acting-admin rule from Silo-Server#2019:
the legacy gates take the household requirement before the access-group
store, and the marker_edit admin grant now goes through acting_admin_allowed
in both gates, so the policy-backed marker gate passes the household fact.
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Oct 9, 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 and others added 2 commits November 2, 2026 01:47
Resolve conflicts with current main:

- internal/auth/permissions_test.go: Silo-Server#2817 kept tests for
  HasEffectivePermission, which this branch removes; keep the branch's
  PolicyPermissions table and drop the default-permissions test as Silo-Server#2817 did.
- internal/api/handlers/items.go: Silo-Server#2370 added a secondary-admin file-path
  check through HasAssignedPermission. A secondary admin now falls through
  to the shared masked check; groups never mask an admin, so it still needs
  metadata_curation assigned to the account.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rker grant

Account.permissions now lists an admin's explicitly assigned permissions
only; say so in the v2 schema, with the acting-admin rule clients apply
from role and profile. The admin policy page still said admins edit
markers automatically on every profile. File-path visibility skips the
access-group lookup when the account lacks metadata_curation, since the
mask can only remove grants.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 91f388c72, with current main (257390ba1) merged in. The marker fix is right: the vendored Rego tests and the two new legacy-gate tests fail on main for the reported reason and pass here. Five findings, one of which is a maintainer decision.

1. The branch no longer merges or builds against main (high). Besides the internal/auth/permissions_test.go conflict, #2370 added a secondary-admin branch to canViewFilePaths that calls auth.HasAssignedPermission, which this branch deletes, so the merged tree fails go build. A secondary admin can fall through to the shared masked check instead: groups never mask an admin (access.ApplyGroupPolicy), so it still needs metadata_curation assigned to the account, the same bar #2370 set. I'm fixing this in a merge commit on this branch, so there's no need to change it yourself.

2. The v2 schema still documents the old meaning of Account.permissions (medium). internal/apiv2/account.go and the generated contracts/api/v2/openapi.json say "Effective assignable permissions; empty for a disabled account". After this change, an admin acting on its primary profile reports [] and still holds both permissions. A third-party client that follows the published description would hide marker editing and curation from every admin without assigned grants. The fix is to describe the list as assigned permissions after the group mask, and to say that the admin role grant applies only while acting as administrator. I'm fixing this in a commit on this branch, with the OpenAPI and web types regenerated.

3. The admin policy page still promises the removed bypass (low). web/src/pages/admin-policy/policyPresentation.tsx says "Marker editing: admins automatically; everyone else needs the permission assigned to their account." A secondary-profile admin now gets 403. I'm fixing the wording in a commit on this branch.

Findings 4 and 5 are inline.

🤖 Claude Code (claude-opus-5-5)

Comment thread internal/api/handlers/auth.go Resolved
Comment thread internal/api/handlers/items.go Resolved
@silo-kody

silo-kody Bot commented Nov 2, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@Quick104

Quick104 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review summary for ddd31252a. The previous summary covered 726e8f796, which merged current main 257390ba1 into 91f388c72 and added review fixes. Findings are in the review.

Addressed on this branch

  • The branch conflicted with main and didn't build once merged. fix(access): take admin reach on profile routes from the acting profile #2370's secondary-admin file-path check called a helper this branch removes. It now goes through the same masked check, and still requires metadata_curation assigned to the account.
  • The v2 Account.permissions description now says an admin lists only its assigned permissions and that the role grant applies only while acting as administrator. The OpenAPI artifact and web types are regenerated.
  • The admin policy page no longer says admins edit markers automatically on every profile.
  • File-path visibility skips the access-group lookup when the account has no metadata_curation.
  • The frozen /api/v1 permissions field is restored (ddd31252a). An enabled admin again gets ["marker_edit","metadata_curation"] from v1 login, /auth/me and the other v1 account responses. v2 keeps this PR's assigned-only list through a separate v2-only field, and no gate reads either list. Non-admin accounts get the group-masked list on both versions, which matches the masked v1 gates this PR adds. The v2 side of login.admin_permissions and .r1 now expects [] for the fixture admin, and the setupServer example shows the first admin with none. docs/architecture/api-contract.md records the version difference.

Left for the maintainers

Verification

  • The four new Rego tests and the two new legacy-gate tests (TestLegacyMarkerEditUsesActingAdminAndEffectiveGrant, TestMarkerEditHouseholdRule) fail on main for the reported reason and pass here. The new handler and policy Go tests call helpers this PR adds, so they don't build on main and aren't evidence of the fix.
  • login.admin_permissions and .r1 (v1 and v2) fail on 726e8f796 with body/user/permissions = [], want non-empty, and pass on ddd31252a and on main. These runs used a scratch database, with the session-field count from [bug] Auth scenario acceptance targets fail on main: stale session field count and login rate-limit scenario #3408 patched locally so only these assertions differ.
  • On ddd31252a, these all pass: the auth, middleware, policy, access, apiv2 (including contract fixtures), handlers and scenariocatalog package tests, changed-line lint, verify-apiv2-openapi and verify-local-paths. CI is green.
  • A sandbox built from main and then from ddd31252a ran with the same data, recorded on the evidence page linked from the PR body. On main, an admin's secondary profile with no grant writes markers through v1 and v2. At the PR head it gets 403 on all three writes and the markers don't change, while the primary profile still writes. Assigning marker_edit restores the writes and Edit Markers, and revoking it denies them again. v1 reports both permissions throughout; v2 reports [], ["marker_edit"], then [].
  • All six marker write routes (v1 and v2) go through the gate. API keys keep their household exemption, and impersonation uses the target account's policy.
  • Cross-provider review of the version-boundary change (Codex, gpt-6.1-sol, one round on ddd31252a): no findings. It traced every v1 and v2 account response to the right list and found no authorization that reads either one.

Validated features
The validation board couldn't be read from this environment, so passed cases were read from the validation issues instead. The diff reaches #1196 C1 and C2, #1199 C1 and #1200 C1 as minor changes: those accounts now report the group-masked permission list, and enforcement is unchanged. #1197 C1 and C2 and #1199 C2 and #1200 C2 show no behavior change. #1151 C1, #1152 C1 and #1153 C1 have not been run yet. No regression was found. The body's Validation tasks: line lists these.

User manual: no change needed. The markers page already says only an administrator's primary profile edits markers without the permission, and that the access group must allow it too.

Apple, Android, jellycompat: no follow-up needed. Apple decodes permissions without using its values, Android doesn't model it, and jellycompat has no manual marker-write route. v1 clients see the same admin list as before.

Fit: 9/10 · Readiness: 9/10 — ready

  • Fit: the marker fix applies the acting-admin rule that metadata curation and the web client already use, in the policy and both gates, so the server and clients agree. The frozen v1 field keeps its old meaning.
  • Readiness: the gate change is shown by tests that fail on main and by a live before and after on a sandbox. The scenario that caught the v1 change fails on the previous head and passes now. The PR is still a draft; whether to mark it ready is up to the maintainers.

🤖 Claude Code (claude-opus-5-5)

The frozen v1 account body listed every assignable permission for an
enabled admin. This branch had switched that list to assigned-only on
both versions, so a typical admin's v1 login and /auth/me returned
"permissions": [] and the recorded login.admin_permissions scenarios
failed.

UserView now carries two lists. Permissions, the v1 JSON field, keeps
the role-derived list for enabled admins and otherwise reports the
masked policy list. PolicyPermissions is v2-only and feeds
Account.permissions, which lists an admin's assigned permissions only.
No gate reads either list; the marker and metadata authority checks
are unchanged.

The v2 side of login.admin_permissions and its .r1 pair now expects an
empty list for the fixture admin, which has no assigned permissions,
and the setupServer example shows the first admin with none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 2, 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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T14:54:10.612018Z ddd3125 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104
Quick104 merged commit 243d7e0 into Silo-Server:main Nov 2, 2026
22 checks passed
@macroscopeapp

macroscopeapp Bot commented Nov 2, 2026

Copy link
Copy Markdown

The PR changes permission data used in recorded access-group and impersonation cases:

The PR must explain why these validated behaviors change; these cases need re-validation after merge.

The marker cases #1151 C1, #1152 C1 and #1153 C1 are recorded as Not run, not blocked. Replace unblocks with reaches and add #1197 C2:

Validation tasks: changes #1196 C1 and C2; changes #1197 C2; changes #1199 C1; changes #1200 C1; reaches #1151 C1, #1152 C1 and #1153 C1 (not run)

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

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.

[bug] Admins on a non-primary profile can still edit markers

3 participants