Skip to content

About

[Obsolete] Router with ACL support

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Router with ACL support

This component allows to add ACL support to your routes, or in other words, to control access to protected routes. It is a Decorator over a Mendo\Router\RequestMatcherInterface instance.

The component requires three dependencies:

  • a Mendo\Acl\AclInterface instance for ACL support (acl component)
  • a Mendo\Auth\CurrentUserInterface instance to get the user's role (auth component)
  • a Mendo\Router\RequestMatcherInterface instance (router component)

Routes can be protected by specifying the required user role in order to access that route. This is done simply by adding the _role route parameter to the corresponding router.

$router = new Mendo\Router\LiteralRouter('edit-profile', '/profile/edit',
    [
        '_role' => 'member',
    ]
);
$requestMatcher = new Mendo\Router\Acl\RequestAuthorizer($dic['router.requestMatcher'], $dic['acl'], $dic['auth']);

The example above restricts the edit-profile route to authenticated members.

If an unauthorized user tries to access a route, a Mendo\Router\Acl\Exception\NotAuthorizedException exception will be thrown, with a 403 exception code.

Installation

You can install Mendo Router using the dependency management tool Composer. Run the require command to resolve and download the dependencies:

composer require mendoframework/router-acl

About

[Obsolete] Router with ACL support

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages