Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 62e0188

Browse files
committed
Small documentation fixes
- Removes mentions of the `mas-cli templates save` command - Removes the old `experimental` flags - Removes the old `policy.data.passwords` configs - Document the `policy.data.client_registration` flags - Remove references to the pre-built macOS binaries - Explains how to get syn2mas - State that you need to prepare the database before importing data - Clean up the reverse proxy documentation - Clarify that you don't need to provede templates/policy/assets manually when running the docker image
1 parent c8afc48 commit 62e0188

File tree

7 files changed

+152
-86
lines changed

7 files changed

+152
-86
lines changed

docs/reference/cli/templates.md

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
11
# `templates`
22

3-
Helps customizing templates.
3+
## `templates check`
44

5-
## `templates save <path>`
6-
7-
Save the builtin template in the specified folder.
8-
9-
```console
10-
$ mas-cli templates save ./templates
11-
INFO mas_core::templates: Wrote template path="./templates/login.html"
12-
INFO mas_core::templates: Wrote template path="./templates/register.html"
13-
INFO mas_core::templates: Wrote template path="./templates/index.html"
14-
INFO mas_core::templates: Wrote template path="./templates/reauth.html"
15-
INFO mas_core::templates: Wrote template path="./templates/form_post.html"
16-
INFO mas_core::templates: Wrote template path="./templates/error.html"
17-
INFO mas_core::templates: Wrote template path="./templates/base.html"
18-
```
19-
20-
By default this command won't overwrite existing files, but this behavior can be changed by adding the `--overwrite` flag.
21-
22-
## `templates check <path>`
23-
24-
Check the validity of the templates in the specified folder.
5+
Check the validity of the templates loaded by the config.
256
It compiles the templates and then renders them with different contexts.
267

278
```console
28-
$ mas-cli templates check ./templates
29-
INFO mas_core::templates: Loading builtin templates
9+
$ mas-cli templates check
3010
INFO mas_core::templates: Loading templates from filesystem path=./templates/**/*.{html,txt}
3111
INFO mas_core::templates::check: Rendering template name="login.html" context={"csrf_token":"fake_csrf_token","form":{"fields_errors":{},"form_errors":[],"has_errors":false}}
3212
INFO mas_core::templates::check: Rendering template name="register.html" context={"__UNUSED":null,"csrf_token":"fake_csrf_token"}
3313
INFO mas_core::templates::check: Rendering template name="index.html" context={"csrf_token":"fake_csrf_token","current_session":{"active":true,"created_at":"2021-09-24T13:26:52.962135085Z","id":1,"last_authd_at":"2021-09-24T13:26:52.962135316Z","user_id":2,"username":"john"},"discovery_url":"https://example.com/.well-known/openid-configuration"}
3414
...
3515
```
36-
37-
Builtin templates are still loaded by default when running this command, but this can be skipped by adding the `--skip-builtin` flag.

