Skip to content

Commit

Permalink
fix(jwe-decrypt): decryption failure (#10843)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanqingwu committed Jan 24, 2024
1 parent fa3f220 commit ee209a7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apisix/plugins/jwe-decrypt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ local function jwe_decrypt_with_obj(o, consumer)
secret,
nil,
cipher,
{iv = o.iv}
{iv = dec(o.iv)}
)

local decrypted = aes_default:decrypt(dec(o.ciphertext), dec(o.tag))
Expand Down
44 changes: 44 additions & 0 deletions t/plugin/jwe-decrypt.t
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,47 @@ GET /hello
Authorization: eyJhbGciOiJkaXIiLCJraWQiOiJ1c2VyLWtleSIsImVuYyI6IkEyNTZHQ00ifQ..MTIzNDU2Nzg5MDEy._0DrWD0.vl-ydutnNuMpkYskwNqu-Q
--- response_body
hello world
=== TEST 22: enable jwt decrypt plugin with test upstream route
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/3',
ngx.HTTP_PUT,
[[{
"plugins": {
"jwe-decrypt": {
"header": "Authorization",
"forward_header": "Authorization"
}
},
"upstream": {
"nodes": {
"httpbin.org": 1
},
"type": "roundrobin"
},
"uri": "/headers"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed
=== TEST 23: verify in upstream header
--- request
GET /headers
--- more_headers
Authorization: eyJhbGciOiJkaXIiLCJraWQiOiJ1c2VyLWtleSIsImVuYyI6IkEyNTZHQ00ifQ..MTIzNDU2Nzg5MDEy._0DrWD0.vl-ydutnNuMpkYskwNqu-Q
--- response_body_like
.*"Authorization": "hello".*

0 comments on commit ee209a7

Please sign in to comment.