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-10-28 17:44:05 +00:00
|
|
|
/*
|
|
|
|
var ACLEntrySchema = {
|
|
|
|
principal: String, // Application/User/Role
|
|
|
|
action: String, // READ/WRITE or method name
|
|
|
|
allowed: Boolean // Positive or negative
|
|
|
|
}
|
|
|
|
|
|
|
|
var ACLSchema = {
|
|
|
|
publicReadAccess: Boolean,
|
|
|
|
publicWriteAccess: Boolean,
|
|
|
|
permissions: [ACLEntrySchema],
|
|
|
|
created: Date,
|
|
|
|
modified: Date
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var AccessLevel = [
|
|
|
|
NotAllowed: 'Not Allowed', // Disabled
|
|
|
|
// 'Allowed when Logged-in',
|
|
|
|
Owner: 'Allow to Object Owner',
|
|
|
|
Role: 'Users defined in a Role',
|
|
|
|
Related: 'Any User with a relationship to the object',
|
|
|
|
Authenticated: 'Allow to Any Logged In User',
|
|
|
|
'Open'
|
|
|
|
];
|
|
|
|
*/
|
|
|
|
|
2013-07-18 18:44:25 +00:00
|
|
|
var ACLSchema = {
|
|
|
|
model: String, // The model name
|
|
|
|
properties: [String], // A list of property names
|
|
|
|
methods: [String], // A list of methods
|
2013-10-28 17:44:05 +00:00
|
|
|
users: [String], // A list of users
|
2013-07-18 18:44:25 +00:00
|
|
|
roles: [String], // A list of roles
|
|
|
|
permission: {type: String, enum: ['Allow', 'Deny']}, // Allow/Deny
|
|
|
|
status: String, // Enabled/disabled
|
|
|
|
created: Date,
|
|
|
|
modified: Date
|
2013-10-28 17:44:05 +00:00
|
|
|
};
|
2013-07-18 18:44:25 +00:00
|
|
|
|
|
|
|
// readAccess, writeAccess --> public, userId, role
|
|
|
|
|
|
|
|
module.exports = function(dataSource) {
|
2013-07-30 21:26:49 +00:00
|
|
|
dataSource = dataSource || new require('loopback-datasource-juggler').ModelBuilder();
|
2013-07-18 18:44:25 +00:00
|
|
|
var ACL = dataSource.define('ACL', ACLSchema);
|
|
|
|
return ACL;
|
2013-10-28 17:44:05 +00:00
|
|
|
};
|