- Fixed merges of latest master
This commit is contained in:
commit
1c2ce07179
15 files changed
+187
-86
No files matched your search
@@ -2,20 +2,21 @@
|
||||
|
||||
use Lean\Factory\HttpFactoryInterface;
|
||||
|
||||
use Ulmus\User\{Authorize\HeaderAuthentication,
|
||||
use Ulmus\User\{
|
||||
Authorize\HeaderAuthentication,
|
||||
Entity,
|
||||
Lib\Authenticate,
|
||||
Lib\Authorize,
|
||||
Middleware\AuthenticationMiddleware,
|
||||
Middleware\HeaderAuthenticationMiddleware,
|
||||
Middleware\PostRequestAuthenticationMiddleware,
|
||||
Authorize\PostRequestAuthentication};
|
||||
|
||||
use Picea\Picea;
|
||||
Authorize\PostRequestAuthentication
|
||||
};
|
||||
|
||||
use Storage\{ Cookie, Session };
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Picea\Picea;
|
||||
|
||||
use function DI\{get, autowire, create};
|
||||
|
||||
return [
|
||||
@@ -38,8 +39,9 @@ return [
|
||||
'authorize.error' => function(ContainerInterface $c) {
|
||||
return function(array $errorData) use ($c) {
|
||||
return $c->get(HttpFactoryInterface::class)::createJsonResponse($errorData + [
|
||||
|
||||
'api.error' => "Authorization failed",
|
||||
'api.datetime' => (new \DateTime)->format(\DateTime::ISO8601),
|
||||
'api.datetime' => (new \DateTime)->format(\DateTime::ATOM),
|
||||
], 403);
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Picea\Picea;
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Lean\{ Lean, Routing, Event\RoutingCompileRoutes, Event\RoutingMapRoutes };
|
||||
use Mcnd\Event;
|
||||
use Taxus\Taxus;
|
||||
@@ -11,6 +9,9 @@ use Notes\Route\Attribute\Method\Route;
|
||||
use Notes\Security\SecurityHandler;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||
use Ulmus\User\Entity\UserInterface;
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
return [
|
||||
Event\EventManager::class => autowire(Event\EventManager::class),
|
||||
@@ -25,6 +26,7 @@ return [
|
||||
|
||||
Event\EventDefinition::class => function($c) {
|
||||
$extension = $c->has(\Picea\Extension\UrlExtension::class) ? $c->get(\Picea\Extension\UrlExtension::class) : null;
|
||||
$user = $c->get(UserInterface::class);
|
||||
|
||||
return new Event\EventDefinition([
|
||||
new class($extension) implements RoutingCompileRoutes {
|
||||
@@ -40,7 +42,12 @@ return [
|
||||
}
|
||||
},
|
||||
|
||||
new class() implements RoutingMapRoutes {
|
||||
new class($user) implements RoutingMapRoutes {
|
||||
|
||||
public function __construct(
|
||||
protected UserInterface $user
|
||||
) {}
|
||||
|
||||
public function execute(Routing $routing, ContainerInterface $container, ServerRequestInterface & $request, Route $attribute) : void
|
||||
{
|
||||
$class = $attribute->class;
|
||||
@@ -54,7 +61,7 @@ return [
|
||||
$securityHandler = $container->get(SecurityHandler::class);
|
||||
|
||||
if ( $redirect = $securityHandler->verify($class, $method) ) {
|
||||
if ( empty($object->user) || ! $object->user->logged ) {
|
||||
if (! $this->user->loggedIn() ) {
|
||||
if ($container->has(Session::class)) {
|
||||
$container->get(Session::class)->set('redirectedFrom', (string)$request->getUri());
|
||||
}
|
||||
@@ -64,8 +71,8 @@ return [
|
||||
}
|
||||
}
|
||||
|
||||
if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::class) && $container->has(SecurityHandler::class) ) {
|
||||
if ( $forbidden = $container->get(SecurityHandler::class)->taxus($class, $method, $object->user ?? null) ) {
|
||||
if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::class)) {
|
||||
if ( $forbidden = $securityHandler->taxus($class, $method, $this->user) ) {
|
||||
$routing->response = $forbidden;
|
||||
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
|
||||
use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator };
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter };
|
||||
use Lean\Factory\{ HttpFactory, HttpFactoryInterface };
|
||||
@@ -29,5 +32,8 @@ return [
|
||||
|
||||
'error.500' => function(ContainerInterface $c, Picea $picea) {
|
||||
return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/500", []), 500);
|
||||
}
|
||||
},
|
||||
|
||||
ThrowableHandlerInterface::class => autowire(ThrowableHandler::class),
|
||||
NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class),
|
||||
];
|
||||
@@ -11,8 +11,12 @@ return [
|
||||
]),
|
||||
|
||||
AdapterProxy::class => function (Psr\Container\ContainerInterface $c) {
|
||||
return new AdapterProxy(
|
||||
$c->get(ConnectionAdapter::class),
|
||||
);
|
||||
$proxy = new AdapterProxy();
|
||||
|
||||
$autoload = $c->get(\Lean\Lean::class)->getConnectionAdapters();
|
||||
|
||||
$proxy->push($autoload);
|
||||
|
||||
return $proxy;
|
||||
},
|
||||
];
|
||||
@@ -66,20 +66,14 @@ return [
|
||||
'routes' => [],
|
||||
|
||||
'cronard' => [],
|
||||
|
||||
'taxus' => [
|
||||
'is_dev' => [ ' dev' => "Is a developper of this application or has the same rights" ],
|
||||
'is_admin' => [ 'admin' => "Can manage almost everything in this application."],
|
||||
'is_moderator' => [ 'moderator' => "Can moderate this application."],
|
||||
'is_user' => [ 'user' => "Is an authenticated user."],
|
||||
'is_anonymous' => [ 'anonymous' => "Is an anonymous user."],
|
||||
],
|
||||
],
|
||||
|
||||
'lean.autoload' => add([
|
||||
Lean::class,
|
||||
]),
|
||||
|
||||
\Lean\Factory\HttpFactoryInterface::class => autowire(\Lean\Factory\HttpFactory::class),
|
||||
|
||||
Lean::class => autowire(Lean::class),
|
||||
|
||||
JavascriptMiddleware::class => create(JavascriptMiddleware::class),
|
||||
|
||||
Reference in new issue
Block a user