配置 /tuupola/slim-jwt-auth 拒绝通过 HTTP 不安全地使用中间件

问题描述 投票:0回答:1

我在 PHP Slim 4 框架中使用 JWT 令牌。该代码在本地计算机上运行良好,但是当我将代码推送到谷歌云时,我收到错误,因为 配置拒绝通过 HTTP 不安全地使用中间件。

附上错误日志的屏幕截图:

enter image description here

以下是我的 JWT 配置:

<?php
$ignoreUrl = "";

$app->add(new Tuupola\Middleware\JwtAuthentication([
    "header" => "X-Token",
    "regexp" => "/(.*)/",
    "path" => "/public", 
    "secure" => true,
    "secret" => "123456789",
    "algorithm" => ["HS256"],
    "ignore" => [
        $ignoreUrl."/public/account/login", 
        $ignoreUrl."/public/account/logout"
    ],
    "error" => function ($response, $arguments) {
        $data["status"] = false;
        $data["message"] = $arguments["message"];
        return $response
            ->withHeader("Content-Type", "application/json")
            ->getBody()->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
    }
]));

尝试了很多解决方案,但没有任何效果。你能建议我的代码有什么问题吗?先谢谢你了

php jwt slim slim-3
1个回答
0
投票

设置, “安全”=> 假,

这将解决问题。不过,不建议在实时服务器中使用。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.