apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: forward-auth plugin POST request timeout

Open dashixiongsk opened this issue 11 months ago • 8 comments

Current Behavior

The forward auth plugin uses post requests, request_headers configures Content Type request headers, and requests timeout

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

this is my config:

{
    "forward-auth": {
        "_meta": {
            "disable": false
        },
        "client_headers": [
            "Location"
        ],
        "keepalive": false,
        "request_headers": [
            "Authorization"
        ],
        "request_method": "POST",
        "upstream_headers": [
            "xx-gw-id"
        ],
        "uri": "http://127.0.0.1:9080/checkAuth"
    }
}

I timed out using the Postman request interface。 When I removed the Content Type from request_headers, it did not time out but reported an error: {"code": 400, "reason": "CODEC", "message": "unregister Content Type:", "metadata": {}}

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

dashixiongsk avatar Mar 15 '24 09:03 dashixiongsk

"Authorization", "Content-Type", Content-Length "x-offcn-gateway-id",

There is something wrong with this json format. Please make sure the json format is OK

theweakgod avatar Mar 18 '24 02:03 theweakgod

Sorry, the json format has been changed

dashixiongsk avatar Mar 19 '24 02:03 dashixiongsk

Can you try example like this ? https://apisix.apache.org/docs/apisix/plugins/forward-auth/#example-usage I have try to do like it , it works fine .

hanqingwu avatar Mar 20 '24 09:03 hanqingwu

@hanqingwu Yes, I have no problem with that example on my end. Now downgrade the version from 3.8.0 to 3.6.0, there's no problem

dashixiongsk avatar Mar 20 '24 09:03 dashixiongsk

thanks @dashixiongsk . I was having the same issue and successfully resolved it by downgrading to 3.6.0

UzairM avatar Mar 22 '24 11:03 UzairM

@dashixiongsk to clarify - this timeout error is encountered when setting "request_method": "POST"?

kayx23 avatar Apr 29 '24 04:04 kayx23

我这边遇到了同样的问题,验证3.6.0 及 3.7.0 是可以的,但是3.8.0及以上就会出现同样的问题,POST转发到下游,下游无法读取

org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters,line: 195,params: ,err_msg:
org.springframework.http.converter.HttpMessageNotReadableException: I/O error while reading input message
	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:195)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:163)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:136)
	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)

luodadaRyan avatar Jul 23 '24 11:07 luodadaRyan