2017 © Pedro Peláez
 

library nette-authorizator

Authorizator extension for Nette Framework

image

geniv/nette-authorizator

Authorizator extension for Nette Framework

  • Tuesday, January 30, 2018
  • by geniv
  • Repository
  • 1 Watchers
  • 0 Stars
  • 166 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

ACL

Installation

$ composer require geniv/nette-authorizator

or, (*1)

"geniv/nette-authorizator": ">=1.0.0"

require:, (*2)

"php": ">=5.6.0",
"nette/nette": ">=2.4.0",
"dibi/dibi": ">=3.0.0"

Include in application

available source drivers:

  • Neon (neon filesystem) - support form
  • Dibi (dibi + cache) - support form
  • Array (neon configure)

policy:

  • allow - all is deny, allow part
  • deny - all is allow, deny part
  • none - all is allow, ignore part

neon configure:, (*3)

# acl
authorizator:
#   autowired: false    # default null, true|false|self|null
    policy: allow       # allow (all is deny, allow part) | deny (all is allow, deny part) | none (all is allow, ignore part)
    source: "Neon"
    path: %appDir%/components/test/nette-authorizator/sql/acl.neon
#    source: "Dibi"
#    tablePrefix: %tablePrefix%
#    source: "Array"
#    role:
#        - guest
#        - moderator
#        - admin
#    resource:
#        - article
#        - comment
#        - poll
#    privilege:
#        - show
#        - insert
#        - update
#        - delete
#    acl:
#        moderator:
#            article: [show, insert, update]
#        admin: all

neon configure extension:, (*4)

extensions:
    authorizator: Authorizator\Bridges\Nette\Extension

presenters:, (*5)

$acl = $this->user->getAuthorizator();
$acl->isAllowed('guest', 'sekce-forum', 'zobrazit');

$this->user->isAllowed('sekce-forum', 'zobrazit');

usage:, (*6)

<span n:if="$user->isAllowed('sekce-forum', 'zobrazit')">...</span>

All method onSuccess callback are default defined like $this->redirect('this');, (*7)

presenters form:, (*8)

use Authorizator\Forms\AclForm;
use Authorizator\Forms\PrivilegeForm;
use Authorizator\Forms\ResourceForm;
use Authorizator\Forms\RoleForm;
...
abstract class BasePresenter extends Presenter
{
    use AutowiredComponent;
...

protected function createComponentRoleForm(RoleForm $roleForm): RoleForm
{
    //$roleForm->setTemplatePath(path);
    //$roleForm->onSuccess[] = function (array $values) { };
    //$roleForm->onError[] = function (array $values, Exception $e = null) { };
    return $roleForm;
}


protected function createComponentResourceForm(ResourceForm $resourceForm): ResourceForm
{
    //$resourceForm->setTemplatePath(path);
    //$resourceForm->onSuccess[] = function (array $values) { };
    //$resourceForm->onError[] = function (array $values, Exception $e = null) { };
    return $resourceForm;
}


protected function createComponentPrivilegeForm(PrivilegeForm $privilegeForm): PrivilegeForm
{
    //$privilegeForm->setTemplatePath(path);
    //$privilegeForm->onSuccess[] = function (array $values) { };
    //$privilegeForm->onError[] = function (array $values, Exception $e = null) { };
    return $privilegeForm;
}

protected function createComponentAclForm(AclForm $aclForm): AclForm
{
    //$aclForm->setTemplatePath(path);
    //$aclForm->onSuccess[] = function (array $values) { };
    //$aclForm->onError[] = function (array $values) { };
    return $aclForm;
}

generic usage on security base presenter:, (*9)

$acl = $this->user->getAuthorizator();
// manual set allowed with internal resolve policy
$acl->setAllowed(IAuthorizator::ALL, 'Homepage');
$acl->setAllowed(IAuthorizator::ALL, 'Login');

if (!$this->user->isAllowed($this->name, $this->action)) {
    // NOT ALLOWED
}

form not required for correct function ACL., (*10)

Available form: role, resource, privilege and acl., (*11)

usage form:, (*12)

{control roleForm}
{control resourceForm}
{control privilegeForm}
{control aclForm}

The Versions

30/01 2018

dev-develop

dev-develop

Authorizator extension for Nette Framework

  Sources   Download

MIT GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

27/01 2018

dev-master

9999999-dev

Authorizator extension for Nette Framework

  Sources   Download

MIT GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

27/01 2018

v1.1.7

1.1.7.0

Authorizator extension for Nette Framework

  Sources   Download

MIT

The Requires

 

by Radek Frystak

acl nette authorizator geniv

19/01 2018

v1.1.6

1.1.6.0

Authorizator extension for Nette Framework

  Sources   Download

MIT

The Requires

 

by Radek Frystak

acl nette authorizator geniv

10/01 2018

v1.1.5

1.1.5.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

05/01 2018

v1.1.4

1.1.4.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

01/01 2018

v1.1.3

1.1.3.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

14/11 2017

v1.1.2

1.1.2.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

09/11 2017

v1.1.1

1.1.1.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

06/11 2017

v1.1.0

1.1.0.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

21/08 2017

v1.0.1

1.0.1.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv

06/08 2017

v1.0.0

1.0.0.0

Authorizator extension for Nette Framework

  Sources   Download

GPL-3.0

The Requires

 

by Radek Frystak

acl nette authorizator geniv