You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$app->add(new \Slim\Middleware\JwtAuthentication([
"secret" => "supersecretkeyyoushouldnotcommittogithub",
"callback" => function ($options) use ($app) {
$app->jwt = $options["decoded"];
}
]));
The example above doesn't work anymore. Maybe Slim 3 is overriding properties or don't allow to set the property. Just to remeber, Slim 3 changed some concepts, since DI container appears, is not possible get app instance like this: $app = \Slim\Slim::getInstance();
The text was updated successfully, but these errors were encountered:
Since we can't get $app instance inside a route callable class, what's the purpose of set $app->jwt? Sounds wrong, it's only work inside a route function() definition.
Callback is just an example and that is how I happen to use it. You can of course store the the decoded value somewhere else. Or you can decide not to store it anywhere at all.
As the readme says it is up to you to implement how the token data is stored or possible authorization implemented. Middleware itself does only authentication, ie makes sure the passed token is valid. Using callback is optional. It is provided that you can do something with the decoded token when needed.
The example above doesn't work anymore. Maybe Slim 3 is overriding properties or don't allow to set the property. Just to remeber, Slim 3 changed some concepts, since DI container appears, is not possible get app instance like this: $app = \Slim\Slim::getInstance();
The text was updated successfully, but these errors were encountered: