Repository navigation
feat(auth): let a password change sign out other devices - #2925
Conversation
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:
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
API contract and request wiring contracts/api/v2/*, docs/auth-api.md, internal/api/handlers/auth*.go, internal/apiv2/* |
The v2 capability and password-change request expose sign_out_other_sessions. The endpoint rejects null and forwards the value to the account service. The v1 handler passes false. |
Transactional session revocation internal/auth/*, internal/api/router.go, internal/auth/login_sessions_db_test.go, scripts/ci/db-contracts.txt, docs/architecture/password-resets.md |
When sign-out is requested, password replacement and revocation of other active sign-ins occur in one transaction. The requesting session is preserved. After success, the service invokes the configured revocation callback. Database tests cover sign-in types, account boundaries, and the callback. |
Web password setting web/src/api/v2/schema.ts, web/src/hooks/queries/account.ts, web/src/pages/settings/AccountSettings* |
The form shows an unchecked checkbox when the capability supports the option. It submits the flag when selected, displays a corresponding success message, and invalidates login-session queries after a successful sign-out change. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Severity of issue fixed: Medium
Sequence Diagram(s)
sequenceDiagram
participant AccountSettings
participant PasswordEndpoint as v2 password endpoint
participant AccountService
participant authService as auth.Service
participant Repository
participant RevocationHook as OnUserSessionsRevoked
AccountSettings->>PasswordEndpoint: Submit password and sign_out_other_sessions
PasswordEndpoint->>AccountService: Pass sign-out setting
AccountService->>authService: ChangePassword with sign-out setting
authService->>Repository: Replace password and revoke other sign-ins
Repository-->>authService: Return after transaction
authService->>RevocationHook: Notify after successful change
PasswordEndpoint-->>AccountSettings: Return successful response
Possibly related PRs
- Silo-Server/silo-server#2930: It changes password-check and hashing contracts used by the password-change path.
- Silo-Server/silo-server#2306: It records password-change and account-wide session-revocation behavior related to this change.
Suggested reviewers: rhainland
Merge Risk: 
Minimal · up to aa593
-
The optional sign-out path preserves the temporary-password transition, and no unresolved issue in the supplied evidence prevents merging after normal checks.
Security architecture risk: 
Low · up to aa593
-
The change retains existing password and account-authority checks and makes password replacement and sign-out transactional. No new security weakness was established in the inspected flow, but deployment-specific invalidation and recovery behavior remain partially verified.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- observed — The new request controls whether to revoke sign-ins, not which account or session to target. Those identifiers are supplied from authenticated claims. The revocation predicate also reaches impersonation sessions associated with that account, including sessions whose viewed account differs.
Security Findings and Attack Paths
- inferred — A process interruption or failed event publication after commit can skip cache eviction, but that alone does not demonstrate continued use of a revoked persistent Jellyfin-compatible credential: subsequent persistent lookup reads the deleted row, and refresh updates cannot recreate it. This is counterevidence to a notification-loss vulnerability, not assurance about every deployment configuration.
Trust Boundaries and Controls
- observed — The changed endpoint retains the shared authorization check. It rejects missing access-session claims and impersonation, and applies the existing primary-profile or administrator rule, with the existing temporary-password exception. Credential replacement additionally validates the current password and uses an expected-hash update to reject stale replacements.
Resilience and Maintainability Implications
- inferred — The inspected transition paths serialize relevant credential issuance with password replacement through the account row. Local sign-in rechecks the password under that lock; Audiobookshelf issuance takes a conflicting shared lock; device collection locks the approving account before the device request. These controls limit concurrent issuance escaping the revocation boundary.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 inconclusive Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "feat(auth): let a password change sign out other devices" matches the main change: an opt-in optional sign_out_other_sessions flag on POST /api/v2/account/password that revokes other sign-ins (login sessions, Jellyfin- and Audiobookshelf-compatible sessions, approved device sign-ins) while keeping the caller's session. The title is specific, concise, and follows a conventional commit form. It does not mention the capability endpoint or the web checkbox, which is expected for a single headline.
Full details: Description check
-
Explanation
The description states the problem (other sign-ins survive a password change), the approach (opt-in sign_out_other_sessions member, capability endpoint, revocation in the same transaction, hook invocation), validation steps, contract notes, risks, and follow-ups. It is directly related to the changeset and is not off-topic.
Full details: Linked Issues check
-
Explanation
[
#2898] Each coding objective has implementation at the reviewed head.- Optional
sign_out_other_sessionsboolean, default false, onPOST /api/v2/account/password:ChangePasswordInputkeepsRawBodyandBody.SignOutOtherSessions(internal/apiv2/account.go). A JSON null is rejected with 422. Omission passes false. - Same-transaction revocation, keeping the caller's session:
ReplacePasswordSigningOutOthersrunsRevokeOtherSignInsInTransactioninside thecompareAndSwapPasswordtransaction, before commit (internal/auth/repository.go).revokeSignInsInTransactionexcludes onlyid IS DISTINCT FROM keepSessionID. - Other login sessions, including "View as user" sessions: the SQL matches
user_idorimpersonator_user_id(internal/auth/password_reset.go). - Audiobookshelf sessions, Jellyfin-compatible sessions, approved uncollected device sign-ins: revoked by
revokeAudiobookshelfSessionsInTransaction,deleteJellyfinSessionsInTransaction, andwithdrawDeviceSignInApprovalsInTransactionin the same transaction. - API keys survive: the revocation SQL does not touch API key tables.
- Post-commit Jellyfin in-memory invalidation:
Service.OnSessionsRevokedis wired todeps.OnUserSessionsRevoked(internal/api/router.go). The hook runs after the password change returns. TheReplacePasswordSigningOutOthersdoc comment states this. - Capability reporting:
AccountPasswordCapabilityView.SignOutOtherSessions(internal/api/handlers/auth_password.go, internal/apiv2/account.go). - Unticked web checkbox, shown only when the capability reports support: AccountSettings.tsx, per the change summary and the web test.
/api/v1unchanged:HandleChangePasswordpasses false.
Tests: a database test
TestChangePasswordSignOutOtherSessionsDB, v2 handler tests for default, true, and null, and a web test for the checkbox. The reported test results were not re-run in this assessment.[
#2907] Closed and contextual only. Its Audiobookshelf race is not a requirement for this pull request. The PR states that#2919addresses it.Limit:
service.gowas read only in part. TheChangePasswordbody was not inspected. Its post-commit hook ordering rests on the change summary and the doc comments. - Optional
Full details: Out of Scope Changes check
-
Explanation
Each changed area supports the
#2898feature:- Contract artifacts (
contracts/api/v2/openapi.json, fixtures,migration.json),web/src/api/v2/schema.ts, anddocs/auth-api.mdanddocs/architecture/password-resets.md: document and type the new v2 member and capability. The v1 contract is unchanged. internal/api/handlers/auth.go,auth_password.go,auth_password_test.go,internal/apiv2/router.go,pilot_fakes_test.go: thread the new boolean through service interfaces. The v1 path passes false.internal/auth/service.go,password_reset.go,repository.go: implement the revocation and post-commit hook.internal/auth/repository.gorefactor:compareAndSwapPasswordnow takes a transaction callback. The temporary-password path still runs the sameUPDATE auth_sessionsstatement, with the samekeepSessionIDsemantics. The diff shows no behavior change there.RevokeSignInsForUsersInTransactionkeeps its previous behavior with a nil keep session.web/src/hooks/queries/account.ts: invalidateslogin-sessionsonly after an opted-in change. This keeps the cached session list accurate.scripts/ci/db-contracts.txt: registers the new database test.
No unrelated feature, refactor, or file change was found.
- Contract artifacts (
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 15 files. (8 skipped: 7 unsupported, 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Quick104
left a comment
There was a problem hiding this comment.
Reviewed 402363789304a7dbf9d9ee3b03c0f4e70e816777: no introduced defect found.
Focused checks passed: four database tests covering opt-in revocation, caller preservation, existing admin revocation, rollback and device-poll serialization; three v2 account tests; and four web form tests. The checkbox test fails on the merge base because the control is absent. The new Go database test cannot build on that base because it uses the new service signature, so that run is not regression proof.
The disclosed Audiobookshelf refresh race remains real and unresolved in #2907: a concurrent refresh can insert replacement tokens after revocation. It predates this diff and the new option inherits it; this review does not establish complete sign-out under that race.
Suggested validation line for recorded passes: Validation tasks: changes #1229 C1. Session cases #1186 C1 and #1187 C1 remain Not run and should exercise the new option; #1229 C1 needs a minor appearance re-check. Existing API-key and impersonation cases retain their behavior. Validation used live issue records; full board enumeration was unavailable because the GitHub token lacks read:project.
The manual follow-up is tracked by Silo-Server/siloserver.org#280 and its draft PR #281. Apple and Android currently have no password-change screen.
Fit: 9/10 · Readiness: 8/10 — conditional on accepting the documented #2907 limitation. CI is green on the reviewed head. No live browser or multi-node exercise was performed in this review.
AI review: Codex desktop, gpt-6.1-sol, xhigh; independent finder and verification passes.
Changing your own password kept every other sign-in working. v2 changePassword now takes an optional sign_out_other_sessions boolean (off by default). When set, the password change revokes everything a reset revokes except the calling session, in the same transaction, and runs the OnUserSessionsRevoked hook after commit. The password capability reports the option. The web form shows an unticked "Sign out of other devices" checkbox when the capability offers it and sends the member only when ticked. /api/v1 is unchanged. Closes #2898 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ActiveSession now takes the session's account and CheckPassword takes a context and reports a busy hasher, so the sign-out-other-sessions DB test passes each fixture session's owner and checks both results. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4023637 to
9724b17
Compare
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:
|
Co-Authored-By: Codex (gpt-6-astra) <[email protected]>
|
#1229 C1 needs a minor appearance re-check: the new checkbox on Settings > Account adds a control using the branded primary color. The PR body still says Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
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
Closes #2898
Related issue: N/A
Validation tasks: changes #1229 C1 (the new checkbox takes the server accent color)
Changing your own password in Settings > Account leaves every other sign-in working: other browsers and apps, Jellyfin-compatible clients, Audiobookshelf-compatible clients, and device sign-ins you approved that the device hasn't collected yet. Someone who changes the password because they think it leaked can't lock out whoever used it, short of signing each session out by hand (and Audiobookshelf sessions and device approvals aren't listed anywhere). An administrator setting the password, or a reset link, already signs the account out everywhere.
This keeps the default (a password change signs nothing else out) and adds an opt-in: a Sign out of other devices checkbox on the password form, unticked by default, backed by a new optional
sign_out_other_sessionsmember onPOST /api/v2/account/password.Approach
When
sign_out_other_sessionsis true, the password change revokes what a password reset revokes, except the session making the change, in the same transaction as the password swap: the account's other login sessions (including "View as user" sessions in either direction), its Audiobookshelf-compatible sessions, its stored Jellyfin-compatible sessions, and its approved, uncollected device sign-ins. API keys survive, as after a reset. After commit, the existingOnUserSessionsRevokedhook runs, so every node drops the Jellyfin-compatible sessions it holds in memory. The newRevokeOtherSignInsInTransactionshares its SQL withRevokeSignInsForUsersInTransaction; existing callers keep no session and revoke the same rows as before.Contract: the member is optional and defaults to false;
nullis a 422. The response stays204.GET /api/v2/account/password/capabilitygainssign_out_other_sessions. Servers without this change reject the member as unknown, so clients send it only when the capability says so; the web form follows that rule./api/v1is unchanged. Docs:docs/auth-api.md,docs/architecture/password-resets.md, and the migration ledger notes.Validation
main(new option); removing the clause that keeps the caller's session, or ignoring the flag, makes it fail.main(no checkbox) and passes here. The v2 handler test covers the member, its default, andnull.gofmt,go vet,make lint-changed, router-recovery lint, web lint/format/build/budget,make test-web, and every contract and hygiene verifier pass.make test-gopasses exceptinternal/mediasampleTestRunStatsWithRealFFmpeg, which fails the same way onmainwith the local ffmpeg build.make verify-actionlintwas not run (no workflow changes; actionlint not installed locally). After rebasing onto currentmain, the focusedinternal/auth,internal/apiv2andinternal/api/handlerstests, the AccountSettings web test, changed-line lint and the v2 contract verifiers pass. The new Postgres test runs in CI's database-contracts job.internal/audiobooks/absTestTokenHandlers_ScopeLibrariesToAuthenticatedProfilefails the same way onmain, as doesmake verify-route-inventory; this pull request touches neither the package nor any route.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-2898/
Surface and build: web app Settings > Account, desktop and phone width, sandbox built from
origin/main(before) and this branch (after).Risks
/authorizestore tokens while holding the account'susersrowFOR SHARE(fix(audiobooks): refuse Audiobookshelf tokens minted during a sign-out everywhere #2919, which closed [bug] An Audiobookshelf token refreshed during a sign-out-everywhere stays valid #2907). The password change holds that row from itsUPDATE usersuntil it commits, so a token issued at the same moment is either revoked by the change or refused afterwards with 401.Follow-ups
Checklist
AI Disclosure
nullmember would slip past validation (fixed with the existing null guard), that the user manual needs an update (tracked below), and a pre-existing Audiobookshelf race (filed as [bug] An Audiobookshelf token refreshed during a sign-out-everywhere stays valid #2907). A multi-agent code review of the final diff (claude-opus-5-5 finders and verifiers, claude-sonnet-5-5 for the cleanup and validation passes) confirmed that the web form sent the member without checking the capability, which would fail every password change against an older node; the form now shows the checkbox only when offered and sends the member only when ticked. It also flagged a copy assertion in the web test, now removed. It refuted the other candidates with evidence: the hook's request context (Jellyfin lookups re-read the stored row), widening the temporary-password revoke (those sign-ins can't exist under a temporary password), and the default-path test step (the only guard that the default stays). The background adversarial review (gpt-6.1-sol, reviewed a655084) found nothing further.🤖 Generated with Claude Code
Note
Add
sign_out_other_sessionsoption to v2 password changesign_out_other_sessionsboolean to the v2 change-password request, with a matching capability flag in the account-password capability response (required in the schema). The v1 handler and API do not expose it.Service.ChangePasswordandUserRepository.ReplacePasswordSigningOutOthersin service.go and repository.go.login-sessionsquery after an opted-in change. Includes OpenAPI/TypeScript schema updates, docs, and a database-backed integration testTestChangePasswordSignOutOtherSessionsDB.ChangePasswordgains a boolean argument onaccountPasswordService,AccountPasswordService, andAccountServiceinterfaces; v2 rejects a nullsign_out_other_sessionsmember, and omission defaults to no sign-out (existing behavior).Macroscope summarized aa593a6.