Skip to content

Commit d88c1af

Browse files
clokepphil-flex
authored andcommitted
Add developer documentation for running a local CAS server (matrix-org#7147)
1 parent f71d543 commit d88c1af

3 files changed

Lines changed: 71 additions & 2 deletions

File tree

changelog.d/7147.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add documentation for running a local CAS server for testing.

docs/dev/cas.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# How to test CAS as a developer without a server
2+
3+
The [django-mama-cas](https://github.com/jbittel/django-mama-cas) project is an
4+
easy to run CAS implementation built on top of Django.
5+
6+
## Prerequisites
7+
8+
1. Create a new virtualenv: `python3 -m venv <your virtualenv>`
9+
2. Activate your virtualenv: `source /path/to/your/virtualenv/bin/activate`
10+
3. Install Django and django-mama-cas:
11+
```
12+
python -m pip install "django<3" "django-mama-cas==2.4.0"
13+
```
14+
4. Create a Django project in the current directory:
15+
```
16+
django-admin startproject cas_test .
17+
```
18+
5. Follow the [install directions](https://django-mama-cas.readthedocs.io/en/latest/installation.html#configuring) for django-mama-cas
19+
6. Setup the SQLite database: `python manage.py migrate`
20+
7. Create a user:
21+
```
22+
python manage.py createsuperuser
23+
```
24+
1. Use whatever you want as the username and password.
25+
2. Leave the other fields blank.
26+
8. Use the built-in Django test server to serve the CAS endpoints on port 8000:
27+
```
28+
python manage.py runserver
29+
```
30+
31+
You should now have a Django project configured to serve CAS authentication with
32+
a single user created.
33+
34+
## Configure Synapse (and Riot) to use CAS
35+
36+
1. Modify your `homeserver.yaml` to enable CAS and point it to your locally
37+
running Django test server:
38+
```yaml
39+
cas_config:
40+
enabled: true
41+
server_url: "http://localhost:8000"
42+
service_url: "http://localhost:8081"
43+
#displayname_attribute: name
44+
#required_attributes:
45+
# name: value
46+
```
47+
2. Restart Synapse.
48+
49+
Note that the above configuration assumes the homeserver is running on port 8081
50+
and that the CAS server is on port 8000, both on localhost.
51+
52+
## Testing the configuration
53+
54+
Then in Riot:
55+
56+
1. Visit the login page with a Riot pointing at your homeserver.
57+
2. Click the Single Sign-On button.
58+
3. Login using the credentials created with `createsuperuser`.
59+
4. You should be logged in.
60+
61+
If you want to repeat this process you'll need to manually logout first:
62+
63+
1. http://localhost:8000/admin/
64+
2. Click "logout" in the top right.

docs/dev/saml.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ To make Synapse (and therefore Riot) use it:
1818
metadata:
1919
local: ["samling.xml"]
2020
```
21-
5. Run `apt-get install xmlsec1` and `pip install --upgrade --force 'pysaml2>=4.5.0'` to ensure
21+
5. Ensure that your `homeserver.yaml` has a setting for `public_baseurl`:
22+
```yaml
23+
public_baseurl: http://localhost:8080/
24+
```
25+
6. Run `apt-get install xmlsec1` and `pip install --upgrade --force 'pysaml2>=4.5.0'` to ensure
2226
the dependencies are installed and ready to go.
23-
6. Restart Synapse.
27+
7. Restart Synapse.
2428

2529
Then in Riot:
2630

0 commit comments

Comments
 (0)