Skip to content

ACL seems to not work when having multiple user models with a base UserModel #3829

@abouroubi

Description

@abouroubi

Description/Steps to reproduce

I'm having trouble using multiple user models in my app, here is my test case.

I create a new loopback app, follow the doc to add multiple user models, with custom AccesToken model (https://loopback.io/doc/en/lb3/Authentication-authorization-and-permissions.html#access-control-with-multiple-user-models).
I have 5 models:

  1. BaseUser : that inherit from User and have common functions (not provided in the sample but needed for a DRY code).
  2. Admin : inherits from BaseUser
  3. Client: inherits from BaseUser
  4. CustomAccessToken: inherits from AccessToken
  5. TaskItem: a persisted model with these ACL
    "acls": [
        {
          "accessType": "*",
          "principalType": "ROLE",
          "principalId": "$everyone",
          "permission": "DENY"
        },
        {
          "accessType": "*",
          "principalType": "Admin",
          "principalId": "$everyone",
          "permission": "ALLOW",
          "property": "*"
        }
    

I want to forbid everyone from accessing the model except Admins.
I tried reversing the order, change principalType to "ROLE" and principalId to "Admin", tried by changing the case (admin, ADMIN, Admin, etc...)

But whatever I do, when accessing the end point GET TaskItems as an Admin user I have a forbidden response.

Of course if I remove all the acls I have the results.

Link to reproduction sandbox

My code is here : https://github.com/abouroubi/loopbacktest

Expected result

Empty Array when Admin and Unauthorized when Client.

Additional information

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions