loopback/lib/models/acl.js

85 lines
1.8 KiB
JavaScript
Raw Normal View History

/**
Schema ACL options
Object level permissions, for example, an album owned by a user
Factors to be authorized against:
* 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
Class level permissions, for example, Album
* model name: Album
* methods
2013-07-15 21:07:17 +00:00
URL/Route level permissions
* url pattern
* application id
* ip addresses
* http headers
2013-07-15 21:07:17 +00:00
Map to oAuth 2.0 scopes
2013-07-01 22:53:10 +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
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,
created: Date,
modified: Date
2013-10-28 17:44:05 +00:00
};
2013-11-04 21:19:02 +00:00
var ACL = loopback.createModel('ACL', ACLSchema);
module.exports = ACL;