Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication inside GraphQL / Juniper #32

Open
PabloSzx opened this issue May 20, 2020 · 3 comments
Open

Authentication inside GraphQL / Juniper #32

PabloSzx opened this issue May 20, 2020 · 3 comments

Comments

@PabloSzx
Copy link

In Node.js GraphQL servers you simply give as context functions that handle the cookies/session to do the authentication, but in this template the authentication is being handled outside of GraphQL, how can I handle it all inside GraphQL? when I try to simply give the actix session stuff it just says it can't be shared between threads.

@clifinger
Copy link
Collaborator

The GraphQL specification doesn’t tell you how to do authentication or authorization. It can be a bit confusing to developers who are new to GraphQL. I don’t claim to have all the answers, so if you have a different idea or a different opinion, feel free to share that in the comments so we can all learn together!

  1. Let the web server (e.g. express or nginx) take care of authentication or a micro service like auth server.
  2. Handle authentication in GraphQL itself.

I am fan of SRP (single responsibility principle), GraphQL for the query, the endpoint for consuming the data and the authentication server for what you know ... Like major compagnies with Oauth ...

In my point I don't think it's a good choice to handle it into the graphql endpoints as it is a single endpoint...what you can do if you want to make the full endpoint private?

@PabloSzx
Copy link
Author

In the Node.js ecosystem there is good tooling around authorization inside the GraphQL schema itself, to give some examples:

I don't have the experience in Rust to give some examples in how I could do it here, but it's specially convenient for the client side to use the same tooling used for the GraphQL schema (Apollo / Relay / urql /gqless, etc...) while doing the authentication process, simply using mutations, instead of hacking around extra logic just for the current_user / login / sign_up / logout.

@PabloSzx
Copy link
Author

And it raises another question, how can I expose some parts of the GraphQL Schema of this template to be open without authorization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants