dkx / slim-security
This package is abandoned and no longer maintained.
No replacement package was suggested.
Security package for slim framework
0.0.1
2019-06-26 14:18 UTC
Requires
- php: ^7.3
- dkx/callable-parser: ^0.0.1
- dkx/security: ^0.0.2
- doctrine/annotations: ^1.6
- slim/slim: ^3.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.11.8
- phpstan/phpstan-phpunit: ^0.11.2
- phpstan/phpstan-strict-rules: ^0.11.1
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-01-27 01:02:53 UTC
README
Security package inspired by symfony security and voters. Based on dkx/security.
Only for class routes.
See dkx/security for complete documentation.
Installation
$ composer require dkx/security dkx/slim-security
Usage
<?php
use DKX\Security\Security;
use DKX\SlimSecurity\SecuredRequestResponse;
use Doctrine\Common\Annotations\AnnotationReader;
use Slim\Container;
$container = new Container;
$container['foundHandler'] = function() use ($container) {
$original = $container->get('foundHandler');
return new SecuredRequestResponse(
$original,
new Security,
new AnnotationReader
);
};
Annotate controllers
<?php
use DKX\SlimSecurity\Annotations\IsGranted;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
/**
* @IsGranted("ROLE_ADMIN")
*/
final class DetailController
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
return $response;
}
}