Skip to content

Instantly share code, notes, and snippets.

@l0gicgate
Last active February 27, 2019 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l0gicgate/afa83502152504e56a02fb46154a1231 to your computer and use it in GitHub Desktop.
Save l0gicgate/afa83502152504e56a02fb46154a1231 to your computer and use it in GitHub Desktop.
<?php
use DI\Container;
use DI\ContainerBuilder;
use Slim\App;
use Tuupola\JwtAuthentication;
$containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions([
'JwtAuthenticationSettings' => [
'secret' => getenv('jwt_secret'),
'path' => ['/admin/api'],
'ignore' => ['/admin/api/login'],
'error' => function (Response $response, $arguments) {
return $response->withJson([
'message' => $arguments['message'],
], 401);
}
],
JwtAuthentication::class => DI\create()->constructor(DI\get('JwtAuthenticationSettings'))
]);
$container = $containerBuilder->build();
$app = new App($container);
$app->group('whatever', function () {
...
})->add(JwtAuthentication::class);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment