1. Go to this page and download the library: Download zycon42/security 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/ */
zycon42 / security example snippets
if (!$securityContext->isGranted('ROLE_ADMIN'))
throw new ForbiddenRequestException('You need to be admin');
if (!$securityContext->isGranted('EDIT', $post))
throw new ForbiddenRequestException("You are not able to edit this $post");
class SecuredPresenter extends BasePresenter
{
// ... some code
/**
* @var PresenterRequirementsChecker
* @inject
*/
public $t, $this->request)) {
// logged users get 403 and anonymous users get redirect to sign in
if ($this->user->isLoggedIn()) {
$expr = $this->
/**
* @Security("hasRole('ADMIN')")
*/
class UsersPresenter extends SecuredPresenter
{
// ... some code
}
class UsersPresenter extends SecuredPresenter
{
// ... some code
/**
* @Security("hasRole('ADMIN')")
*/
public function actionEdit($id) {
// ... implementation
}
}
class PostPresenter extends SecuredPresenter
{
// ... some code
/**
* @Security("hasPermission(post, 'EDIT')")
*/
public function actionEdit(Post $post) {
// ... implementation
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.