the dynamic superuser(admin) role for the loopback application.
npm install loopback-component-role-superThis loopback component add a new dynamic role: admin to become a super user.
You can use the loopback-component-role-user instead of it for more features.
1. Install in you loopback project:
npm install --save loopback-component-role-super
2. Create a component-config.json file in your server folder (if you don't already have one)
3. Configure options inside component-config.json:
``json`
{
"loopback-component-role-super": {
"enabled": true,
"role": "admin",
"models": []
}
}
enabled
- [Boolean]: whether enable this component. defaults: truerole
- [String] : the role name. defaults: $adminmodels
- [Boolean|Array of string]. defaults: truetrue
* enable the admin role to the models. means all models in the app.models.isAdminUser
- [Function(aUserId, aRoleName, callback)]: the callback function to check whetheraUserId
the is an admin user.callback
* the function(err, result) the result should be a boolean.aRoleName
defaults: the Role should has and the RoleMapping should has a user with aUserId.*
Just enable it on component-config.json.
set DEBUG=loopback:security:role:super` env vaiable to show debug info.