Hello,
I’ve been setting up security for my database this week with the @auth
directive and I’m noticing some rules are not being evaluated correctly in DGraph Cloud. Namely, the ones in the last section of auth docs. At first I though I wasn’t setting up auth correctly either in the # DGraph.Authorization
line or in my front end, but I was able to get it working using the rules that actually contain a query. I’ll explain below what I’ve done so far:
When using this rule:
@auth(
query: { rule: """
query ($USER: String!) {
queryUser(filter: {
or: [
{ email: { eq: $USER } },
{not: {email: {eq: $USER}}}
]
}) {
id
}
}"""
}
)
I’m able to get results from my back end
However, when switching to this rule:
@auth(
query: { rule: "{$isAuthenticated: { eq: \"true\" } }" },
)
I get no results.
I’ve also been able to decode my token and verify that the corresponding claims are indeed present.
I know I can replace the $isAuthenticated
rule with the other one containing a query, but I’d prefer using the former one due to its readability.
I already opened a support ticket but I figured I’d post it here in case someone else runs into this issue in the future. I was wondering if maybe the DGraph version running on DGraph Cloud doesn’t support this yet but was told by support it does. Any suggestions are highly appreciated.