Stub OpenID Connect server for testing.
Primarily used to stub GOV.UK One Login for end-to-end tests and load testing of services that use it.
- Install Python 3.12
-
Create a virtual environment:
python3.12 -m venv --prompt . --upgrade-deps .venv
-
Activate the virtual environment:
source .venv/bin/activate
-
Install the dependencies:
pip install -e .[dev]
-
Run the server:
make run
To run the server as a container:
-
Build the Docker image:
docker build -t oidc_server .
-
Run the Docker image:
docker run --rm -p 5001:5001 -e FLASK_SERVER_NAME=localhost:5001 oidc_server
The server can also be run on a different port by specifying the PORT
environment variable:
docker run --rm -p 8000:8000 -e FLASK_SERVER_NAME=localhost:8000 -e PORT=8000 oidc_server
The image is also available on GitHub Container registry as ghcr.io/acteng/stub-oidc-server.
The server can be configured on start up using environment variables or at runtime using a Web API.
Use the following environment variables to create a user and register a client on start up:
Name | Value |
---|---|
FLASK_OIDC_USER_ID | OIDC user id |
FLASK_OIDC_USER_EMAIL | OIDC user email |
FLASK_OIDC_CLIENT_ID | OIDC client id |
FLASK_OIDC_CLIENT_REDIRECT_URI | OIDC client redirect URI |
FLASK_OIDC_CLIENT_PUBLIC_KEY | OIDC client public key |
FLASK_OIDC_CLIENT_SCOPE | OIDC client scope |
To create a user:
curl http://localhost:5001/users \
-H 'Content-Type: application/json' \
-d "{
\"id\": \"test-user\",
\"email\": \"[email protected]\"
}"
To delete all users:
curl -X DELETE http://localhost:5001/users
To register an OIDC client:
curl http://localhost:5001/clients \
-H 'Content-Type: application/json' \
-d "{
\"client_id\": \"test-client\",
\"redirect_uri\": \"http://localhost:5000/auth\",
\"public_key\": \"-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----\",
\"scope\": \"openid email\"
}"
To unregister all OIDC clients:
curl -X DELETE http://localhost:5001/clients