|
| 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. |
0 commit comments