Skip to content

Commit

Permalink
Merge pull request #96 from colearnr/master
Browse files Browse the repository at this point in the history
Update mongodb driver to 1.4.30
  • Loading branch information
manast committed Feb 3, 2015
2 parents 74d0e1a + 457626e commit a155664
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
70 changes: 35 additions & 35 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

This module provides a minimalistic ACL implementation inspired by Zend_ACL.

When you develop a web site or application you will soon notice that sessions are not enough to protect all the
available resources. Avoiding that malicious users access other users content proves a much more
When you develop a web site or application you will soon notice that sessions are not enough to protect all the
available resources. Avoiding that malicious users access other users content proves a much more
complicated task than anticipated. ACL can solve this problem in a flexible and elegant way.

Create roles and assign roles to users. Sometimes it may even be useful to create one role per user,
to get the finest granularity possible, while in other situations you will give the *asterisk* permission
Create roles and assign roles to users. Sometimes it may even be useful to create one role per user,
to get the finest granularity possible, while in other situations you will give the *asterisk* permission
for admin kind of functionality.

A Redis, MongoDB and In-Memory based backends are provided built-in in the module. There are other third party backends such as [*knex*](https://github.com/christophertrudel/node_acl_knex) based and [*firebase*](https://github.com/tonila/node_acl_firebase). There is also an alternative memory backend that supports [*regexps*](https://github.com/futurechan/node_acl-mem-regexp).
Expand Down Expand Up @@ -71,7 +71,7 @@ acl = new acl(new acl.memoryBackend());
acl = new acl(new acl.mongodbBackend(dbInstance, prefix));
```

All the following functions return a promise or optionally take a callback with
All the following functions return a promise or optionally take a callback with
an err parameter as last parameter. We omit them in the examples for simplicity.

Create roles implicitly by giving them permissions:
Expand Down Expand Up @@ -114,14 +114,14 @@ lead to unnecessary nested callbacks for handling errors. Instead use the follow
```javascript
acl.allow([
{
roles:['guest','member'],
roles:['guest','member'],
allows:[
{resources:'blogs', permissions:'get'},
{resources:['forums','news'], permissions:['get','put','delete']}
]
},
{
roles:['gold','silver'],
roles:['gold','silver'],
allows:[
{resources:'cash', permissions:['sell','exchange']},
{resources:['account','deposit'], permissions:['put','delete']}
Expand Down Expand Up @@ -166,7 +166,7 @@ It will return an array of resource:[permissions] like this:
```
Finally, we provide a middleware for Express for easy protection of resources.
Finally, we provide a middleware for Express for easy protection of resources.
```javascript
acl.middleware()
Expand All @@ -184,7 +184,7 @@ The middleware will protect the resource named by *req.url*, pick the user from
acl.isAllowed(req.session.userId, '/blogs/12345', 'put')
```
The middleware accepts 3 optional arguments, that are useful in some situations. For example, sometimes we
The middleware accepts 3 optional arguments, that are useful in some situations. For example, sometimes we
cannot consider the whole url as the resource:
```javascript
Expand All @@ -207,7 +207,7 @@ app.put('/blogs/:id/comments/:commentId', acl.middleware(3, 'joed', 'post'), fun
Adds roles to a given user id.
__Arguments__
```javascript
userId {String|Number} User id.
roles {String|Array} Role(s) to add to the user id.
Expand All @@ -218,7 +218,7 @@ __Arguments__
<a name="removeUserRoles"/>
### removeUserRoles( userId, roles, function(err) )
Remove roles from a given user.
__Arguments__
Expand All @@ -237,7 +237,7 @@ __Arguments__
Return all the roles from a given user.
__Arguments__
```javascript
userId {String|Number} User id.
callback {Function} Callback called when finished.
Expand All @@ -251,7 +251,7 @@ __Arguments__
Return all users who has a given role.
__Arguments__
```javascript
rolename {String|Number} User id.
callback {Function} Callback called when finished.
Expand All @@ -265,7 +265,7 @@ __Arguments__
Return boolean whether user has the role
__Arguments__
```javascript
userId {String|Number} User id.
rolename {String|Number} role name.
Expand All @@ -291,11 +291,11 @@ __Arguments__
<a name="removeRole" />
### removeRole( role, function(err) )
Removes a role from the system.
__Arguments__
```javascript
role {String} Role to be removed
callback {Function} Callback called when finished.
Expand All @@ -305,11 +305,11 @@ __Arguments__
<a name="removeResource" />
### removeResource( resource, function(err) )
Removes a resource from the system
__Arguments__
```javascript
resource {String} Resource to be removed
callback {Function} Callback called when finished.
Expand All @@ -323,7 +323,7 @@ __Arguments__
Adds the given permissions to the given roles over the given resources.
__Arguments__
```javascript
roles {String|Array} role(s) to add permissions to.
resources {String|Array} resource(s) to add permisisons to.
Expand All @@ -332,13 +332,13 @@ __Arguments__
```
### allow( permissionsArray, function(err) )
__Arguments__
```javascript
permissionsArray {Array} Array with objects expressing what permissions to give.
[{roles:{String|Array}, allows:[{resources:{String|Array}, permissions:{String|Array}]]

callback {Function} Callback called when finished.
```
Expand All @@ -352,7 +352,7 @@ Remove permissions from the given roles owned by the given role.
Note: we loose atomicity when removing empty role_resources.
__Arguments__
```javascript
role {String}
resources {String|Array}
Expand All @@ -367,12 +367,12 @@ __Arguments__
Returns all the allowable permissions a given user have to
access the given resources.
It returns an array of objects where every object maps a
It returns an array of objects where every object maps a
resource name to a list of permissions for that resource.
__Arguments__
```javascript
userId {String|Number} User id.
resources {String|Array} resource(s) to ask permissions for.
Expand All @@ -383,12 +383,12 @@ __Arguments__
<a name="isAllowed" />
### isAllowed( userId, resource, permissions, function(err, allowed) )
Checks if the given user is allowed to access the resource for the given
Checks if the given user is allowed to access the resource for the given
permissions (note: it must fulfill all the permissions).
__Arguments__
```javascript
userId {String|Number} User id.
resource {String} resource to ask permissions for.
Expand All @@ -399,11 +399,11 @@ __Arguments__
---------------------------------------
<a name="areAnyRolesAllowed" />
### areAnyRolesAllowed( roles, resource, permissions, function(err, allowed) )
Returns true if any of the given roles have the right permissions.
__Arguments__
```javascript
roles {String|Array} Role(s) to check the permissions for.
resource {String} resource to ask permissions for.
Expand All @@ -425,11 +425,11 @@ __Arguments__
```
whatResources(role, permissions, function(err, resources) )
Returns what resources a role has the given permissions over.
__Arguments__
```javascript
role {String|Array} Roles
permissions {String|Array} Permissions
Expand Down Expand Up @@ -469,10 +469,10 @@ __Arguments__
```
```javascript
var mongodb = require('mongodb');
var mongodb = require('mongodb');
mongodb.connect("mongodb://127.0.0.1:27017/acltest", function(error, db) {
var mongoBackend = new acl.mongodbBackend(db, 'acl_');
});
});
```
Creates a new MongoDB backend using database instance `db`.
Expand All @@ -496,7 +496,7 @@ Run tests with `npm` (requires mocha):
- Support for denials (deny a role a given permission)
##License
##License
(The MIT License)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acl",
"version": "0.4.6",
"version": "0.4.7",
"description": "An Access Control List module, based on Redis with Express middleware support",
"keywords": [
"middleware",
Expand All @@ -18,7 +18,7 @@
"async": "~0.9.0",
"bluebird": "^2.3.11",
"lodash": "~2.4.1",
"mongodb": "^1.4.23",
"mongodb": "^1.4.30",
"redis": ">=0.12.1"
},
"devDependencies": {
Expand Down

0 comments on commit a155664

Please sign in to comment.