2017 © Pedro Peláez
 

library permission-matcher

A permission matcher for PHP

image

legalthings/permission-matcher

A permission matcher for PHP

  • Tuesday, July 11, 2017
  • by jasny
  • Repository
  • 7 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 59 % Grown

The README.md

Legal Things - Permission matcher

With the permission matcher library, you can check whether a user is allowed to have access to specific resources. Specifying resources and access control levels is up to the client of the library., (*1)

Requirements

Required PHP extensions are marked by composer, (*2)

Installation

The library can be installed using composer., (*3)

composer require legalthings/permission-matcher

How it works

The library exposes one function with which you can get a list of privileges for matching authz groups. Authz groups can be anything you want, in the example below resource URIs are used, but you could also use a string of any format. In the example we have a user that has certain permissions attached to him. We can then ask the PermissionMatcher class to extract the permissions of the users for a given authz group. Note that you can use wildcards *. You can also invert a permission by placing a ! in front of the authz group., (*4)

$matcher = new PermissionMatcher();

$permissionsThatSomeUserHas = [
    '/organizations/0001' => ['full-access'],
    '/organizations/0002?list=all' => 'list',
    '/organizations/0003/*/foo' => ['read', 'write']
];

echo $matcher->match($permissionsThatSomeUserHas, ['/organizations/0001']);
// outputs ['full-access']

echo $matcher->match($permissionsThatSomeUserHas, ['/organizations/0001', '/organizations/0003/random/foo']);
// outputs ['full-access', 'read', 'write']

echo $matcher->match($permissionsThatSomeUserHas, ['/organizations/0002']);
// outputs []

echo $matcher->match($permissionsThatSomeUserHas, ['/organizations/0002?list=all']);
// outputs ['list']

echo $matcher->match($permissionsThatSomeUserHas, ['/organizations/*']);
// outputs ['full-access', 'read', 'write']

The Versions

11/07 2017

dev-master

9999999-dev

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires

11/07 2017

dev-fix-invert

dev-fix-invert

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires

18/01 2017

dev-improve-code

dev-improve-code

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires

13/01 2017

0.1

0.1.0.0

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires

13/01 2017

dev-reverse-priviliges

dev-reverse-priviliges

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires

02/11 2016

dev-inverted-permissions

dev-inverted-permissions

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires

09/05 2016

v0.0.2

0.0.2.0

A permission matcher for PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-pcre *

 

The Development Requires