Skip to content

Instantly share code, notes, and snippets.

@sacarino
Last active October 25, 2018 17:05
Show Gist options
  • Save sacarino/52ea4d9f29e849a4a0469d7d306ccd3f to your computer and use it in GitHub Desktop.
Save sacarino/52ea4d9f29e849a4a0469d7d306ccd3f to your computer and use it in GitHub Desktop.
Some sane LoopbackJS ACL defaults / examples
// authenticated access to READ the model, but only admin or owner of the model can CRUD
...
"acls": [{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
}, {
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}],
...
// public access to READ the model, but only admin or owner of the model can CRUD
...
"acls": [{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
}, {
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}],
...
// only admin and the owner of the model can CRUD
...
"acls": [{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
}],
...
// only admin can CRUD the model
...
"acls": [{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}, {
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}],
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment