@@ -36,28 +36,15 @@ As with other login types, there are additional fields (e.g. `device_id` and
36
36
37
37
## Preparing Synapse
38
38
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
53
40
to your configuration file (or uncomment the ` enabled: true ` line in the
54
41
existing section). See [ sample_config.yaml] ( ./sample_config.yaml ) for some
55
42
sample settings.
56
43
57
44
## How to test JWT as a developer
58
45
59
46
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 .
61
48
62
49
1 . Configure Synapse with JWT logins, note that this example uses a pre-shared
63
50
secret and an algorithm of HS256:
@@ -70,9 +57,13 @@ examples below use [PyJWT](https://pyjwt.readthedocs.io/en/latest/) directly.
70
57
` ` `
71
58
2. Generate a JSON web token:
72
59
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
+
73
64
` ` ` 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
76
67
` ` `
77
68
3. Query for the login types and ensure `org.matrix.login.jwt` is there :
78
69
0 commit comments