Giter VIP home page Giter VIP logo

auth-scope's Introduction

auth-scope

Create a scope from collection of roles and/or permissions.

Originally made for use with oauth2orize and the scope parameter, but could be adapted to different scenarios.

Installation

Node

npm install auth-scope

Browser

component install alexmingoia/auth-scope

Example

var Permission = require('auth-permission')
  , Role = require('auth-role')
  , Scope = require('auth-scope');

// Specify any number of roles or permissions
var roles = new Scope([
  Role('api')
    .allow(Permission('read profile'))
    .allow(Permission('read post')),
  Permission('create account'),
  Permission('update billing')
]);

// Create scope from available roles and/or permissions
var scope = new Scope(roles.find(['api', 'create account']));

// Get scope permissions
var permissions = scope.permissions();

JSON.stringify(permissions);
// => ['read profile', 'read post', 'create account']

API

new Scope(collection)

Create a new scope from collection of permissions and roles.

scope.find(names)

Find permissions or roles in the scope by name.

scope.roles()

Returns array of roles.

scope.permissions()

Returns array of permissions.

MIT Licensed

auth-scope's People

Contributors

alexmingoia avatar

Watchers

Navid Nikpour avatar  avatar

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.