Skip to content

Commit

Permalink
fix(acl): filter out the results based on type (#7978) (#7980)
Browse files Browse the repository at this point in the history
We store the groupId and userId in a predicate named dgraph.xid.There was a subtle bug where if a we create the group with same name as that of a user, then the user is not able to log in. This happens because we were not applying a filter by type.

This PR fixes that.

(cherry picked from commit 3553855)
  • Loading branch information
NamanJain8 authored Aug 12, 2021
1 parent 2da78a1 commit 18fd841
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions edgraph/access_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func getRefreshJwt(userId string, namespace uint64) (string, error) {

const queryUser = `
query search($userid: string, $password: string){
user(func: eq(dgraph.xid, $userid)) {
user(func: eq(dgraph.xid, $userid)) @filter(type(dgraph.type.User)) {
uid
dgraph.xid
password_match: checkpwd(dgraph.password, $password)
Expand Down Expand Up @@ -455,7 +455,7 @@ func upsertGuardianAndGroot(closer *z.Closer, ns uint64) {
func upsertGuardian(ctx context.Context) error {
query := fmt.Sprintf(`
{
guid as guardians(func: eq(dgraph.xid, "%s")){
guid as guardians(func: eq(dgraph.xid, "%s")) @filter(type(dgraph.type.Group)) {
uid
}
}
Expand Down Expand Up @@ -525,10 +525,10 @@ func upsertGroot(ctx context.Context, passwd string) error {
// groot is the default user of guardians group.
query := fmt.Sprintf(`
{
grootid as grootUser(func: eq(dgraph.xid, "%s")){
grootid as grootUser(func: eq(dgraph.xid, "%s")) @filter(type(dgraph.type.User)) {
uid
}
guid as var(func: eq(dgraph.xid, "%s"))
guid as var(func: eq(dgraph.xid, "%s")) @filter(type(dgraph.type.Group))
}
`, x.GrootId, x.GuardiansId)
userNQuads := acl.CreateUserNQuads(x.GrootId, passwd)
Expand Down

0 comments on commit 18fd841

Please sign in to comment.