Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHash committed Nov 26, 2022
1 parent 66fce43 commit 1eefeda
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions src/Middleware/Authorizor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php declare(strict_types=1);
/**
* This file is part of the daikon-cqrs/security-interop project.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Daikon\Security\Middleware;

use Daikon\Boot\Middleware\Action\DaikonRequest;
use Daikon\Boot\Middleware\RoutingHandler;
use Daikon\Security\Middleware\Action\SecureActionInterface;
use Fig\Http\Message\StatusCodeInterface;
use Middlewares\Utils\Factory;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

final class Authorizor implements MiddlewareInterface, StatusCodeInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$requestHandler = $request->getAttribute(RoutingHandler::REQUEST_HANDLER);

if ($requestHandler instanceof SecureActionInterface) {
if (!$requestHandler->isAuthorized(DaikonRequest::wrap($request))) {
return Factory::createResponse(self::STATUS_FORBIDDEN);
}
}

return $handler->handle($request);
}
}

0 comments on commit 1eefeda

Please sign in to comment.