Skip to content

Can not delete a data row with ACL(Using Role to check ACL) #1948

Closed

Description

@ntloc592

Issue Description

I can not delete a row after created.

Describe your issue in as much detail as possible.

Steps to reproduce

  1. Create role with name "Admin", create user admin, set role Admin for this user
  2. Login with admin user and create a "Tag" object
    • ACL: Role admin
      + Read: true
      + Write: true
  3. Delete this tag
    • Result:
      {
      code: 101,
      message: 'Object not found.'
      }

image

Expected Results

Can detete this row

Actual Outcome

 Somtime return error, sometime can delete this row
 {
   code: 101,
   message: 'Object not found.'
  }

Environment Setup

  • Server
    • parse-server version: 2.2.10
    • Operating System: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [FILL THIS OUT]
  • Database
    • MongoDB version: [FILL THIS OUT]
    • Storage engine: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [FILL THIS OUT]

Logs/Trace

With My debuging

image

In this function (view image), I found some wrong when debuging

  • File /src/Auth.js
  • Sometime, system will get user role from cache at line 102, but this.userRoles=[]
  • System will check permission by this.userRoles at line 75 in next image
    • File /src/rest.js
      image

Activity

  1. FarmerKing commented on Jun 8, 2016

    @FarmerKing

    the parse-server version should be 2.2.11.
    ( in version 2.2.10, there aren't any cachedRoles codes in src/Auth.js:_loadRoles)

    We also noticed the issue.

    In our test cases, there's a test which creates a data and then delete it.
    The data is created that only a certain Role can read/write.

    when we updated the parse-server to version 2.2.11, the test fails.

    The test is like:

    const testData = new forTest();
    const acl = new Parse.ACL();
    acl.setRoleReadAccess('Admin', true);
    acl.setRoleWriteAccess('Admin', true);
    
    testData.set('number', 1);
    testData.set('title', 'test');
    testData.set('ACL', acl);
    
    // where user is a Parse.User which has Admin Role
    return testData.save(null, { sessionToken: user.getSessionToken() } )
    .then( () =>
      testData.destroy( { sessionToken: user.getSessionToken() } )
    )
    .then( () => {
      // done
    })
    .catch( err => {
      // done.fail('create and drop fail: ' + err.code + ', ' + err.message );
    });

    we also traced the bug to these files: (just as @ntloc592's description)
    https://github.com/ParsePlatform/parse-server/blob/2.2.11/src/rest.js#L64-L77
    https://github.com/ParsePlatform/parse-server/blob/2.2.11/src/Auth.js#L97-L104

  2. FarmerKing commented on Jun 13, 2016

    @FarmerKing

    @ntloc592
    Will be fixed in
    #2034: fix getting user roles from cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions