Report a Dgraph Bug
It seems like @auth rules that filter a user type by a user id don’t actually do anything. I’ve seen this issue posted a few times but haven’t seen a solution. Wondering if anyone has a solution/workaround.
What version of Dgraph are you using?
v21.03.0-78-ge4ad0b113 (Dgraph Cloud)
Steps to reproduce the issue (command/config used to run Dgraph).
I have this schema
type Consumer
@auth(
query: {
rule: """
query ($USER_ID: ID!) {
queryConsumer(filter: {id: [$USER_ID]}) {
id
}
}
"""
}
) {
id: ID!
name: String!
...other unrelated fields
}
and making this query
query {
queryConsumer {
id
name
}
}
with this decoded JWT
{
"https://myapp.com/jwt/claims": {
"USER_ID": "<A USER ID>"
},
"aud": "myapp"
...other unrelated fields
}
and this Authorization object
# Dgraph.Authorization {"VerificationKey":"...","Header":"X-myapp","Namespace":"https://myapp.com/jwt/claims","Algo":"HS256","Audience":["myapp"]}
Expected behaviour and actual result.
I’m getting back every Consumer
in the database. I should just be getting back the Consumer
in the USER_ID
field in the JWT. I have tried pretty much every permutation I can think of for JWT structure, Dgraph.Authorization
rules, @auth
rules, etc. and I have only been able to get all the data or none of it.
Update: I can also mutate users that don’t match the JWT.