Repository navigation
fix(auth): require marker grants for secondary admin profiles - #2177
Conversation
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.
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:
|
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
left a comment
There was a problem hiding this comment.
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)
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:
|
|
Review summary for Addressed on this branch
Left for the maintainers
Verification
Validated features 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 Fit: 9/10 · Readiness: 9/10 — ready
🤖 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 — 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:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
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
Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
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
permissionslist differs by version: v2Account.permissionslists only the admin's assigned permissions, while the frozen/api/v1account responses keep listing every assignable permission for an enabled admin. No gate reads either list.Validation
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 v2Account.permissionsdescription and the admin policy page wording, and skipped the access-group lookup in file-path visibility when the account lacksmetadata_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.ddd31252a: the frozen/api/v1account responses keep the role-derived admin list, and v2 keeps the assigned-only list. The recorded scenarioslogin.admin_permissionsand.r1(v1 and v2) fail on726e8f796and 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 (main07f0ae21c, thenddd31252a) is on the evidence page.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.
PUTv1/v2,DELETEv2) return 200 and change the markers.marker_editrestores the writes, and revoking it denies them again.["marker_edit","metadata_curation"].["marker_edit","metadata_curation"]. v2 reports only assigned permissions:[], or["marker_edit"]once assigned.marker_editassigned, Edit Markers returns on its own.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 isddd31252a. 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/v1responses 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
AI Disclosure
726e8f796and the v1/v2 permissions split onddd31252a), Go, PostgreSQL, Docker, pnpm, local browser/device tools, GitHub CLI726e8f796: 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 onddd31252a: the/api/v1permissions 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
auth.PolicyPermissionsnormalizes effective-policy permissions (assignable-only, deduped, sorted), andeffectiveAccountPolicyreplaceseffectiveDownloadAllowedacross auth, admin, device, invitation, and password-reset handlers, so all account views carry resolved permissions.apiv2.accountFromView) now serializes policy permissions, while the v1 permissions list keeps the all-assignable-permissions value for enabled admins viav1AccountPermissions.canViewFilePaths,RequireMetadataCurationForItem) now resolve the effective policy including access-group masks and deny on resolution failure.auth.EffectivePermissions,HasEffectivePermission, andHasAssignedPermissionare 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.