1. Go to this page and download the library: Download apigopro/slim-jwt-auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
apigopro / slim-jwt-auth example snippets
use SlimJwtAuth\JwtAuthMiddleware;
$app->add(new JwtAuthMiddleware([
'secret' => 'supersecretkeyyoushouldnotcommittogithub',
'path' => ['/api'], // only these paths dClass)
$response->getBody()->write($claims->sub);
return $response;
});
use SlimJwtAuth\JwtAuthMiddleware;
use SlimJwtAuth\RbacMiddleware;
$app->add(new JwtAuthMiddleware(['secret' => $secret, 'path' => ['/api']]));
// Only "admin" (or any role you list) may hit this group.
$app->group('/api/admin', function ($group) {
$group->get('/users', ListUsersAction::class);
})->add(RbacMiddleware::