sander-io / hasura-jwt-auth

Hasura JWT auth using PostgreSQL
MIT License
84 stars 9 forks source link

Created a Docker Quickstart for Hasura JWT Auth #1

Closed dvasdekis closed 5 years ago

dvasdekis commented 5 years ago

Lets users quickly run an instance of Hasura with PGJWT working via docker-compose up -d. See quickstart/README.md for a full description of how it works

I've duplicated the SQL from your repo into one giant file due to docker postgres initialisation limitations - if a community develops I can fix that later.

dvasdekis commented 5 years ago

Despite Hasura connecting to the database, I'm having problems getting a sample query to work. Will keep trying for now and will re-pullreq later

sanderhahn commented 5 years ago

My own setup maybe a bit weird so its not really a Quickstart, because i am not using Docker at the moment. Running the graphql-engine binary directly on a vps using the commands below. Have executed the sql scripts using the psql command line tool so that i can use ssh and sudo to pipe scripts to the server (cat schema.sql | ssh root@domain.com sudo -u postgres -i psql). However there also is a sql execute form on the Data tab in Hasura.

wget -O /usr/local/bin/graphql-engine https://graphql-engine-cdn.hasura.io/server/latest/linux-amd64
chmod +x /usr/local/bin/graphql-engine

And have a systemd script to automatically start the service:

[Unit]
Description=Hasura
After=postgresql.service

[Service]
User=www-data
Type=simple
# https://docs.hasura.io/1.0/graphql/manual/deployment/graphql-engine-flags/reference.html
Environment="HASURA_GRAPHQL_DATABASE_URL=postgresql://user:password@localhost:5432/clubadmin"
Environment="HASURA_GRAPHQL_ADMIN_SECRET=admin_secret"
Environment="HASURA_GRAPHQL_SERVER_PORT=4000"
Environment="HASURA_GRAPHQL_CORS_DOMAIN=https://domain.com"
Environment="HASURA_GRAPHQL_ENABLE_CONSOLE=true"
Environment="HASURA_GRAPHQL_ENABLE_TELEMETRY=true"
Environment="HASURA_GRAPHQL_ENABLED_APIS=metadata,graphql,pgdump"
Environment=HASURA_GRAPHQL_JWT_SECRET='{"type":"HS256","key":"key"}'
Environment="HASURA_GRAPHQL_UNAUTHORIZED_ROLE=anonymous"

ExecStart=/usr/local/bin/graphql-engine serve

[Install]
WantedBy=multi-user.target
sanderhahn commented 5 years ago

Sorry that ssh sudo command is wrong... i used a local psql client and added a user to .pgpass so that i could execute the script as my database owner (not postgres user).