This is simple django application which exposes /webhook/
(with token authentication) and /public-webhook/
(without any authentication) API routes.
In production this app has mutual TLS enabled.
credits django-on-docker
Uses the default Django development server.
-
Rename .env.dev-sample to .env.dev.
-
Update the environment variables in the docker-compose.yml and .env.dev files.
-
Build the images and run the containers:
$ docker-compose up -d --build
Test it out at http://localhost:8000. The "app" folder is mounted into the container and your code changes apply automatically.
$ chmod +x generate_certs.sh
$ ./generate_certs.sh
-
Rename .env.prod-sample to .env.prod and .env.prod.db-sample to .env.prod.db. Update the environment variables.
-
Build the images and run the containers:
$ docker-compose -f docker-compose.prod.yml up -d --build
Test it out with mTLS at https://127.0.0.1:1337
Test it out without mTLS at http://127.0.0.1:8000
-
Use curl to test
$ curl -X POST -H 'Content-type: application/json' --data '{"payload": { "a": "b"}}' https://127.0.0.1:1337/public-webhook/ --key nginx/certificates/client.key --cert nginx/certificates/client.crt --cacert nginx/certificates/server_ca.pem $ curl -X POST -H 'Content-type: application/json' -H 'Authorization: Token 61c0ef4aa8b8e9b6fd95612ca57e0cd727eabbe6' --data '{"payload": { "a": "b"}}' https://127.0.0.1:1337/webhook/ --key nginx/certificates/client.key --cert nginx/certificates/client.crt --cacert nginx/certificates/server_ca.pem
- Login to http://127.0.0.1:8000/admin with username = admin, password = admin