Skip to content

Commit

Permalink
Allow uid access (#4922)
Browse files Browse the repository at this point in the history
  • Loading branch information
animesh2049 authored Mar 12, 2020
1 parent a861a87 commit 0a0d273
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion edgraph/access_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ func parsePredsFromQuery(gqls []*gql.GraphQuery) []string {
if gq.Func != nil {
predsMap[gq.Func.Attr] = struct{}{}
}
if len(gq.Attr) > 0 {
if len(gq.Attr) > 0 && gq.Attr != "uid" {
predsMap[gq.Attr] = struct{}{}
}
for _, ord := range gq.Order {
Expand Down
25 changes: 24 additions & 1 deletion ee/acl/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,30 @@ func TestQueryRemoveUnauthorizedPred(t *testing.T) {
t.Run(tc.description, func(t *testing.T) {
resp, err := userClient.NewTxn().Query(ctx, tc.input)
require.Nil(t, err)
require.Equal(t, tc.output, string(resp.Json))
testutil.CompareJSON(t, tc.output, string(resp.Json))
})
}

require.NoError(t, testutil.AssignUids(101))
mutation = &api.Mutation{
SetNquads: []byte(`
<100> <name> "100th User" .
<100> <age> "100" .
`),
CommitNow: true,
}
_, err = dg.NewTxn().Mutate(ctx, mutation)
require.NoError(t, err)
uidQuery := `
{
me(func: uid(100)) {
uid
name
age
}
}
`
resp, err := userClient.NewReadOnlyTxn().Query(ctx, uidQuery)
require.Nil(t, err)
testutil.CompareJSON(t, `{"me":[{"name":"100th User", "uid": "0x64"}]}`, string(resp.GetJson()))
}

0 comments on commit 0a0d273

Please sign in to comment.