klimesf/secured

@Secured annotation for Nette framework

v0.1 2015-01-05 18:35 UTC

README

@Secured annotation for Nette framework inspired by Spring's @Secured annotation.

Installation

First, you need to have Kdyby\AOP installed and configured.

Install Secured using composer:

composer require klimesf/secured:@dev

and register SecuredAspect in your Nette application:

aspects:
	- Klimesf\Secured\Secured

Usage

class Service
{

	/**
	 * @Klimesf\Secured\Secured(roles = {"admin"})
	 */
	public function doStuff() {
		// do stuff requiring admin role ...
	}
  
}

If current Nette\Security\User is not logged in or does not have required roles, Nette\Security\AuthenticationException will be thrown.

Notes

Note: Due to a bug in Kdyby\AOP, you can't import the annotation with use statements at this moment. Until it's fixed you have to provide fully qualified name of the annotation (@Klimesf\Secured\Secured)

Note: You cannot annotate presenter methods.

Note: This extension was inspired by redhead/Cached.