Skip to content

fix(auth): let only the household manager disconnect a sign-in identity - #3967

Merged
Quick104 merged 3 commits into
mainfrom
fix/account-identity-unlink-household-manager
Nov 11, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/account-identity-unlink-household-manager

Conversation

@Quick104

@Quick104 Quick104 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none. No validation task covers disconnecting a sign-in identity.

Any profile on an account could disconnect one of the account's external sign-in identities (OIDC, LDAP or a network identity). deleteAccountIdentity checked only that the caller was the account's own login session and ignored which profile was acting, so a child profile could do it from any signed-in device, including on a household whose primary profile has a PIN. The account cannot always put the identity back by itself, because self-service linking needs the account's local password.

Disconnecting now requires the household manager, the rule personal API key creation and Discord delivery settings already use.

Approach

  • deleteAccountIdentity is now profile scoped with an optional profile. The request must act as the account's primary profile, with its PIN verified when it has one. Another profile gets 403 permission_denied, and a PIN-protected profile named without its token gets 403 profile_verification_required. A request that names no profile is accepted only from an admin account's login session while no profile on the account is PIN-protected or access-restricted. A non-manager is refused before the identity ID is looked at. The own-login-session check and the 409 last_sign_in_method rule are unchanged.
  • listAccountIdentities is still readable by every profile, and by a request that names none. Its can_unlink now also answers the household rule for the profile asking, so a client shows the control only where the call would succeed. To know that profile, the list became profile scoped with an optional profile as well.
  • /api/v2 only; there is no v1 or Jellyfin route for this. The change is additive in shape: both operations gain the optional profile headers, and the descriptions change. The OpenAPI document, fixtures index and web types are regenerated, and docs/auth-api.md and docs/architecture/external-sign-in.md are updated.
  • The web app needs no change: its account page is already offered only to the primary profile, it sends the profile headers, and it hides the control on can_unlink.

Validation

  • On a dev sandbox of main, with one identity linked to a non-admin account that can also sign in with its local password, a child profile read can_unlink: true and its DELETE answered 204; the identity was gone from the account's list and the administrator's. The same 204 came back with no profile named, and for the child profile while the primary profile had a PIN.
  • On a sandbox of this branch, same steps: the child profile and the request with no profile read the list (200) with can_unlink: false, and their deletes answered 403 permission_denied; the identity stayed linked. The primary profile read can_unlink: true and its delete answered 204. With a PIN on the primary profile, the list and the delete answered 403 profile_verification_required without the token, and the delete answered 204 with it. Removing the account's only sign-in method still answered 409 last_sign_in_method. For an identity ID that does not exist, the child profile got 403 and the primary profile 404.
  • The sandbox of main was built one commit behind this branch's base; the two differ only in two contributor documents.
  • Test: the table added to TestAccountIdentities passes on the branch. It does not build on main, because it uses the dependency this change adds, so it has not been seen failing there. Removing the check from the delete, or from the list's can_unlink, fails its secondary-profile and no-profile rows. The sandbox run above is the proof that main has the gap.
  • Go: go build ./..., gofmt, go mod tidy -diff, go vet ./..., make lint-changed (0 issues) and make lint-router-recovery pass. make test-go: 200 packages pass, including every package this touches. Eight tests in internal/metadata/nfo, internal/scanner, internal/subtitles/subsync and internal/playback fail the same way alone on the base on this Mac. TestHEVCFallbackProducesDecodableMain8FMP4 failed once under the full suite's load and passes alone on both.
  • Web: install, lint, format check, build, bundle budget and make test-web (7,250 tests) pass.
  • Contracts and hygiene: verify-apiv2-openapi, verify-apiv2-web-types, verify-apiv2-contract (6 changes, none breaking), verify-apiv2-fixtures, TestCommittedArtifactMatchesRouter, verify-local-paths, verify-offline-routes and verify-case-collisions pass. make verify-route-inventory cannot run on this host, on the branch or on the base; no route is added.
  • Not checked live: a sign-in through a real provider (the identity was linked by an administrator with a made-up subject), an account with two identities, and the request with no profile from an admin account.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/account-identity-unlink-household-manager/

