hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.95k stars 2.74k forks source link

docs: create a boilerplate for using hasura with passportjs and jwt #451

Open coco98 opened 5 years ago

coco98 commented 5 years ago

Should cover:

coco98 commented 5 years ago

This was also requested by Raj/Pratip

shahidhk commented 5 years ago

@coco98 The webhook example was added as https://github.com/hasura/graphql-engine/tree/master/community/boilerplates/auth-webhooks/passport-js

Should we add a JWT example also?

shahidhk commented 5 years ago

@arvi3411301 Can you also add a custom JWT server example?

shahidhk commented 5 years ago

We already have a boilerplate with passportjs which acts as a webhook.

Hasura supports JWT out of the box. It will be great if we can create a boilerplate which acts as an auth server issuing JWT tokens and also integrates passportjs so that all other login methods like google, facebook, etc. can be integrated later.

To start with, we can implement username-password login, where upon signing up or logging in the auth server issues a JWT token with say user role and a id. Hasura can then be configured with this server's JWK.

Questions? Fire away.

peterjgrainger commented 5 years ago

@shahidhk can I take this on? I'll let you know if I have any issues

shahidhk commented 5 years ago

Go for it! 😁

On Sat 13 Oct, 2018, 15:34 Peter Grainger, notifications@github.com wrote:

@shahidhk https://github.com/shahidhk can I take this on? I'll let you know if I have any issues

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hasura/graphql-engine/issues/451#issuecomment-429527833, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7wPTl763mGZBu2gKAKipbEVU_ezaTsks5ukbrIgaJpZM4Wo_2g .

lukebyrne commented 5 years ago

@peterjgrainger I am looking at starting on a similar task tomorrow, have you managed to make any progress?

peterjgrainger commented 5 years ago

@lukebyrne working on it now. I'll post a link to the repo here when I get a chance

lukebyrne commented 5 years ago

@peterjgrainger great stuff, even its not complete today could u post a link later on after your have finished working on it for the day so that I can have a noodle around with it? Cheers

lukebyrne commented 5 years ago

@peterjgrainger Just a heads up, I got a pretty simple Express App working for my needs.

https://gist.github.com/lukebyrne/72129edfb5ae09c844826f7a32b0f322

The process.env. just go in the .env file and if you read through the code they are all fairly self explanatory.

I have it working with a VueJS frontend.

peterjgrainger commented 5 years ago

@shahidhk @lukebyrne took a bit longer than I thought but it's done. Created the boilerplate for the JWT auth server. Hopefully the PR explains what is in there :)