dgraph-io / dgraph

The high-performance database for modern applications
https://dgraph.io
Other
20.45k stars 1.5k forks source link

JWT authentication #5173

Closed emregency closed 4 years ago

emregency commented 4 years ago

Experience Report

Note: Feature requests are judged based on user experience and modeled on Go Experience Reports. These reports should focus on the problems: they should not focus on and need not propose solutions.

What you wanted to do

I wanted to evaluate the Enterpise License to know if I can authenticate users using JWT tokens issued by an IAM provider.

What you actually did

I went to check the documentation to see if this was possible. I discovered that dGraph was actually also acting as an IAM service, partially.

The secret key is used by Alpha servers to sign JSON Web Tokens (JWT). As you’ve probably guessed, it’s critical to keep the secret key as a secret. Another requirement for the secret key is that it must have at least 256-bits, i.e. 32 ASCII characters, as we are using HMAC-SHA256 as the signing algorithm.

Why that wasn't great, with examples

It wasn't great because, if I think of a dB, I think of it as a data service in my application in harmony with the other services. As users need to consume different services within the context of an application, I was considering to implement defense-in-depth using the enterprise edition of dGraph service. I was considering if dGraph can authenticate a user through a JWT, then apply ACL based on that.

Example scenario: 1- User identifies through a UI with PKCE to an IAM service 2- IAM service authenticates the User and returns a JWT 3- UI sends a request to the API Gateway with the Bearer authorization header 4- API Gateway validates the JWT and authorizes the user for services or operations 5- API Gateway relays the request to the relevant service with the User JWT 6- Every service checks again ACL based on User JWT

Graph ACL #5167 + User JWT = defense-in-depth, unified accountability across services, reduced attack surface for lateral movement and information disclosure.

Any external references to support your case

Mongo dB Atlas Custom JWT

gja commented 4 years ago

Hi @emregency,

Thank you for the experience report. I wanted to ask a few questions to clarify exactly what you are looking for.

We currently have two types of authentication / authorization in our system

Does the JWT Authorization for GraphQL solve your use case? If you are looking for ACL, but have the IAM provider be a 3rd party, then would you be able to generate a JWT token in dgraph's format, or do you think that dgraph should also support custom JWT? Finally, which client are you using (dgo / dgraph4j / etc...., or the Rest/GRPC endpoints directly)

Tejas

minhaj-shakeel commented 4 years ago

Github issues have been deprecated. This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing