2017 © Pedro Peláez
 

windwalker-package authorisation

Windwalker Authorisation package

image

windwalker/authorisation

Windwalker Authorisation package

  • Tuesday, February 20, 2018
  • by asika32764
  • Repository
  • 3 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 30 Versions
  • 0 % Grown

The README.md

Windwalker Authorisation

Installation via Composer

Add this to the require block in your composer.json., (*1)

``` json { "require": { "windwalker/authorisation": "~3.0" } }, (*2)


## Create Authorisation and add policies A simple example to use Closure as policy with action name `can.edit.article`. ``` php use Windwalker\Authorisation\Authorisation; $auth = new Authorisation; $auth->addPolicy('can.edit.article', function (User $user, \stdClass $article) { return $user->isAdmin() || $user->id == $article->author_id; }); // Check access $auth->authorise('can.edit.article', $user, $article); // boolean

Use Authorisation to Make ACL system

We can also use Authorisation object as a ACL handler, see this example. We find blog.article actions from acl_list table in database, and check the can.edit action greater then 1, so it means this user (or group) has access to edit all articles in blog., (*3)

``` php $auth->addPolicy('can.edit', function (User $user, $assetName) { $action = $db->prepare('SELECT access FROM acl_list WHERE action = :action AND asset = :asset AND group = :group') ->bind('action', 'can.edit') ->bind('asset', $assetName) ->bind('group', $user->group_id) ->execute() ->fetchObject();, (*4)

return $action >= 1;

});, (*5)

// Can edit articles $auth->authorise('can.edit', $user, 'blog.article'); // boolean, (*6)

// Can edit article with id = 3 $auth->authorise('can.edit', $user, 'blog.article.3'); // boolean, (*7)


> NOTE: This is just an simple example to show how ACL works, you must write your own rules to implements ACL system. ## Pre-defined Policy We can define a policy by creating classes which implements `PolicyInterface`. ``` php class CanEditPolicy implements \Windwalker\Authorisation\PolicyInterface { public function authorise($user, $data = null) { return $user->isAdmin() || $user->id == $data->author_id; } } $auth->addPolicy('can.edit', new CanEditPolicy); // After PHP 5.5, you can simply use ::class to add class name $auth->addPolicy('can.edit', CanEditPolicy::class);

Register Multiple Policies

Use Policy Provider, we can define policies in a class that is more easily to add multiple policies., (*8)

``` php use Windwalker\Authorisation\AuthorisationInterface; use Windwalker\Authorisation\PolicyProviderInterface;, (*9)

class ArticlePolicyProvider implements PolicyProviderInterface { public function register(AuthorisationInterface $auth) { $auth->addPolicy('can.create.article', function () { ... }); $auth->addPolicy('can.edit.article', function () { ... }); $auth->addPolicy('can.edit.own.article', function () { ... }); $auth->addPolicy('can.delete.article', function () { ... }); } }, (*10)

// Register policies $auth->registerPolicyProvider(new ArticlePolicyProvider); ```, (*11)

The Versions

20/02 2018

dev-master

9999999-dev https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

dev-test

dev-test https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+ LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.3

3.3.0.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.3.1

3.3.1.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.3.2

3.3.2.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.4

3.4.0.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.4.1

3.4.1.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.4.2

3.4.2.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.4.3

3.4.3.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

20/02 2018

3.4.4

3.4.4.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.2

3.2.2.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.3

3.2.3.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.4

3.2.4.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.5

3.2.5.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.6

3.2.6.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.7

3.2.7.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

09/06 2017

3.2.8

3.2.8.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

05/06 2017

3.2.1

3.2.1.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

21/03 2017

3.2

3.2.0.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

framework authorisation windwalker

15/12 2016

3.1.4

3.1.4.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

15/12 2016

3.1.5

3.1.5.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

15/12 2016

3.1.6

3.1.6.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

18/07 2016

3.0

3.0.0.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

18/07 2016

3.0.1

3.0.1.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

18/07 2016

3.1

3.1.0.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

18/07 2016

3.1.1

3.1.1.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

18/07 2016

3.1.2

3.1.2.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

18/07 2016

3.1.3

3.1.3.0 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

06/07 2016

3.0-beta2

3.0.0.0-beta2 https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker

04/07 2016

3.0-beta

3.0.0.0-beta https://github.com/ventoviro/windwalker-authorisation

Windwalker Authorisation package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework authorisation windwalker