I made this before I found Keycloak. I switched to Keycloak. Thus, I won't be maintaining this anymore. (However, I'll leave everything up in case someone will benefit from it.)
SSO using Django and OAuth
git clone https://github.com/etnguyen03/unilogin
cd unilogin
pipenv install --deployAt this point, you will want to copy unilogin/settings/secret.sample.py
to unilogin/settings.secret.py and fill in as necessary. Take care of the following:
- Set
DEBUGtoFalsein a production environment. - Add your hostname to
ALLOWED_HOSTS. - Generate a Django secret key and set it in
SECRET_KEY. This can be done with:from django.core.management.utils import get_random_secret_key print(get_random_secret_key())
- Configure your database, see this.
The libraries included allow for the following databases, but only PostgreSQL and SQLite3
will be "officially" endorsed. However, I discourage the use of an SQLite3 database in production.
- PostgreSQL
- SQLite
- MariaDB
- MySQL
- Oracle
- Microsoft SQL
- Configure other settings, whose options and instructions are located in
secret.sample.py.
Then, run:
pipenv run python3 manage.py collectstatic
pipenv run python3 manage.py migrate
pipenv run gunicorn unilogin.wsgi The last line starts a gunicorn server.
In production, you should use a reverse proxy (Nginx?) that sets the
X_FORWARDED_FOR header to the client's actual IP.
First, download unilogin/settings/secret.sample.py, name it secret.py, and configure.
Then, you can use something like this:
docker run --restart=unless-stopped -p 8000:8000 -d -v $PWD/secret.py:/app/unilogin/settings/secret.py etnguyen03/uniloginHowever, you would likely need a database container. A docker-compose.yml is upcoming.
Copyright © 2020 Ethan Nguyen and contributors. All rights reserved.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.