Risks

  • The Apple app does not send the profile headers on these two calls today. Until it does, on any non-admin account, and on an admin account that has a PIN-protected or restricted profile, the app reads can_unlink: false: it hides Disconnect and shows its "only way to sign in" footer even when the account has another way in. The list and the rest of that screen still work. The web app, acting as the primary profile, is the workaround. fix(account): send the active profile when listing and disconnecting sign-in identities silo-apple#1118 is the paired change: it sends the profile on both calls.
  • The Android app sends the profile headers, so its primary profile is unaffected. A non-primary profile there now reads can_unlink: false and sees the same footer text, which is wrong for it.
  • A non-admin account with no profiles at all can no longer disconnect an identity until it creates its first profile. Discord delivery settings already treat such an account the same way.
  • A script or client that calls deleteAccountIdentity without X-Profile-Id on a non-admin account now gets 403.
  • The Apple and Android repositories vendor the v2 fixtures index, which this change edits, so their copies need a resync after merge.
  • This regenerates contracts/api/v2/openapi.json, the fixtures index and web/src/api/v2/schema.ts. Another open change that touches the same files will need to regenerate after whichever merges first.
  • Other account-level actions stay open to any profile and are not changed here: ending a login session, approving a device sign-in, and revoking a personal API key.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (Claude desktop app)
  • Tool(s): Claude Code subagents, GitHub CLI
  • Model(s): claude-mythos-5-2
  • Involvement: Fully AI-generated; human verification pending
  • Adversarial review: a separate Claude Code subagent that did not write the change traced the rule for each kind of caller, the order of the checks, the failure paths, the contract diff, and what each client sends on these calls. It found nothing that blocks and judged the server change safe to merge before the Apple app is updated, with the cost listed under Risks. It found that a web change in the first commit had no useful effect, since a non-primary profile never reaches that page, and that a comment and two documentation sentences were inaccurate; the second commit reverts the web change and corrects the wording.

🤖 Generated with Claude Code

Note

Require household-manager permission to disconnect sign-in identities

Adds an authorization layer to both account-identity operations. GET /api/v2/account/identities now reports can_unlink based on the household-management check for the active profile, and DELETE /api/v2/account/identities/{id} rejects non-manager profiles with permission denied.

  • New MayUnlinkAccountIdentity method on handlers.ExternalSignInHandler delegates to the household-management check with a profile-verification callback; the router wires the UserStoreProvider into the handler.
  • Unverified profiles (e.g. PIN-locked primary profile) get a profile-verification problem instead of an unlink.
  • Both routes are registered as profile-scoped and profile-optional, with OpenAPI contracts and docs updated.
  • Behavioral Change: identity deletion now fails closed when the user store is unavailable, and requests without a named profile no longer bypass the household check — see MayUnlinkAccountIdentity in external_sign_in.go and route registration in external_sign_in.go

Macroscope summarized 7e0fd08.

Quick104 and others added 2 commits November 10, 2026 22:27
Any profile on an account, including a child profile on a household whose
primary profile has a PIN, could disconnect one of the account's external
sign-in identities, and the account's owner cannot always link it again
because that needs the account's local password.

deleteAccountIdentity is now profile scoped and requires the household
manager, the rule personal API key creation uses: the primary profile,
with its PIN verified when it has one. Another profile gets 403
permission_denied and an unverified primary profile gets 403
profile_verification_required. listAccountIdentities answers can_unlink
by the same rule for the profile asking, and the web app shows its
"only way to sign in" hint to the primary profile only.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The web account page is reachable only by the primary profile or an
acting admin, so the "only way to sign in" hint goes back to following
can_unlink alone; limiting it to the primary profile hid it from an admin
who has not chosen a profile. The docs now say which refusal each caller
of deleteAccountIdentity gets, including the viewer gate's 404 for an
unknown profile and 403 for a PIN-protected profile without its token.
They also say the account cannot always link an identity again by itself,
since an administrator can still link one.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e2e1e99c-d679-4715-9dc0-16dbe73fa271
Commits

Reviewing files that changed from the base of the PR and between 1224daa and 7e0fd08.

Files selected for processing: 11

  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/openapi.json
  • docs/architecture/external-sign-in.md
  • docs/auth-api.md
  • internal/api/handlers/external_sign_in.go
  • internal/api/router.go
  • internal/apiv2/external_sign_in.go
  • internal/apiv2/external_sign_in_fixtures_test.go
  • internal/apiv2/external_sign_in_test.go
  • internal/apiv2/household_profile_gate_test.go
  • web/src/api/v2/schema.ts
Pre-merge checks: Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Description check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 11, 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 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T19:29:36.732889Z 7e0fd08 New commits
🔒 Security Review ✅ Completed 2026-11-11T19:32:45.925116Z 7e0fd08 New commits
ℹ️ 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.

Comment thread internal/apiv2/external_sign_in.go Resolved
…o fix/account-identity-unlink-household-manager
@Quick104
Quick104 merged commit 5d7448a into main Nov 11, 2026
17 checks passed
@Quick104
Quick104 deleted the fix/account-identity-unlink-household-manager branch November 11, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant