parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

ACL restricted PFQuery returns no results when using parse-server, works when using old Parse.com API

Open adinamira opened this issue 10 years ago • 10 comments

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

-[X ] You've met the prerequisites.

-[ X] You're running the latest version of Parse Server.

-[X ] You've searched through existing issues. Chances are that your issue has been reported or resolved before.

Environment Setup

AWS Elastic Beanstalk, 64bit Amazon Linux 2015.09 v2.0.8 running Node.js

Steps to reproduce

Create Read/Write ACL restricted object using iOS SDK 1.12 then attempt to find it after saving it. Example Code: PFACL *userACL = [[PFACL alloc] init]; [userACL setPublicReadAccess:false]; [userACL setPublicWriteAccess:false]; [userACL setReadAccess:true forUser:[PFUser currentUser]]; [userACL setWriteAccess:true forUser:[PFUser currentUser]]; [myPFObject setACL:userACL]; [myPFObject saveInBackgroundWithBlock //..];

//Success, no error, see object in DB, then later... run PFQuery, no results found when would normally be found before migrating.

Query returns successfully with the expected object using Parse.com API but unsuccessfully when using a ParseClientConfiguration set to my server. I suspect the read ACL is not working properly because it returns with no results found even though _rperm and _wperm match the PFUser object ID in MongoDB. Query returns successfully with public read/write permissions set to true as well.

ACL query works on Android, both Parse.com and self-hosted server. ACL query only works on iOS on Parse.com, does not work on self-hosted server.

Logs/Trace


/var/log/nodejs/nodejs.log

BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field BUG: the handler did not include a "response" field

adinamira avatar Mar 01 '16 01:03 adinamira

I have same problem with self-hosted Parse-server: After save new Parse.User object I set ACL for this user:

1 variant

newUser.signUp(null, { useMasterKey: true })
    .then(
        (user) => {
            let acl = new Parse.ACL(user);                      
            user.setACL(acl);
            user.save();
        },
        (error) => {

        }
    );

2 variant

newUser.signUp(null, { useMasterKey: true })
    .then(
        (user) => {
            let acl = new Parse.ACL();
            acl.setReadAccess(user.id, true);
            acl.setWriteAccess(user.id, true);
            acl.setPublicReadAccess(false);
            user.setACL(acl);
            user.save();
        },
        (error) => {

        }
    );

But in both case in mongoDB i see for this record: "_id" : "mwlCdr4GtU", "_rperm" : [ "mwlCdr4GtU", "*" ], "_wperm" : [ "mwlCdr4GtU" ]

Why in read permission "*"?

stalehard avatar Mar 01 '16 08:03 stalehard

I'll have a look

flovilmart avatar Mar 01 '16 16:03 flovilmart

@stalehard I can't repro your bug check here: https://github.com/ParsePlatform/parse-server/tree/flovilmart.UserACL

flovilmart avatar Mar 02 '16 22:03 flovilmart

Any update on my bug?

adinamira avatar Mar 02 '16 22:03 adinamira

@flovilmart to repro this bug I use this code

var newUser = new Parse.User();
newUser.set('username', 'test');
newUser.set('password', '123');

newUser.signUp(null, { useMasterKey: true })
    .then(function(user) {
        var acl = new Parse.ACL();
        acl.setReadAccess(user.id, true);
        acl.setWriteAccess(user.id, true);
        acl.setPublicReadAccess(false);
        user.setACL(acl);
        user.save();
    }, function(err) {
        console.log(err);
    });

In mongoDB i see "_id" : "RAye8eRxzY", "_rperm" : [ "RAye8eRxzY", "*" ], "_wperm" : [ "RAye8eRxzY" ] Also i can read full info about this object as any user

I find working variant

var newUser = new Parse.User();
newUser.set('username', 'test');
newUser.set('password', '123');
var acl = new Parse.ACL();
newUser.setACL(acl);

newUser.signUp(null, { useMasterKey: true })
    .then(function(user) {
        var acl = new Parse.ACL(user);
        user.setACL(acl);
        user.save(null, { useMasterKey: true });
    }, function(err) {
        console.log(err);
    });

In this case all work fine: "_id" : "SR2AAfmFvd", "_rperm" : [ "SR2AAfmFvd" ], "_wperm" : [ "SR2AAfmFvd" ]

Solution is use save object User with masterkey

stalehard avatar Mar 03 '16 10:03 stalehard

@stalehard I'll track it deeper

flovilmart avatar Mar 03 '16 13:03 flovilmart

@flovilmart you reference stalehard's issue when you say you aren't able to reproduce. His issue seems separate from mine. Can you please address my issue instead of the comment posted after? This is delaying a major feature release for us and It is not clear if you are unable to reproduce my issue. I know the issue goes away if I use the default API url but it persists if I use parse-server on my AWS deployment.

adinamira avatar Mar 07 '16 22:03 adinamira

Our Issue seems resolved with the update to 2.1.5. Leaving this open so you can work with stalehard.

adinamira avatar Mar 11 '16 00:03 adinamira

@fyredave good to know that's solved, I'd rather have @stalehard to open a new issue for that as they are unrelated to keep things tidy. @stalehard can you do that?

flovilmart avatar Mar 11 '16 00:03 flovilmart

@flovilmart ok

stalehard avatar Mar 11 '16 11:03 stalehard