community/boilerplates/auth-webhooks/python-flask/README.md
A boilerplate authentication webhook for Hasura GraphQL Engine written in Python using Flask.
git clone https://github.com/hasura/graphql-engine
cd graphql-engine/community/boilerplates/auth-webhooks/python-flask
Run the webhook using any of the tree methods below:
pip install -r requirements.txt
export FLASK_APP=auth-webhook.py
flask run
Webhook will be available at http://localhost:5000/auth-webhook
docker build -t hasura-auth-webhook .
docker run -p 5000:5000 hasura-auth-webhook
Webhook will be available at http://localhost:5000/auth-webhook
Install and configure now:
npm install -g now
now login
Deploy the webhook:
now
Webhook will be available at a url like https://python-flask-lrnfqprjcc.now.sh
Configure Hasura with the webhook url. You will need to set an admin secret key to enable webhook.
When running Hasura as a docker container, localhost will point to the
container itself, not the host machine. So, if you're running the webhook
locally or as a container (not on a public url), you'll need to:
docker network and
keep Hasura and the webhook container in the same network so that webhook url
will become http://container-id:5000/auth-webhook--net=host with docker
run) so that localhost will be the host's network itself. Here, webhook url
will be http://localhost:5000/auth-webhookhttp://host.docker.internal:5000/auth-webhookSet the following environment variables for Hasura:
HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey
HASURA_GRAPHQL_AUTH_WEBHOOK=http://localhost:5000/auth-webhook
All queries will be now validated through the webhook.
Read more on authentication and access control.