mirror of
https://github.com/sitn/django-dotnetid-example.git
synced 2026-08-26 00:14:15 +00:00
A demo implementing django-dotnetid | Read-only mirror of https://github.com/sitn/django-dotnetid-example — Canton de Neuchâtel. Issues & pull requests at the source.
- Python 55.9%
- TypeScript 19%
- CSS 11.9%
- HTML 7.1%
- Dockerfile 6.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| apache | ||
| back | ||
| front | ||
| .dockerignore | ||
| .gitignore | ||
| docker-compose.yaml | ||
| Dockerfile | ||
| README.md | ||
OpenID BFF with Django
A simple Django project with openid working with dotnetaccess
With Docker
cp back/.env.sample back/.env
Add your secrets to your env then
docker compose up -d
Then go to https://localhost
Without Docker
Requirements
- openssl in order to generate certificates. Easier to use WSL if you're on Windows.
Backend
cp .env.sample .env
Then adapt the .env file
python -m venv venv
./venv/Scripts/activate
pip install -r requirements.txt
cd back
python manage.py migrate
python manage.py runserver
Go to http://127.0.0.1:8000
Backend should work. Authentication on backend should also work.
⚠ Do not change docker port on local, the only allowed host registered on OpenID is http://127.0.0.1:8000
Frontend and BFF
We want a frontend to access secured backend endpoints. On a separate terminal, run the frontend
cd front
npm run start
Now, we need a proxy for two reasons:
- Avoid cross domain cookies (possible but needs extra config)
- HTTPS endpoints
In a new terminal (a wsl one if you're on windows), generate the certificates:
openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout apache/certs/server.key \
-out apache/certs/server.crt \
-subj "/CN=localhost"
Two files should appear in apache/certs folder.
Now you can run apache in a Docker container or copy your certification to your installation.
Go to https://localhost
Login should work.