Given an authentication mechanism and a signed JSON Web Token (JWT), the @auth
directive tells Dgraph how to apply authorization.
query
auth rule or
the auth rule doesnβt depend on a JWT value, then the data can be accessed
without a signed JWT.
For example, the to do app might allow anyone, logged in or not, to view any
author, but not make any mutations unless logged in as the author or an admin.
That would be achieved by rules like the following.
"isAuthenticated": "true"
. For example,
ROLE
claim isnβt present in a JWT, any rule that relies on ROLE
simply evaluates to false.
You can also simply disallow some queries and mutations by using a condition on
a non-existing claim:
If you know that your JWTs never contain the claim DENIED
, then a rule such as