prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
673 stars 66 forks source link

Website guide for authorization #238

Open jasonkuhrt opened 4 years ago

jasonkuhrt commented 4 years ago

What

unresolved

Why

How

Related

210

References

Articles

Forums

Node Libs / Tools

Other

iherger commented 4 years ago

What's the current thinking about authorisation in nexus?

This is a critical aspect of any GraphQL API that is open to different user roles, and it would be good to get some guidance here (what is the current status, and where do we go from here).

I have been playing a bit with nexus for a personal project, but I really would need a good way to handle authorisation.

EDIT: I guess I can use graphql-shield as express middleware at the moment.

Thanks a lot.

nargetdev commented 4 years ago

I've been spinning on this pretty full on the past week searching for "idiomatic" implementation that would scale well and "feel good".

I've made a placeholder here for an effort for a fullstack Auth0 example implimenting "roles" for access control for GraphQL using Prisma2: https://github.com/nargetdev/prisma2-auth0-example

Not sure what library will make sense for Auth0.. seems like there's a lot of options. For now I'm just going to manage "the old fashioned way" - by storing user ID in a table with a "role" column.

P.S. Are schema directives dead in Prisma2?

hsluoyz commented 4 years ago

@nargetdev @jasonkuhrt Hi guys, Node-Casbin is one of the most promising authorization library for Node.js that supports ACL, RBAC and ABAC. It has a Prisma adapter: https://github.com/node-casbin/prisma-adapter The rules can be stored via Prisma like your other data.

Casbin is suitable for protecting GraphQL endpoints, see an example: https://github.com/esmaeilpour/graphql-casbin

jasonkuhrt commented 4 years ago

Thanks @hsluoyz will take a look. Would you be open for a direct chat with the team sometime?

hsluoyz commented 4 years ago

@jasonkuhrt sure. What tool do you use?

jasonkuhrt commented 4 years ago

@hsluoyz flexible! Zoom often. Best time might be once the team has had a chance to inform ourselves a bit. Depends on when we sprint on auth. Might still be a month or few out, not sure. Can we reach out to you then? Via email?

hsluoyz commented 4 years ago

@jasonkuhrt OK. Please reach me at hsluoyz AT gmail dot com at that time !