Skip to content

Commit

Permalink
fix(acl): filter out the results based on type (#7978) (#7981)
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)
(cherry picked from commit ff9ef37)
  • Loading branch information
NamanJain8 authored and ahsanbarkati committed Aug 17, 2021
1 parent e75ce7f commit bed3607
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 @@ -273,7 +273,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 @@ -459,7 +459,7 @@ func InitializeAcl(closer *z.Closer) {
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 @@ -529,10 +529,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 bed3607

Please sign in to comment.