strongloop/loopback-example-access-control

Sample with mongo db connection not working as expected

brunoescalona-zz opened this issue · 2 comments

Description of the problem

If I run the example code as it is, it works perfect.
I try to modify the data source from memory to a mongo database with the following code.

"db": {
    "host": "localhost",
    "port": 27017,
    "database": "access-control",
    "name": "db",
    "connector": "mongodb"
  }

With the change when I run the application I can see all the Users, Roles and Roles Mapping in my database, the problem is when I login with the admin user and I GET all the projects I get the 401 error. (I am using the token in the request).

The ACL is:

 {
    "accessType": "READ",
    "principalType": "ROLE",
    "principalId": "admin",
    "permission": "ALLOW",
    "property": "find"
 }

Expected result

As in the memory example the expected result is to get all the project listed when I login with the admin user.

Sorry the issue was alredy open.
I could solve the problem with the following modification in the RoleMapping model:

"options": {
     "strictObjectIDCoercion": true
}

Thank you anyway for pointing this.