docs/reference/configuration.md

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ passwords:
253253
# If disabled, users will only be able to log in using upstream OIDC providers
254254
enabled: true
255255
256+
# Minimum complexity required for passwords, estimated by the zxcvbn algorithm
257+
# Must be between 0 and 4, default is 3
258+
# See https://github.com/dropbox/zxcvbn#usage for more information
259+
minimum_complexity: 3
260+
256261
# List of password hashing schemes being used
257262
# /!\ Only change this if you know what you're doing
258263
# TODO: document this section better
@@ -345,20 +350,13 @@ policy:
345350
# Dynamic Client Registration
346351
client_registration:
347352
# don't require URIs to be on the same host. default: false
348-
allow_host_mismatch: true
353+
allow_host_mismatch: false
349354
# allow non-SSL and localhost URIs. default: false
350-
allow_insecure_uris: true
351-
352-
# Registration using passwords
353-
passwords:
354-
# minimum length of a password. default: 0
355-
min_length: 8
356-
# require at least one lowercase character in a password. default: false
357-
require_lowercase: true
358-
# require at least one uppercase character in a password. default: false
359-
require_uppercase: true
360-
# require at least one number in a password. default: false
361-
require_number: true
355+
allow_insecure_uris: false
356+
# don't require clients to provide a client_uri. default: false
357+
allow_missing_client_uri: false
358+
# don't require clients to provide a contacts field. default: false
359+
allow_missing_contacts: false
362360
```
363361
364362
## `rate_limiting`
@@ -638,16 +636,4 @@ experimental:
638636

639637
# Time-to-live of compatibility access tokens in seconds, when refresh tokens are supported. Defaults to 300, 5 minutes.
640638
#compat_token_ttl: 300
641-
642-
# Whether to enable self-service password registration. Defaults to `true` if password authentication is enabled.
643-
#password_registration_enabled: false
644-
645-
# Whether users are allowed to change their email addresses. Defaults to `true`.
646-
#email_change_allowed: false
647-
648-
# Whether users are allowed to change their display names. Defaults to `true`.
649-
#displayname_change_allowed: false
650-
651-
# Whether users are allowed to change their passwords. Defaults to `true`.
652-
#password_change_allowed: false
653639
```

docs/setup/general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mas-cli config generate > config.yaml
1818
If you're using the docker container, the command `mas-cli` can be invoked with `docker run`:
1919

2020
```sh
21-
docker run ghcr.io/matrix-org/matrix-authentication-service:main config generate > config.yaml
21+
docker run ghcr.io/matrix-org/matrix-authentication-service config generate > config.yaml
2222
```
2323

2424
This applies to all of the `mas-cli` commands in this document.

docs/setup/installation.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
## Pre-built binaries
44

5-
Pre-built binaries can be found attached on each release, for Linux and macOS, on both `x86_64` and `aarch64` architectures.
5+
Pre-built binaries can be found attached on each release, for Linux on both `x86_64` and `aarch64` architectures.
66

