Why is the Principal not a model, but Role, RoleMapping, ACL are unexpected models?

I am reading Loopback access control concepts ( https://docs.strongloop.com/display/public/LB/Authentication%2C+authorization%2C+and+permissions ) and I don’t understand how it happened that it’s Principalnot a model, but Role, RoleMapping, ACL- a model with a full set of REST API methods and are listed in the model-config.json? When I tried to include Principalin model-config.jsonwith Role, RoleMappingand ACL, I got an error:

"ACL": {
    "dataSource": "db",
    "public": false
},
"RoleMapping": {
    "dataSource": "db",
    "public": false
},
"Role": {
    "dataSource": "db",
    "public": false
},
"Principal": {
    "dataSource": "db",
    "public": true
},

Mistake:

throw new Error('Model not found: ' + modelName);
      ^
Error: Model not found: Principal

Where is the logic here? Principalis on the same line as the others, but is not a model. Why?

+4
source share
1

, ?

- , . . : user create. user .

user, application role , .

Class Principal ,

, , , . : type, id name. type , . principal . , role,

role.principals.create({
    principalType: app.models.RoleMapping.USER,
    principalId: admin.id
}, function(err, principal) {
    if (err) {
        throw err;
    } else {
        next();
    }
});

principal role. . , principalType , .

: , , principal , , , , create.

, principal. principal Loopback ,

throw new Error('Model not found: ' + modelName);
      ^
Error: Model not found: Principal
+2

Source: https://habr.com/ru/post/1614591/


All Articles