psr-jwt
psr-jwt copied to clipboard
How to apply the middleware globally for all routes?
Hello please help. I'm trying to apply the middleware globally but it fails. Only works if added to each route.
This is how I use the handler:
// The handler.
$jsonHandler = new Json($secretKey, '', ['message' => 'Authorization Failed']);
// The middleware.
$jwtMiddleware = new JwtAuthMiddleware($jsonHandler);
// JWT middleware (applies to all routes)
$app->add($jwtMiddleware);
Thank you!