修改token增加bearer后验证问题

This commit is contained in:
wanglei 2025-11-01 16:34:31 +08:00
parent 64b4e82145
commit eb4228a200
2 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
local jwt = require "resty.jwt"
local validators = require "resty.jwt-validators"
local cjson = require("cjson.safe")
local conf = require("config")
-- 定义一个JSON Schema
@ -29,7 +29,7 @@ if token == nil then
end
--校验令牌
local jwt_obj = jwt:verify(conf.secret_key, auth_header)
local jwt_obj = jwt:verify(conf.secret_key, token)
--如果校验结果中的verified==false则表示令牌无效
if jwt_obj.verified == false then
ngx.log(ngx.WARN, "Invalid token: ".. jwt_obj.reason)

View File

@ -56,7 +56,7 @@ function _M.authorizationToken(auth_header)
end
--校验令牌
local jwt_obj = jwt:verify(conf.secret_key, auth_header)
local jwt_obj = jwt:verify(conf.secret_key, token)
--如果校验结果中的verified==false则表示令牌无效
if jwt_obj.verified == false then
response["code"] = 401