如何使用JWT SLIM中间件进行身份验证?
此代码可以工作,但如何通过GET请求获取查看/api
内容的权限??
<?php
use PsrHttpMessageServerRequestInterface as Request;
use PsrHttpMessageResponseInterface as Response;
require 'vendor/autoload.php';
$app = new SlimApp();
$app->add(new SlimMiddlewareJwtAuthentication([
"path" => "/api",
"secret" => "1234"
]));
$app->get('/api', function (Request $request, Response $response) {
echo "Hi";
});
$app->get('/teste', function (Request $request, Response $response) {
echo "Hi";
});
$app->run();
解决方案
我用的是Authorization: Bearer Mykey
,密钥需要在jwt模式下编码
相关文章