Skip to content

Commit

Permalink
Add support for wildcard actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Virgen committed Feb 12, 2013
1 parent 5c8f7fa commit c387b73
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/permission.js
Expand Up @@ -15,7 +15,8 @@ Permission.prototype.match = function(role, resource, action) {
case (this.role == null && this.resource == null && this.action == null): // Global rule
case (this.role == _role && this.resource == null && this.action == action): // Global rule on role
case (this.role == null && this.resource == _resource && this.action == action): // Global rule on resource
case (this.role == null && this.resource == _resource && this.action == null): // Global rule on action
case (this.role == _role && this.resource == _resource && this.action == null): // Global rule on action
case (this.role == null && this.resource == _resource && this.action == null): // Global rule on role and action
case (this.role == null && this.resource == null && this.action == action): // Global rule on role and resource
case (this.role == null && this.resource == resource && this.action == null): // Global rule on role and action
case (this.role == _role && this.resource == null && this.action == null): // Global rule on resource and action
Expand Down
8 changes: 6 additions & 2 deletions package.json
@@ -1,10 +1,14 @@
{
"name": "virgen-acl",
"version": "0.0.16",
"version": "0.0.17",
"description": "A fast in-memory ACL with role/resource inheritance and support for custom assertions.",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/djvirgen/virgen-acl.git"
},
"scripts": {
"test": "mocha --reporter spec"
"test": "mocha"
},
"devDependencies": {
"mocha": "~1.6.0",
Expand Down
8 changes: 8 additions & 0 deletions test/index.js
Expand Up @@ -79,6 +79,7 @@ require('should');
this.acl = new Acl();
this.acl.allow('foo', 'bar', allowedActions);
this.acl.deny('foo', 'bar', deniedActions);
this.acl.allow('derp', 'doo');
});

for (var i in allowedActions) (function(action) {
Expand All @@ -98,6 +99,13 @@ require('should');
});
});
})(deniedActions[i]);

it("supports wildcard actions", function(done) {
this.acl.query('derp', 'doo', 'anything', function(err, allowed) {
allowed.should.equal(true);
done();
});
});
});

describe('query', function() {
Expand Down
5 changes: 5 additions & 0 deletions test/mocha.opts
@@ -0,0 +1,5 @@
--require should
--reporter spec
--ui bdd
--compilers coffee:coffee-script
--globals config

0 comments on commit c387b73

Please sign in to comment.