-
-
Notifications
You must be signed in to change notification settings - Fork 570
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
Authorization and authentication #26
Conversation
I like the spec, but would you just parse all claims globally or, or namespace them, e.g. {
"roles": {
"sub": "postgraphql",
"role": "user",
"user_id": 2
}
} We've used JWTs in the past to store arbitrary data (that needed to be trusted), which would get picked up and set as a role with your solution. |
Only the top level role would be used to set the role. If there was a nested object it would be stringified. So If so we could have a flag in the JWT to switch it off. |
Ah sorry, I wasn't aware it's only the role field that gets set, everything else can get discarded if not needed. If it's just role, then chances for collisions are relatively low. |
@hardchor is there a way I could improve the documentation/specification to make this more clear? |
I just wasn't quite aware of how authorisation in Postgres works (do very little DB related these days). After reading the spec again, it does make sense! |
Are you going to pass the token / claims in through the GraphQL context? I'm doing the request handling myself (and just use |
Currently, the token is used to run some queries on the PostgreSQL client and is unused by resolvers so it isn't needed in the context. I also don't want to be setting the local variables more than once so putting token serialization in the resolver isn't optimal. Take a look at I think what I'll probably do is make a small module ( I could also add a helper function, |
I was going to wait to also implement authentication before merging this PR, but I don't have any strong ideas at the moment. How would everyone feel if I merged and released this and work on an authentication solution in another PR? Releasing this would not be a breaking change, servers would still work even if they never use tokens. People using PostGraphQL as a library would not be affected at all by this PR as it only changes code in the server. |
I'd say handle authorisation and authentication separately and get it in! |
Authorization support has been added in |
This PR's goal is to add authorization and optional authentication to PostGraphQL. As of the opening of this issue I have only added authorization support using JWTs. Look at the tests, look at the readme, and look at this specification and tell me if you like this authorization schema. Authentication (creating tokens) will be decided later on.