Skip to content

Commit

Permalink
make command.php accesible without auth
Browse files Browse the repository at this point in the history
add logger for unathorised user
  • Loading branch information
sveneld committed Jan 6, 2025
1 parent 5460b26 commit cf6a32a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/packages/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
->accessControl()
->path('^/resetPassword$')
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']);
$security
->accessControl()
->path('^/command.php$')
->roles(['IS_AUTHENTICATED_ANONYMOUSLY']);

$security
->accessControl()
Expand Down
13 changes: 12 additions & 1 deletion src/Controller/CommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace BikeShare\Controller;

use BikeShare\App\Kernel;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class CommandController extends AbstractController
{
Expand All @@ -21,10 +23,19 @@ public function __construct(Kernel $kernel)
* @Route("/command.php", name="command")
*/
public function index(
Request $request
Request $request,
LoggerInterface $logger
): Response {
$kernel = $this->kernel;

if (is_null($this->getUser())) {
$logger->notice('Access to command.php without authentication', [
'ip' => $request->getClientIp(),
'uri' => $request->getRequestUri(),
'request' => $request->request->all(),
]);
}

ob_start();
require_once $this->getParameter('kernel.project_dir') . '/command.php';
$content = ob_get_clean();
Expand Down

0 comments on commit cf6a32a

Please sign in to comment.