2013-07-01 18:51:28 +00:00
|
|
|
/**
|
|
|
|
Schema ACL options
|
2013-06-26 23:25:51 +00:00
|
|
|
|
2013-07-01 18:51:28 +00:00
|
|
|
Object level permissions, for example, an album owned by a user
|
2013-06-26 23:25:51 +00:00
|
|
|
|
2013-07-01 18:51:28 +00:00
|
|
|
Factors to be authorized against:
|
2013-06-26 23:25:51 +00:00
|
|
|
|
2013-07-01 18:51:28 +00:00
|
|
|
* model name: Album
|
|
|
|
* model instance properties: userId of the album, friends, shared
|
|
|
|
* methods
|
|
|
|
* app and/or user ids/roles
|
|
|
|
** loggedIn
|
|
|
|
** roles
|
|
|
|
** userId
|
|
|
|
** appId
|
|
|
|
** none
|
|
|
|
** everyone
|
|
|
|
** relations: owner/friend/granted
|
2013-06-26 23:25:51 +00:00
|
|
|
|
2013-07-01 18:51:28 +00:00
|
|
|
Class level permissions, for example, Album
|
|
|
|
* model name: Album
|
|
|
|
* methods
|
2013-07-15 21:07:17 +00:00
|
|
|
|
2013-07-18 18:44:25 +00:00
|
|
|
URL/Route level permissions
|
|
|
|
* url pattern
|
|
|
|
* application id
|
|
|
|
* ip addresses
|
|
|
|
* http headers
|
2013-07-15 21:07:17 +00:00
|
|
|
|
2013-07-18 18:44:25 +00:00
|
|
|
Map to oAuth 2.0 scopes
|
2013-06-26 23:25:51 +00:00
|
|
|
|
2013-07-01 22:53:10 +00:00
|
|
|
*/
|
2013-07-18 18:44:25 +00:00
|
|
|
|
2013-11-04 21:19:02 +00:00
|
|
|
var loopback = require('loopback');
|
|
|
|
|
2013-10-28 17:44:05 +00:00
|
|
|
var ACLEntrySchema = {
|
2013-11-04 21:19:02 +00:00
|
|
|
/**
|
|
|
|
* Type of the principal - Application/User/Role
|
|
|
|
*/
|
|
|
|
principalType: String,
|
|
|
|
/**
|
|
|
|
* Id of the principal - such as appId, userId or roleId
|
|
|
|
*/
|
|
|
|
principalId: String,
|
2013-10-28 17:44:05 +00:00
|
|
|
|
2013-11-04 21:19:02 +00:00
|
|
|
/**
|
|
|
|
* Name of the access type - READ/WRITE/EXEC
|
|
|
|
*/
|
|
|
|
accessType: String,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ALARM - Generate an alarm, in a system dependent way, the access specified in the permissions component of the ACL entry.
|
|
|
|
* ALLOW - Explicitly grants access to the resource.
|
|
|
|
* AUDIT - Log, in a system dependent way, the access specified in the permissions component of the ACL entry.
|
|
|
|
* DENY - Explicitly denies access to the resource.
|
|
|
|
*/
|
|
|
|
permission: String
|
|
|
|
};
|
|
|
|
|
|
|
|
var AccessSchema = {
|
2013-10-28 17:44:05 +00:00
|
|
|
publicReadAccess: Boolean,
|
|
|
|
publicWriteAccess: Boolean,
|
2013-11-04 21:19:02 +00:00
|
|
|
publicExecAccess: Boolean,
|
|
|
|
permissions: [ACLEntrySchema]
|
|
|
|
};
|
2013-10-28 17:44:05 +00:00
|
|
|
|
2013-07-18 18:44:25 +00:00
|
|
|
var ACLSchema = {
|
2013-11-04 21:19:02 +00:00
|
|
|
/**
|
|
|
|
* Resource
|
|
|
|
*/
|
|
|
|
model: String, // The name of the model
|
|
|
|
property: String, // The name of the property
|
|
|
|
method: String, // The name of the method
|
|
|
|
|
|
|
|
access: AccessSchema, // The access
|
|
|
|
|
|
|
|
status: String,
|
2013-07-18 18:44:25 +00:00
|
|
|
created: Date,
|
|
|
|
modified: Date
|
2013-10-28 17:44:05 +00:00
|
|
|
};
|
2013-07-18 18:44:25 +00:00
|
|
|
|
|
|
|
|
2013-11-04 21:19:02 +00:00
|
|
|
var ACL = loopback.createModel('ACL', ACLSchema);
|
|
|
|
|
|
|
|
module.exports = ACL;
|