Skip to content

Commit 4a2d5bb

Browse files
committed
chore: some additional refvisions
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 9c464bc commit 4a2d5bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

php/public/index.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
const AIO_SESSION_MAX_LIFETIME = '86400'; // (24h)
2626
const AIO_COOKIE_LIFETIME = '0'; // Auto logout on browser close
2727
const AIO_LOG_ERRORS_MAX_LEN = '0'; // Log whole log messages
28-
2928
const AIO_TWIG_CACHE_PATH = false; // e.g., __DIR__ . '/../var/twig-cache'
3029
const AIO_DISPLAY_ERRORS = false;
3130

@@ -54,22 +53,28 @@
5453
$app = AppFactory::create();
5554
$responseFactory = $app->getResponseFactory();
5655

56+
// Register CSRF middleware (container-only)
5757
$container->set(Guard::class, function () use ($responseFactory): Guard {
5858
$guard = new Guard($responseFactory);
5959
$guard->setPersistentTokenMode(true);
6060
return $guard;
6161
});
6262

6363
session_start();
64+
65+
// Activate CSRF middleware for all routes
6466
$app->add(Guard::class);
6567

68+
// Setup and activate Twig middleware
6669
$twig = Twig::create(__DIR__ . '/../templates/',
6770
[ 'cache' => AIO_TWIG_CACHE_PATH ]
6871
);
6972
$app->add(TwigMiddleware::create($app, $twig));
7073

74+
// Add CSRF extension to Twig so templates can access CSRF tokens
7175
$twig->addExtension(new \AIO\Twig\CsrfExtension($container->get(Guard::class)));
7276

77+
// Establish and activate authentication middleware for all routes
7378
$app->add(new \AIO\Middleware\AuthMiddleware($container->get(\AIO\Auth\AuthManager::class)));
7479

7580
//-------------------------------------------------

0 commit comments

Comments
 (0)