This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add developer documentation for running a local CAS server #7147
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add documentation for running a local CAS server for testing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# How to test CAS as a developer without a server | ||
|
||
The [django-mama-cas](https://github.com/jbittel/django-mama-cas) project is an | ||
easy to run CAS implementation built on top of Django. | ||
|
||
## Prerequisites | ||
|
||
1. Create a new virtualenv: `python3 -m venv <your virtualenv>` | ||
2. Activate your virtualenv: `source /path/to/your/virtualenv/bin/activate` | ||
3. Install Django and django-mama-cas: | ||
``` | ||
python -m pip install "django<3" "django-mama-cas==2.4.0" | ||
``` | ||
4. Create a Django project in the current directory: | ||
``` | ||
django-admin startproject cas_test . | ||
``` | ||
5. Follow the [install directions](https://django-mama-cas.readthedocs.io/en/latest/installation.html#configuring) for django-mama-cas | ||
6. Setup the SQLite database: `python manage.py migrate` | ||
7. Create a user: | ||
``` | ||
python manage.py createsuperuser | ||
``` | ||
1. Use whatever you want as the username and password. | ||
2. Leave the other fields blank. | ||
8. 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 Riot) to use CAS | ||
|
||
1. Modify your `homeserver.yaml` to enable CAS and point it to your locally | ||
running Django test server: | ||
```yaml | ||
cas_config: | ||
enabled: true | ||
server_url: "http://localhost:8000" | ||
service_url: "http://localhost:8081" | ||
#displayname_attribute: name | ||
#required_attributes: | ||
# name: value | ||
``` | ||
2. 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 Riot: | ||
|
||
1. Visit the login page with a Riot pointing at your homeserver. | ||
2. Click the Single Sign-On button. | ||
3. Login using the credentials created with `createsuperuser`. | ||
4. You should be logged in. | ||
|
||
If you want to repeat this process you'll need to manually logout first: | ||
|
||
1. http://localhost:8000/admin/ | ||
2. Click "logout" in the top right. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried following these instructions and got stuck here. The linked instructions ask me to run
migrate
, but I'm not sure what this means. There certainly isn't a binary namedmigrate
in my path.Then I tried
python manage.py migrate
, thinking that might be it, but there's no file calledmanage.py
.What am I missing? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a file called
manage.py
after running the step above this (django-admin startproject ...
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that works! Would probably help if I didn't test this in such a cluttered folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have liked the directions to be simpler, but...this seemed easier than a "full" CAS setup.