All Projects → Avaq → permissionary

Avaq / permissionary

Licence: MIT License
Tiny and framework-agnostic role-based permission management using composition over inheritance

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to permissionary

Adonis Acl
demo app: https://github.com/enniel/adonis-acl-blog-demo
Stars: ✭ 195 (+926.32%)
Mutual labels:  permissions, roles
ngx-access
Add access control to your components using hierarchical configuration with logical expressions.
Stars: ✭ 21 (+10.53%)
Mutual labels:  permissions, roles
Vue Router User Roles
A Vue.js plugin that protects routes based on user roles. Add your own authentication.
Stars: ✭ 237 (+1147.37%)
Mutual labels:  permissions, roles
Maravel Permissions
Because in the Maravelous univer every user deserves super power
Stars: ✭ 139 (+631.58%)
Mutual labels:  permissions, roles
spree admin roles and access
Admin Roles And Access for Spree
Stars: ✭ 45 (+136.84%)
Mutual labels:  permissions, roles
Think Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP 6.0 .
Stars: ✭ 155 (+715.79%)
Mutual labels:  permissions, roles
rbac
Simple RBAC/ACL for Laravel 8 caching and permission groups.
Stars: ✭ 43 (+126.32%)
Mutual labels:  permissions, roles
Accesscontrol
Role and Attribute based Access Control for Node.js
Stars: ✭ 1,723 (+8968.42%)
Mutual labels:  permissions, roles
django-hats
Role-based permissions system for Django. Everyone wears a different hat, some people wear multiple.
Stars: ✭ 21 (+10.53%)
Mutual labels:  permissions, roles
React-Express-JWT-UserPortal
React.js & Express.js User portal Using Core UI, JWT, JWT Token, Refresh Token, Role & Permission management, User manamgenet, Event Log.
Stars: ✭ 22 (+15.79%)
Mutual labels:  permissions, roles
Laratrust
Handle roles and permissions in your Laravel application
Stars: ✭ 1,799 (+9368.42%)
Mutual labels:  permissions, roles
HeimGuard
🛡 A simple library that allows you to easily manage permissions in your .NET projects.
Stars: ✭ 77 (+305.26%)
Mutual labels:  permissions, roles
Laravel Governor
Manage authorization with granular role-based permissions in your Laravel Apps.
Stars: ✭ 131 (+589.47%)
Mutual labels:  permissions, roles
Vue Gates
🔒 A Vue.js & Nuxt.js plugin that allows you to use roles and permissions in your components or DOM elements, also compatible as middleware and methods.
Stars: ✭ 184 (+868.42%)
Mutual labels:  permissions, roles
Laravel Auth
A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
Stars: ✭ 128 (+573.68%)
Mutual labels:  permissions, roles
Bouncer
Eloquent roles and abilities.
Stars: ✭ 2,763 (+14442.11%)
Mutual labels:  permissions, roles
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (+315.79%)
Mutual labels:  permissions, roles
Sentinel
A framework agnostic authentication & authorization system.
Stars: ✭ 1,354 (+7026.32%)
Mutual labels:  permissions, roles
nova-permissions
Add Permissions based authorization for your Nova installation via User-based Roles and Permissions. Roles are defined in the database whereas Permissions are defined in the code base.
Stars: ✭ 115 (+505.26%)
Mutual labels:  permissions, roles
ngx-security
Security directives for your Angular application to show/hide elements based on a user roles / permissions.
Stars: ✭ 18 (-5.26%)
Mutual labels:  permissions, roles

Permissionary - bringing permissions to the lawless

NPM Version Dependencies Build Status Code Coverage Greenkeeper badge

Tiny and framework-agnostic role-based permission management using a model of composition over inheritance.

npm install --save permissionary

Usage

var {checkPermission, findRoles} = require('permissionary');

Philosophy

Many permission systems use the idea of inheritance to define roles in terms of other roles. This can lead to the definition of non-flexible roles where the developer has to make decisions that determine what will be possible in the future. Mattias Petter Johansson has a good video explaining the phenomenon.

To combat this issue, Permissionary has no inheritance. Instead, groupings of grants are given names (known as roles), and multiple such roles can be assigned to a user. This allows one to define very minimal roles (containing the minimum number of grants necessary to carry meaning) and define types of users as being compositions of multiple such roles. If at any point in the future, a new type of user is required that shares the responsibility of formerly unassociated roles, all you'd have to do was assign both roles to that user.

API

checkPermission :: StrMap (Array String) -⁠> Array String -⁠> String -⁠> Boolean

A curried function that takes three arguments and returns a Boolean:

  1. A mapping from role names to an array of grants represented by glob patterns to match permission names.
  2. An Array of role names.
  3. A permission name.

The glob patterns will be filtered down to contain only those associated with the given list of roles. The permission will be checked against the filtered glob patters using micromatch to produce the Boolean.

To make optimal use of this function, it is recommended to partially apply the function to produce new functions, as shown in the example below:

// This defines a mapping from roles to permissions.
// We can use wildcards to assign multiple permissions at once.
> var createVerifier = checkPermission({
.   'content-reader': ['content.read', 'images.read'],
.   'content-writer': ['content.write', 'images.upload'],
.   'superadmin': ['*']
. })

// Let's say our user Bob is a content-reader, and also a content-writer.
> var canBob = createVerifier(['content-reader', 'content-writer'])

// And Alice is an administrator.
> var canAlice = createVerifier(['superadmin'])

// Bob has this permission through his content-reader role.
> canBob('content.read')
true

// Bob does not have this permission.
> canBob('users.create')
false

// Alice, however, does. She has all permissions (even the ones
// we haven't thought of yet).
canAlice('users.create')
true

findRoles :: StrMap (Array String) -⁠> String -⁠> Array String

A curried function that takes two arguments and returns an Array of role names:

  1. A mapping from role names to an array of grants represented by glob patterns to match permission names.
  2. A permission name.

This function can be used to answer the question: "Which role do I need to obtain a given permission?"

> var getRequiredRoles = findRoles({
.   'content-reader': ['content.read', 'images.read'],
.   'content-writer': ['content.write', 'images.upload'],
.   'superadmin': ['*']
. })

> getRequiredRoles('content.read')
['content-reader', 'superadmin']
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].