-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Failed auth with body transformer not working #11608
Comments
this indeed looks like a bug, please share your apisix resource configurations |
Consumer: {
"plugins": {
"key-auth": {
"key": "abcdef"
}
},
"username": "consumer_user"
} Route: {
"name": "Some route",
"status": 1,
"plugins": {
"key-auth": {
"_meta": {
"disable": true
},
"hide_credentials": true
},
"body-transformer": {
"request": {
"input_format": "json",
"template_is_base64": true,
"template": "<base64 template>"
}
},
"proxy-rewrite": {
"regex_uri": [
"^/some-route",
"/other-route"
],
"use_real_request_uri_unsafe": false
}
},
"host": "host.example.com",
"methods": [
"GET",
"POST"
],
"uri": "/some-route",
"upstream": {
"scheme": "https",
"type": "roundrobin",
"nodes": [
{
"host": "other-host.example.com",
"weight": 1,
"priority": 0,
"port": 443
}
],
"hash_on": "vars",
"timeout": {
"connect": 6,
"read": 6,
"send": 6
},
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
},
"pass_host": "node"
}
} Request: curl --request POST \
--url 'https://host.example.com/some-route?apikey=abcdef' \
--header 'Content-Type: application/json' \
--data '{
"attr1": "value 1",
"attr2": "value 2"
}' |
Hi. I have done some digging and maybe I have something to add. I'm very new to Lua and APISIX so, I might be way off track. The fact that Line 1174 in a91e79a
A few lines later, it Until someone that knows what they are doing can have a look at this, I have a dodgy workaround.
This uses the ctx variable to enumerate all plugins enabled for this request. It finds the Complete plugin:
Put the above in a file called |
@ShaunMaher, the apisix/apisix/plugins/body-transformer.lua Line 194 in 4bbb7cc
But during body_filter phase, body-transformer's body_filter function is called and APISIX panics because apisix/apisix/plugins/body-transformer.lua Lines 219 to 220 in 4bbb7cc
This can be fixed just by adding a nil check. |
Thanks for the feedback. One thing I still don't quite understand though is whether or not the I'm happy to come up with a PR that updates the code in body-transformer and the doco if you like. Cheers. |
Current Behavior
I have in route key-auth and body-transformer plugins. When key-auth plugin fail ([lua] plugin.lua:1171: run_plugin(): key-auth exits with http status code 401) then body-transformer horibly crash with error
When I remove key-auth plugin or key-auth doesn't fail, it works as expected.
Expected Behavior
It should probably stop executing next plugins or at least body-transformer should have all data to not crash.
Error Logs
Steps to Reproduce
Environment
apisix version
): 3.10.0The text was updated successfully, but these errors were encountered: