Ashy Ashcsi
Ashy Ashcsi

Reputation: 1597

Loopback custom role based ACL not working

I am using Loopback 3 and my datasource is MySQl. I have created a user with SUPER_ADMIN role. The entries in the table look like below:

The user table looks like below:

1   admin   password [email protected]

The Role table looks like below:

3   ADMIN   super admin 4/24/18 11:42 AM    4/24/18 11:42 AM

The Rolemapping table

4   ADMIN   1   3

But when I try use this role in the ACL, it does not work:

{
  "accessType": "*",
  "principalType": "ROLE",
  "principalId": "ADMIN",
  "permission": "ALLOW",
  "property": "greet"
}

The above always throws 401, Authorization Required error.

Could anyone let me know, if I am missing anything here.

Thanks

Upvotes: 1

Views: 339

Answers (1)

Antonio Trapani
Antonio Trapani

Reputation: 811

principalType value is wrong in the RoleMapping entry, ADMIN should be replaced with USER, which is a constant here: app.models.RoleMapping.USER

Upvotes: 1

Related Questions