🔗 Accompanying code for the post of the UB Labs Blog. 🔗
This project is a copy of django-allauth/examples/regular-django (tag 64.0.0).
Changes:
- settings.py
- Disable (comment) all login provider execpt openid-connect
- Add:
SOCIALACCOUNT_PROVIDERS = { "openid_connect": { "APPS": [ { "provider_id": os.getenv("KC_PROVIDER_ID", "keycloak"), "name": "Keycloak", "client_id": os.getenv("KC_CLIENT_ID", "django"), "secret": os.getenv("KC_CLIENT_SECRET", "changeme"), "settings": { "server_url": os.getenv("KC_SERVER_URL", "http://localhost:8080/realms/example/.well-known/openid-configuration"), }, } ] } }
cp template.env .env
docker compose up -d
# Login admin/password
- Create realm example
- Create client django
- Lookup client credentials
- Export client secret
export KC_CLIENT_SECRET="changeme"
- Enable user registration in realm settings
make venv
# Django 5.0.7
# django-allauth 64.0.0
source venv/bin/activate
export KC_CLIENT_SECRET="changeme"
./manage.py migrate
./manage.py runserver