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%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-04 09:22:05 +02:00
apache dockerize, pypi 2025-12-19 11:00:23 +01:00
back update demo 2026-06-04 09:22:05 +02:00
front handle initial cookie 2026-05-29 14:09:27 +02:00
.dockerignore dockerize 2024-01-29 14:09:19 +01:00
.gitignore bff working 2025-07-01 10:46:58 +02:00
docker-compose.yaml dockerize, pypi 2025-12-19 11:00:23 +01:00
Dockerfile dockerize, pypi 2025-12-19 11:00:23 +01:00
README.md update ENV doc 2025-12-19 11:46:21 +01:00

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:

  1. Avoid cross domain cookies (possible but needs extra config)
  2. 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.