You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/setup/migration.md
+89-43
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,25 @@
1
1
# Migrating an existing homeserver
2
2
3
-
One of the design goals of MAS has been to allow it to be used to migrate an existing homeserver to an OIDC-based architecture.
3
+
One of the design goals of MAS has been to allow it to be used to migrate an existing homeserver, specifically without requiring users to re-authenticate and ensuring that all existing clients continue to work.
4
4
5
-
Specifically without requiring users to re-authenticate and that non-OIDC clients continue to work.
6
-
7
-
Features that are provided to support this include:
5
+
Features that support this include:
8
6
9
7
- Ability to import existing password hashes from Synapse
10
8
- Ability to import existing sessions and devices
11
-
- Ability to import existing access tokens linked to devices (ie not including short-lived admin puppeted access tokens)
9
+
- Ability to import existing access tokens
12
10
- Ability to import existing upstream IdP subject ID mappings
13
11
- Provides a compatibility layer for legacy Matrix authentication
14
12
15
-
There will be tools to help with the migration process itself. But these aren't quite ready yet.
16
-
17
13
## Preparing for the migration
18
14
19
-
The deployment is non-trivial so it is important to read through and understand the steps involved and make a plan before starting.
15
+
The deployment is non-trivial, so it is important to read through and understand the steps involved and make a plan before starting.
20
16
21
17
### Is your setup ready to be migrated?
22
18
23
19
#### SAML2 and LDAP Single Sign-On Providers are not supported
24
20
25
-
A deployment which requires SAML or LDAP-based authentication should use a service like [Dex](https://github.com/dexidp/dex) to bridge between the SAML provider and the authentication service.
26
-
MAS is different from Synapse in that it does **not** have built-in support for SAML or LDAP-based providers.
21
+
A deployment that requires SAML or LDAP-based authentication should use a service like [Dex](https://github.com/dexidp/dex) to bridge between the SAML provider and the authentication service.
22
+
MAS differs from Synapse in that it does **not** have built-in support for SAML or LDAP-based providers.
27
23
28
24
#### Custom password providers are not supported
29
25
@@ -32,28 +28,34 @@ If your Synapse homeserver currently uses a custom password provider module, ple
32
28
#### SQLite databases are not supported
33
29
34
30
It is worth noting that MAS currently only supports PostgreSQL as a database backend.
31
+
The migration tool only supports reading from PostgreSQL for the Synapse database as well.
35
32
36
33
### Install and configure MAS alongside your existing homeserver
37
34
38
35
Follow the instructions in the [installation guide](installation.md) to install MAS alongside your existing homeserver.
39
36
40
37
You'll need a blank PostgreSQL database for MAS to use; it does not share the database with the homeserver.
41
38
42
-
Set up a configuration file but don't start MAS, or create any users, yet.
39
+
MAS provides a tool to generate a configuration file based on your existing Synapse configuration. This is useful for kickstarting your new configuration.
When using this tool, be careful to examine the log output for any warnings about unsupported configuration options.
43
46
44
47
#### Local passwords
45
48
46
-
Synapse uses bcrypt as its password hashing scheme while MAS defaults to using the newer argon2id.
49
+
Synapse uses bcrypt as its password hashing scheme, while MAS defaults to using the newer argon2id.
47
50
You will have to configure the version 1 scheme as bcrypt for migrated passwords to work.
48
-
It is also recommended that you keep argon2id as version 2 so that once users log in, their hashes will be updated to the newer recommended scheme.
49
-
If you have a `pepper` set in the `password_config` section of your Synapse config, then you need to specify this `pepper` as the `secret` field for your `bcrypt` scheme.
51
+
It is also recommended that you keep argon2id as version 2 so that once users log in, their hashes will be updated to the newer, recommended scheme.
50
52
51
53
Example passwords configuration:
52
54
```yml
53
55
passwords:
54
56
enabled: true
55
57
schemes:
56
-
- version: 1# TODO I think v:2 has to come first in this list
58
+
- version: 1
57
59
algorithm: bcrypt
58
60
# Optional, must match the `password_config.pepper` in the Synapse config
59
61
#secret: secretPepperValue
@@ -70,22 +72,59 @@ The migration checker will inform you if this has not been configured properly.
70
72
If you are using an upstream SSO provider, then you will need to configure the upstream provider in MAS manually.
71
73
72
74
MAS does not support SAML or LDAP upstream providers.
73
-
If you are using one of these, you will need to use an adapter such as Dex at this time,
74
-
but we have not yet documented this procedure.
75
+
If you are using one of these, you will need to use an adapter such as Dex at this time, but we have not yet documented this procedure.
75
76
76
77
Each upstream provider that was used by at least one user in Synapse will need to be configured in MAS.
77
78
78
79
Set the `synapse_idp_id` attribute on the provider to:
79
80
80
81
- `"oidc"`if you used an OIDC provider in Synapse's legacy `oidc_config` configuration section.
81
-
- `"oidc-myprovider"`if you used an OIDC provider in Synapse's `oidc_providers` configuration list,
82
-
with a `provider` of `"myprovider"`.
82
+
- `"oidc-myprovider"`if you used an OIDC provider in Synapse's `oidc_providers` configuration list, with a `provider` of `"myprovider"`.
83
83
(This is because Synapse prefixes the provider ID with `oidc-` internally.)
84
84
85
-
Without the `synapse_idp_id`s being set, syn2mas does not understand which providers
86
-
in Synapse correspond to which provider in MAS.
85
+
Without the `synapse_idp_id`s being set, `mas-cli syn2mas` does not understand which providers in Synapse correspond to which provider in MAS.
86
+
87
+
For example, if your Synapse configuration looked like this:
Having done the preparation, you can now proceed with the actual migration. Note that this will require downtime for the homeserver and is not easily reversible.
161
+
Having completed the preparation, you can now proceed with the actual migration. Note that this will require downtime for the homeserver and is not easily reversible.
115
162
116
163
### Backup your data and configuration
117
164
118
-
As with any migration, it is important to backup your data before proceeding.
165
+
As with any migration, it is important to back up your data before proceeding.
119
166
120
-
We also suggest making a backup copy of your homeserver's known good configuration,
121
-
before making any changes to enable MAS integration.
167
+
We also suggest making a backup copy of your homeserver's known good configuration before making any changes to enable MAS integration.
122
168
123
-
### Shutdown the homeserver
169
+
### Shut down the homeserver
124
170
125
-
This is to ensure that no new sessions are created whilst the migration is in progress.
171
+
This ensures that no new sessions are created while the migration is in progress.
126
172
127
173
### Configure the homeserver to enable MAS integration
128
174
129
175
Follow the instructions in the [homeserver configuration guide](homeserver.md) to configure the homeserver to use MAS.
130
176
131
177
### Do the import
132
178
133
-
Once the homeserver has been stopped, MAS has been configured (but is not running!)
134
-
and you have a successful migration check,
135
-
run `syn2mas`'s `migrate` command.
136
-
137
-
Other than the change of command word, the syntax is exactly the same as the `check` command.
179
+
Once the homeserver has been stopped, MAS has been configured (but is not running!), and you have a successful migration check, run `syn2mas`'s `migrate` command.
- You can either try to fix the error and make another attempt by re-running the command; or
148
-
- you can revert your homeserver configuration (so MAS integration is disabled once more)
149
-
and abort the migration for now. In this case, you should not start MAS up.
189
+
- You can try to fix the error and make another attempt by re-running the command; or
190
+
- You can revert your homeserver configuration (so MAS integration is disabled once more) and abort the migration for now. In this case, you should not start MAS up.
191
+
192
+
In *some cases*, MAS may have written to its own database during a failed migration, causing it to complain in subsequent runs.
193
+
In this case, you can safely delete and recreate the MAS database, then start over.
194
+
195
+
In *any case*, the migration tool itself **will not** write to the Synapse database, so as long as MAS hasn't been started, it is safe to roll back the migration without restoring the Synapse database.
150
196
151
197
Please report migration failures to the developers.
0 commit comments