1. Go to this page and download the library: Download nepada/security-annotations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nepada / security-annotations example snippets
use Nepada\SecurityAnnotations\Annotations\Allowed;
use Nepada\SecurityAnnotations\Annotations\LoggedIn;
use Nepada\SecurityAnnotations\Annotations\Role;
/**
* To access this presenter the user must be logged in.
*/
#[LoggedIn]
class SecuredPresenter extends Nette\Application\UI\Presenter
{
use Nepada\SecurityAnnotations\SecurityAnnotations;
#[Role("admin", "superadmin")]
public function actionForAdmins(): void
{
// Only users with role admin or superadmin are allowed here.
}
#[Allowed(resource: "world", privilege: "destroy")]
public function handleDestroyWorld(): void
{
// Only users with specific permission are allowed to call this signal.
}
}
use Nepada\SecurityAnnotations\Annotations\LoggedIn;
class SecuredPresenter extends Nette\Application\UI\Presenter
{
use Nepada\SecurityAnnotations\SecurityAnnotations;
#[LoggedIn]
public function actionDefault(): void
{
// ...
}
protected function createComponentForm(): Nette\Application\UI\Form
{
$form = new Nette\Application\UI\Form();
$form->addSubmit('Do something dangerous');
$form->onSuccess[] = function (Nette\Application\UI\Form $form): void {
// ...
};
return $form;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.