2018-09-11 14:11:24 +03:00
Authorization modes
===================
2019-09-11 10:17:14 +03:00
You can run Hasura's GraphQL engine in three modes:
2018-09-11 14:11:24 +03:00
1. No Authentication mode
^^^^^^^^^^^^^^^^^^^^^^^^^
2019-02-14 12:37:47 +03:00
- When ``--admin-secret`` and ``--auth-hook`` are not set
2018-09-11 14:11:24 +03:00
2019-02-14 12:37:47 +03:00
- It is useful when you're developing . It is not recommended to use in production but however you can have proxy gateway that will set (``X-Hasura-Admin-Secret``) header and other required ``X-Hasura-*`` headers.
2018-09-11 14:11:24 +03:00
Run server in this mode using following docker command.
.. code-block:: bash
docker run --name hasura-graphql-engine -p 9000:9000 \
--link hasura-postgres:postgres \
-d hasura/graphql-engine:latest graphql-engine \
--database-url \
postgres://postgres:mysecretpassword@postgres:5432/postgres \
serve --server-port 9000 --cors-domain "*"
2019-02-14 12:37:47 +03:00
2. Admin secret mode
^^^^^^^^^^^^^^^^^^^^
2018-09-11 14:11:24 +03:00
2019-02-14 12:37:47 +03:00
- When only ``--admin-secret`` is set. See :doc:`GraphQL Server Options <../deployment/options>`
2018-09-11 14:11:24 +03:00
2019-02-14 12:37:47 +03:00
- Server authenticates based on ``X-Hasura-Admin-Secret`` header and expects all other required ``X-Hasura-*`` headers.
2018-09-11 14:11:24 +03:00
Run server in this mode using following docker command.
.. code-block:: bash
docker run --name hasura-graphql-engine -p 9000:9000 \
--link hasura-postgres:postgres \
-d hasura/graphql-engine:latest graphql-engine \
--database-url \
postgres://postgres:mysecretpassword@postgres:5432/postgres \
2019-02-14 12:37:47 +03:00
serve --server-port 9000 --admin-secret myAdminSecretKey \
2018-09-11 14:11:24 +03:00
--cors-domain "*"
2019-02-14 12:37:47 +03:00
3. Admin secret key and Authorization webhook mode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2018-09-11 14:11:24 +03:00
2019-02-14 12:37:47 +03:00
- When both ``--admin-secret`` and ``--auth-hook`` are set
2018-09-11 14:11:24 +03:00
2019-02-14 12:37:47 +03:00
- This mode is useful in production. When server founds ``X-Hasura-Admin-Secret`` header it ignores webhook and expects all other required ``X-Hasura*`` headers
2018-09-11 14:11:24 +03:00
2019-02-14 12:37:47 +03:00
- If ``X-Hasura-Admin-Secret`` header not found then server authenticaters through webhook. See :doc:`Authorization
2018-09-11 14:11:24 +03:00
Webhook <webhook>`
Run server in this mode using following docker command.
.. code-block:: bash
docker run --name hasura-graphql-engine -p 9000:9000 \
--link hasura-postgres:postgres \
-d hasura/graphql-engine:latest graphql-engine \
--database-url \
postgres://postgres:mysecretpassword@postgres:5432/postgres \
2019-02-14 12:37:47 +03:00
serve --server-port 9000 --admin-secret myAdminSecretKey \
2018-09-11 14:11:24 +03:00
--auth-hook http://myAuthhook/ --cors-domain "*"