Last active
February 27, 2019 02:39
-
-
Save l0gicgate/afa83502152504e56a02fb46154a1231 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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