Repository navigation
fix(deploy): register accounts without leaving a session behind - #159
Merged
Merged
Conversation
Synapse's shared-secret registration also signs the new account in (a device and access token) unless the request sets inhibit_login. register_new_matrix_user cannot ask for that and throws the token away, so every install left one unused session on the owner account (listed in their Matrix app) and one on @mm-core. _register_user now performs the same handshake itself (nonce, HMAC-SHA1 over nonce/user/password/admin) with inhibit_login, using a short standard-library script run by Synapse's own Python inside its container. The password still reaches it on stdin only. An existing account fails with Synapse's answer (M_USER_IN_USE), as before. Tests: a fake Synapse checks the MAC as v1.163 does and records whether a device was created. Checked against a real matrixdotorg/synapse:v1.163.0 container: accounts registered this way have no devices, while register_new_matrix_user leaves one never-used device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #157. The live test of #157 found one unused session on the owner account (
@admin) and a second session on@mm-core. This PR stops the installer creating them.Cause
Synapse's shared-secret registration (
/_synapse/admin/v1/register) also signs the new account in, creating a device and an access token, unless the request setsinhibit_login.register_new_matrix_userhas no option for that, and it throws the token away. So every install so far has left:@mm-core, since fix(deploy): close five self-host installer gaps; mmctl upgrade --to; mm-core's own Synapse account #157.Fix
_register_user(deploy/lib/bootstrap.sh) now does the same handshake itself, withinhibit_login: true:admin, keyed withregistration_shared_secret;It runs as a short standard-library Python script under Synapse's own Python, inside its container, the way
register_new_matrix_userruns. Behaviour is otherwise the same:M_USER_IN_USE);Existing installs
Installs from before keep that one session on the owner account. It has no name, and "last seen" is empty, so signing it out from the app is safe; the CHANGELOG says so. The installer leaves the owner's sessions alone: telling this session apart from a real one relies on a heuristic, and #157 settled that a re-run leaves the owner account alone.
Tests
deploy/test/fixtures/fake_synapse_register.py, a fake Synapse that checks the MAC as v1.163 does and records whether a device was created. Removinginhibit_loginfails 2 of them.matrixdotorg/synapse:v1.163.0container (local, now removed). Its generated config has a quoted secret with symbols, which the parser handled. Results:@mm-corehad only the 1 sign-in I made;register_new_matrix_user, for comparison, had an extra never-used device (last_seen_ts: null);🤖 Generated with Claude Code