2017 © Pedro Peláez
 

library authorize-group

Authorize access-control-list (ACL) group

image

jstewmc/authorize-group

Authorize access-control-list (ACL) group

  • Sunday, August 14, 2016
  • by Jstewmc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

authorize-group

Authorize a group to perform an action on a resource., (*1)

Terminology

This library uses the following terminology:, (*2)

  • A user is a person.
  • A resource is a thing, typically a model name. By convention, resources are plural and lower-case (e.g., 'users').
  • An action is something done to a resource, typically a CRUD operation. By convention, actions are singular, present-tense, and lower-case (e.g., 'create').
  • A permission is the right to perform an action on a _resource_ (e.g., 'create' + 'users').
  • A role is a named set of permissions. By convention, roles are singular and lower-cased (e.g., 'administrator')
  • A group is a set of users with a unique name. By convention, groups are plural and lower-case (e.g., 'administrators').

Methodology

This library's methodology is rather simple:, (*3)

  1. A user is assigned to a group.
  2. A group is assigned one or more roles.
  3. A role is granted one or more permissions.
  4. A permission allows an action on a resource.

While users are assigned one or more groups in the database, a group is assigned a role and a role is assigned permissions in a configuration array., (*4)

Example

Finally (haha):, (*5)

use Jstewmc\AuthorizeGroup;

// grant permissions to roles
$roles = [
    // the "administrator" role...
    'administrator' => [
        // for the "users" resource...
        'users' => [
            // has the "create" action
            'create'   
        ]
    ]
];

// assign roles to groups
$groups = [
    // the "administrators" group...
    'administrators' => [
        // has the "administrator" role
        'administrator'
    ]
];

// implement a group named "administrators"
$group = new class implements Group {
    public function getName(): string {
        return 'administrators';
    }
}

// create our authorization service
$authorizer = new Authorize($groups, $roles);

// is the group authorized to create users? (yes)
$authorizer($group, 'create', 'users');

// is the group authorized to delete users? (no)
$authorizer($group, 'delete', 'users');

That's about it!, (*6)

License

MIT, (*7)

Author

Jack Clayton, (*8)

Version

1.0.0, August 16, 2016

  • Major release
  • Fix composer.json
  • Cleanup a few comments

0.1.0, August 3, 2016

  • Initial release

The Versions

14/08 2016

dev-master

9999999-dev

Authorize access-control-list (ACL) group

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

acl php access list authorize control group jstewmc

14/08 2016

v1.0.0

1.0.0.0

Authorize access-control-list (ACL) group

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

acl php access list authorize control group jstewmc

04/08 2016

v0.1.0

0.1.0.0

Authorize access-control-list (ACL) group

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

acl php access list authorize control group jstewmc