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

Commit 3891e0a

Browse files
committed
Adapted documentation to changed lib
1 parent 13bccbb commit 3891e0a

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

docs/jwt.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,15 @@ As with other login types, there are additional fields (e.g. `device_id` and
3636

3737
## Preparing Synapse
3838

39-
The JSON Web Token integration in Synapse uses the
40-
[`PyJWT`](https://pypi.org/project/pyjwt/) library, which must be installed
41-
as follows:
42-
43-
* The relevant libraries are included in the Docker images and Debian packages
44-
provided by `matrix.org` so no further action is needed.
45-
46-
* If you installed Synapse into a virtualenv, run `/path/to/env/bin/pip
47-
install synapse[pyjwt]` to install the necessary dependencies.
48-
49-
* For other installation mechanisms, see the documentation provided by the
50-
maintainer.
51-
52-
To enable the JSON web token integration, you should then add an `jwt_config` section
39+
To enable the JSON web token integration, you should add a `jwt_config` section
5340
to your configuration file (or uncomment the `enabled: true` line in the
5441
existing section). See [sample_config.yaml](./sample_config.yaml) for some
5542
sample settings.
5643

5744
## How to test JWT as a developer
5845

5946
Although JSON Web Tokens are typically generated from an external server, the
60-
examples below use [PyJWT](https://pyjwt.readthedocs.io/en/latest/) directly.
47+
example below uses a locally generated JWT.
6148

6249
1. Configure Synapse with JWT logins, note that this example uses a pre-shared
6350
secret and an algorithm of HS256:
@@ -70,9 +57,13 @@ examples below use [PyJWT](https://pyjwt.readthedocs.io/en/latest/) directly.
7057
```
7158
2. Generate a JSON web token:
7259
60+
There's a small script for doing so locally:
61+
`scripts-dev/build_custom_jwt.py`. Have a look inside and set key/secret
62+
and the algorithm to be used (`HS256` or `RS256`) as well as the payload
63+
7364
```bash
74-
$ pyjwt --key=my-secret-token --alg=HS256 encode sub=test-user
75-
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0LXVzZXIifQ.Ag71GT8v01UO3w80aqRPTeuVPBIBZkYhNTJJ-_-zQIc
65+
$ poetry run scripts-dev/build_custom_jwt.py
66+
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMSIsImF1ZCI6WyJhdWRpZW5jZSJdfQ.fRrThuWvok5_gOYKyiIVtKTqZuFhYffiiBLTsIIZPwD-cqwICcSNkLtdhfzfau2Yje48XUiqh19VqP17MnnjGbjBTlotyHonXeXRtIKi5nK1DdKoibUkY8ILeXcDfhHe_lCItzjVtmZm7t4ePe6861Y3TQnbCgM2PBQszYOh1KU
7667
```
7768
3. Query for the login types and ensure `org.matrix.login.jwt` is there:
7869

0 commit comments

Comments
 (0)