WIP on liteing the framework
This commit is contained in:
1 parent
bc55a2ab89
commit
9b795b857a
7 files changed
+36
-67
No files matched your search
@@ -25,11 +25,16 @@ return [
|
||||
|
||||
Event\EventDefinition::class => function($c) {
|
||||
return new Event\EventDefinition([
|
||||
new class() implements RoutingCompileRoutes {
|
||||
|
||||
new class($c->has(\Picea\Extension\UrlExtension::class) ? $c->get(\Picea\Extension\UrlExtension::class) : null) implements RoutingCompileRoutes {
|
||||
public function __construct(
|
||||
protected ? \Picea\Extension\UrlExtension $extension,
|
||||
) {}
|
||||
|
||||
public function execute(Routing $routing, Route $attribute) : void
|
||||
{
|
||||
if (null !== ($name = $attribute->name ?? null)) {
|
||||
$routing->extension->registerRoute($name, $attribute->getRoute(), $attribute->class, $attribute->classMethod, $attribute->methods ?? (array)$attribute->method);
|
||||
$this->extension->registerRoute($name, $attribute->getRoute(), $attribute->class, $attribute->classMethod, $attribute->methods ?? (array)$attribute->method);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -45,7 +50,9 @@ return [
|
||||
|
||||
# Checking if user needs to be logged
|
||||
if ( $container->has(SecurityHandler::class) ){
|
||||
if ( $redirect = $container->get(SecurityHandler::class)->verify($class, $method) ) {
|
||||
$securityHandler = $container->get(SecurityHandler::class);
|
||||
|
||||
if ( $redirect = $securityHandler->verify($class, $method) ) {
|
||||
if ( empty($object->user) || ! $object->user->logged ) {
|
||||
$routing->session->set('redirectedFrom', (string) $request->getUri());
|
||||
$routing->response = $redirect;
|
||||
@@ -54,7 +61,7 @@ return [
|
||||
}
|
||||
}
|
||||
|
||||
if ( $container->has(Taxus::class) ) {
|
||||
if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::class) ) {
|
||||
if ( $forbidden = $container->get(SecurityHandler::class)->taxus($class, $method, $object->user ?? null) ) {
|
||||
$routing->response = $forbidden;
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Storage\Session;
|
||||
|
||||
use Taxus\{ Privilege, Taxus, PermissionGrantInterface, DefaultPermissionGrant };
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
return [
|
||||
Taxus::class => function ($c) {
|
||||
return ( new Taxus( $c->get(PermissionGrantInterface::class) ) )->add(
|
||||
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ],
|
||||
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ],
|
||||
[ new Privilege("user", "Is an authenticated user."), "is_user" ],
|
||||
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ],
|
||||
);
|
||||
},
|
||||
|
||||
PermissionGrantInterface::class => create(DefaultPermissionGrant::class)->constructor(get(ServerRequestInterface::class), get(Session::class)),
|
||||
];
|
||||
Reference in new issue
Block a user