mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 09:35:45 +03:00
4218473f9e
This makes the CAS handler look more like the SAML/OIDC handlers: * Render errors to users instead of throwing JSON errors. * Internal reorganization.
2 KiB
2 KiB
How to test CAS as a developer without a server
The django-mama-cas project is an easy to run CAS implementation built on top of Django.
Prerequisites
- Create a new virtualenv:
python3 -m venv <your virtualenv>
- Activate your virtualenv:
source /path/to/your/virtualenv/bin/activate
- Install Django and django-mama-cas:
python -m pip install "django<3" "django-mama-cas==2.4.0"
- Create a Django project in the current directory:
django-admin startproject cas_test .
- Follow the install directions for django-mama-cas
- Setup the SQLite database:
python manage.py migrate
- Create a user:
python manage.py createsuperuser
- Use whatever you want as the username and password.
- Leave the other fields blank.
- Use the built-in Django test server to serve the CAS endpoints on port 8000:
python manage.py runserver
You should now have a Django project configured to serve CAS authentication with a single user created.
Configure Synapse (and Element) to use CAS
- Modify your
homeserver.yaml
to enable CAS and point it to your locally running Django test server:cas_config: enabled: true server_url: "http://localhost:8000" service_url: "http://localhost:8081" #displayname_attribute: name #required_attributes: # name: value
- Restart Synapse.
Note that the above configuration assumes the homeserver is running on port 8081 and that the CAS server is on port 8000, both on localhost.
Testing the configuration
Then in Element:
- Visit the login page with a Element pointing at your homeserver.
- Click the Single Sign-On button.
- Login using the credentials created with
createsuperuser
. - You should be logged in.
If you want to repeat this process you'll need to manually logout first:
- http://localhost:8000/admin/
- Click "logout" in the top right.