Coder Social home page Coder Social logo

node_acl-mem-regexp's Introduction

Memory Backend with RegExp support for NODE ACL

This replacement for the memory-backend that ships with acl supports regular expressions for the resource.

##Status

BuildStatus DependencyStatus

##Installation

Using npm:

npm install acl-mem-regexp

##Examples

Explicitly allow access to a resource and its subresource.

var acl = require('acl')
    , Backend = require('acl-mem-regexp')
    , acl = new acl(new Backend())
;

acl.allow([
	{
		roles:['someRole'], 
		allows:[
			{resources:'/resource(/[0-9]+)?', permissions:['get', 'post', 'put']},
			{resources:'/resource/[0-9]+/subresource/[0-9]+', permissions:['get', 'post', 'put']}
		]
	}
])

Do not include ^ and $. Those will be added for you.

You can also omit access to the parent resource while allowing access to the subresource.

acl.allow([
	{
		roles:['someOtherRole'], 
		allows:[
			{resources:'/resource/[0-9]+/subresource/[0-9]+', permissions:['get', 'post', 'put']}
		]
	}
])

node_acl-mem-regexp's People

Contributors

futurechan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

maniacs-js artzub

node_acl-mem-regexp's Issues

Support for real Regexp

Hi, nice work.

Is there any particular reason why plain/pure Regexp are not supported?

Looking at:

Do not include ^ and $. Those will be added for you.

I wonder why this is not possible:

acl.allow([
    {
        roles:['someRole'], 
        allows:[
            {resources:^\/resource(/[0-9]+)?$, permissions: ['get']},
            {resources:\/[0-9]+$, permissions: ['get']}, // all resources ending with `/:id`
        ]
    }
])

Let me know if this is worth my time investigating. I can submit a Pull request to add support for pure Regexp.

Cheers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.