77
- [`mas-cli-aarch64-linux.tar.gz`](https://github.com/matrix-org/matrix-authentication-service/releases/latest/download/mas-cli-aarch64-linux.tar.gz)
88
- [`mas-cli-x86_64-linux.tar.gz`](https://github.com/matrix-org/matrix-authentication-service/releases/latest/download/mas-cli-x86_64-linux.tar.gz)
9-
- [`mas-cli-aarch64-macos.tar.gz`](https://github.com/matrix-org/matrix-authentication-service/releases/latest/download/mas-cli-aarch64-macos.tar.gz)
10-
- [`mas-cli-x86_64-macos.tar.gz`](https://github.com/matrix-org/matrix-authentication-service/releases/latest/download/mas-cli-x86_64-macos.tar.gz)
119

1210
Each archive contains:
1311

@@ -27,7 +25,7 @@ Example shell commands to download and extract the `mas-cli` binary:
2725

2826
```sh
2927
ARCH=x86_64 # or aarch64
30-
OS=linux # or macos
28+
OS=linux
3129
VERSION=latest # or a specific version, like "v0.1.0"
3230

3331
# URL to the right archive
@@ -41,13 +39,12 @@ curl -sL "$URL" | tar xzC /path/to/mas
4139
/path/to/mas/mas-cli --help
4240
```
4341

44-
**Note for macOS users**: the binaries are not signed, so if the archive is downloaded from a browser, it may be necessary to run `xattr -d com.apple.quarantine mas-cli` to remove the quarantine attribute on the binary.
45-
4642

4743
## Using the Docker image
4844

49-
A pre-built Docker image is available here: [`ghcr.io/matrix-org/matrix-authentication-service:main`](https://ghcr.io/matrix-org/matrix-authentication-service:main)
45+
A pre-built Docker image is available here: [`ghcr.io/matrix-org/matrix-authentication-service:latest`](https://ghcr.io/matrix-org/matrix-authentication-service:latest)
5046

47+
The `latest` tag is built using the latest release.
5148
The `main` tag is built from the `main` branch, and each commit on the `main` branch is also tagged with a stable `sha-<commit sha>` tag.
5249

5350
The image can also be built from the source:

docs/setup/migration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ There will be tools to help with the migration process itself. But these aren't
1818

1919
The deployment is non-trivial so it is important to read through and understand the steps involved and make a plan before starting.
2020

21+
### Get `syn2mas`
22+
23+
The easiest way to get `syn2mas` is through [`npm`](https://www.npmjs.com/package/@matrix-org/syn2mas):
24+
25+
```sh
26+
npm install -g @matrix-org/syn2mas
27+
```
28+
2129
### Run the migration advisor
2230

2331
You can use the advisor mode of the `syn2mas` tool to identify extra configuration steps or issues with the configuration of the homeserver.
@@ -38,6 +46,15 @@ If you are using an upstream SSO provider then you will need to provision the up
3846

3947
Each upstream provider will need to be given as an `--upstreamProviderMapping` command line option to the import tool.
4048

49+
### Prepare the MAS database
50+
51+
Once the database is created, it still needs to have its schema created and synced with the configuration.
52+
This can be done with the following command:
53+
54+
```sh
55+
mas-cli config sync
56+
```
57+
4158
### Do a dry-run of the import to test
4259

4360
```sh

docs/setup/reverse-proxy.md

Lines changed: 111 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ http:
1717
- name: oauth
1818
- name: compat
1919
- name: graphql
20-
# Uncomment to serve the assets by the service
21-
#- name: assets
22-
# path: ./share/assets/
20+
- name: assets
2321

2422
binds:
2523
# Bind on a local port
2624
- host: localhost
2725
port: 8080
28-
26+
2927
# OR bind on a Unix domain socket
3028
#- socket: /var/run/mas.sock
3129

@@ -37,9 +35,9 @@ http:
3735
#proxy_protocol: true
3836
```
3937

40-
## Example nginx configuration
38+
## Base nginx configuration
4139

42-
Note that the assets can be served directly by nginx, and the `assets` resource can be removed from the service configuration.
40+
A basic configuration for `nginx`, which proxies traffic to the service would look like this:
4341

4442
```nginx
4543
server {
@@ -51,32 +49,21 @@ server {
5149
ssl_certificate_key path/to/privkey.pem;
5250
5351
location / {
52+
proxy_http_version 1.1;
5453
proxy_pass http://localhost:8080;
5554
# OR via the Unix domain socket
5655
#proxy_pass http://unix:/var/run/mas.sock;
57-
58-
proxy_http_version 1.1;
5956
60-
# Optional: use the PROXY protocol
57+
# Forward the client IP address
58+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
59+
# or, using the PROXY protocol
6160
#proxy_protocol on;
6261
}
63-
64-
# Optional: serve the assets directly
65-
location /assets/ {
66-
root /path/to/share/assets/;
67-
68-
# Serve pre-compressed assets
69-
gzip_static on;
70-
# With the ngx_brotli module installed
71-
# https://github.com/google/ngx_brotli
72-
#brotli_static on;
73-
74-
# Cache assets for a year
75-
expires 365d;
76-
}
7762
}
7863
```
7964

65+
## Compatibility layer
66+
8067
For the compatibility layer, the following endpoints need to be proxied to the service:
8168

8269
- `/_matrix/client/*/login`
@@ -91,16 +78,17 @@ server {
9178
listen [::]:443 ssl http2;
9279
9380
server_name matrix.example.com;
94-
81+
9582
# Forward to the auth service
9683
location ~ ^/_matrix/client/(.*)/(login|logout|refresh) {
84+
proxy_http_version 1.1;
9785
proxy_pass http://localhost:8080;
9886
# OR via the Unix domain socket
9987
#proxy_pass http://unix:/var/run/mas.sock;
100-
101-
proxy_http_version 1.1;
10288
103-
# Optional: use the PROXY protocol
89+
# Forward the client IP address
90+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
91+
# or, using the PROXY protocol
10492
#proxy_protocol on;
10593
}
10694
@@ -116,4 +104,99 @@ server {
116104
proxy_http_version 1.1;
117105
}
118106
}
119-
```
107+
```
108+
109+
## Preserve the client IP
110+
111+
For rate-limiting and logging purposes, MAS needs to know the client IP address, which can be lost when using a reverse proxy.
112+
There are two ways to preserve the client IP address
113+
114+
### `X-Forwarded-For` header
115+
116+
MAS can infer the client IP address from the `X-Forwarded-For` header.
117+
It will trust the value for this header only if the request comes from a trusted reverse proxy.
118+
119+
The range of IPs that can be trusted is configured using the `trusted_proxies` configuration option, which has the default private IP ranges.
120+
121+
```yaml
122+
http:
123+
trusted_proxies:
124+
- 192.168.0.0/16
125+
- 172.16.0.0/12
126+
- 10.0.0.0/10
127+
- 127.0.0.1/8
128+
- fd00::/8
129+
- ::1/128
130+
```
131+
132+
With nginx, this can be achieved by setting the `proxy_set_header` directive to `X-Forwarded-For $proxy_add_x_forwarded_for`.
133+
134+
### Proxy protocol
135+
136+
MAS supports the [PROXY protocol](https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt) to preserve the client IP address.
137+
To enable it, enable the `proxy_protocol` option on the listener:
138+
139+
```yaml
140+
http:
141+
listeners:
142+
- name: web
143+
resources:
144+
- name: discovery
145+
- name: human
146+
- name: oauth
147+
- name: compat
148+
- name: graphql
149+
- name: assets
150+
binds:
151+
- address: "[::]:8080"
152+
proxy_protocol: true
153+
```
154+
155+
With nginx, this can be achieved by setting the `proxy_protocol` directive to `on` in the `location` block.
156+
157+
## Serve assets directly
158+
159+
To avoid unnecessary round-trips, the assets can be served directly by nginx, and the `assets` resource can be removed from the service configuration.
160+
161+
```yaml
162+
http:
163+
listeners:
164+
- name: web
165+
resources:
166+
- name: discovery
167+
- name: human
168+
- name: oauth
169+
- name: compat
170+
- name: graphql
171+
# MAS doesn't need to serve the assets anymore
172+
#- name: assets
173+
binds:
174+
- address: "[::]:8080"
175+
proxy_protocol: true
176+
```
177+
178+
Make sure the assets directory served by nginx is up to date.
179+
180+
```nginx
181+
server {
182+
# --- SNIP ---
183+
184+
location / {
185+
# --- SNIP ---
186+
}
187+
188+
# Make nginx serve the assets directly
189+
location /assets/ {
190+
root /path/to/share/assets/;
191+
192+
# Serve pre-compressed assets
193+
gzip_static on;
194+
# With the ngx_brotli module installed
195+
# https://github.com/google/ngx_brotli
196+
#brotli_static on;
197+
198+
# Cache assets for a year
199+
expires 365d;
200+
}
201+
}
202+
```

docs/setup/running.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ Other than the binary, the service needs a few files to run:
2121

2222
Be sure to check the [installation instructions](./installation.md) for more information on how to get these files, and make sure the configuration file is updated accordingly.
2323

24+
**If you are using [the docker image](./installation.md#using-the-docker-image)**, everything is already included in the image at the right place, so in most cases you don't need to do anything.
25+
26+
**If you are using [the pre-built binaries](./installation.md#pre-built-binaries)**, those files are shipped alongside them in the `share` directory.
27+
The default configuration will look for them from the current working directory, meaning that you don't have to adjust the paths, as long as you are running the service from the parent directory of the `share` directory.
28+
2429
## Configure the HTTP server
2530

2631
The service can be configured to have multiple HTTP listeners, serving different resources.

0 commit comments

Comments
 (0)