for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/
declare(strict_types=1);
namespace Spiral\Auth\Middleware\Firewall;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\UriInterface;
use Psr\Http\Server\RequestHandlerInterface;
* Changes the target URL to login form without altering URL in client browser. Changes response status.
final class OverwriteFirewall extends AbstractFirewall
{
/** @var UriInterface */
private $uri;
/** @var int */
private $status;
* @param UriInterface $uri
* @param int $status
public function __construct(UriInterface $uri, int $status = 401)
$this->uri = $uri;
$this->status = $status;
}
* @inheritDoc
protected function denyAccess(Request $request, RequestHandlerInterface $handler): Response
return $handler->handle($request->withUri($this->uri))->withStatus($this->status);