You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "lplcc (via GitHub)" <gi...@apache.org> on 2023/10/31 07:36:20 UTC
[PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
lplcc opened a new pull request, #10425:
URL: https://github.com/apache/apisix/pull/10425
### Description
The gateway returns 403 forbidden in the forward-auth.lua file because the post request body is too large
Fixes # (issue)
### Checklist
- [ ] I have explained the need for this PR and the problem it solves
- [ ] I have explained the changes or the new features added to this PR
- [ ] I have added tests corresponding to this change
- [ ] I have updated the documentation to reflect this change
- [ ] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
<!--
Note
1. Mark the PR as draft until it's ready to be reviewed.
2. Always add/update tests for any changes unless you have a good reason.
3. Always update the documentation to reflect the changes made in the PR.
4. Make a new commit to resolve conversations instead of `push -f`.
5. To resolve merge conflicts, merge master instead of rebasing.
6. Use "request review" to notify the reviewer after making changes.
7. Only a reviewer can mark a conversation as resolved.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1409012266
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
I agree with @Gallardot, it's ok to use `core.request.get_body()` if the `content-length` is missing, the client should ensure the input format is correct.
But we should not check the `err` value of `local client_body_reader, err = httpc:get_client_body_reader()`, because the `err` will be `nil` if the `content-length` is missing. https://github.com/ledgetech/lua-resty-http/blob/master/lib/resty/http.lua#L999
So the code is like:
```
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if client_body_reader then
params.body = client_body_reader
else
core.warn(...)
params.body = core.request.get_body()
end
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1378422113
##########
apisix/plugins/forward-auth.lua:
##########
@@ -117,7 +117,8 @@ function _M.access(conf, ctx)
local httpc = http.new()
httpc:set_timeout(conf.timeout)
-
+ local client_body_reader, err = httpc:get_client_body_reader()
+ params.body=client_body_reader
Review Comment:
Why do you add this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1409012266
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
I agree with @Gallardot, it's ok to use `core.request.get_body()` if the `content-length` is missing, the client should ensure the input is correct.
But we can't check the `err` value of `local client_body_reader, err = httpc:get_client_body_reader()`, because the `err` will be `nil` if the `content-length` is missing. https://github.com/ledgetech/lua-resty-http/blob/master/lib/resty/http.lua#L999
```
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if client_body_reader then
params.body = client_body_reader
else
params.body = core.request.get_body()
end
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 closed pull request #10425: fix: forward-auth request body is too large
URL: https://github.com/apache/apisix/pull/10425
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "Gallardot (via GitHub)" <gi...@apache.org>.
Gallardot commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1401428424
##########
apisix/plugins/forward-auth.lua:
##########
@@ -117,7 +117,8 @@ function _M.access(conf, ctx)
local httpc = http.new()
httpc:set_timeout(conf.timeout)
-
+ local client_body_reader, err = httpc:get_client_body_reader()
+ params.body=client_body_reader
Review Comment:
Agree with @monkeyDluffy6017 . Additionally, if this is a GET request, this approach may not be appropriate.
##########
apisix/plugins/forward-auth.lua:
##########
@@ -117,7 +117,8 @@ function _M.access(conf, ctx)
local httpc = http.new()
httpc:set_timeout(conf.timeout)
-
+ local client_body_reader, err = httpc:get_client_body_reader()
+ params.body=client_body_reader
Review Comment:
Agree with @monkeyDluffy6017 . Additionally, if this is a `GET` request, this approach may not be appropriate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 closed pull request #10425: fix:Solve the 403 problem caused by the post request body is too large
URL: https://github.com/apache/apisix/pull/10425
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1404775400
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
That won't work if the `Content-Length` header is missing as `client_body_reader` requires it to be provided.
Apparently, reading `req_body` implicitly fixes this problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1409012266
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
I agree with @Gallardot, it's ok to use `core.request.get_body()` if the `content-length` is missing, the client should ensure the input format is correct.
But we should not check the `err` value of `local client_body_reader, err = httpc:get_client_body_reader()`, because the `err` will be `nil` if the `content-length` is missing. https://github.com/ledgetech/lua-resty-http/blob/master/lib/resty/http.lua#L999
So the code is like:
```
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if client_body_reader then
params.body = client_body_reader
else
params.body = core.request.get_body()
end
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1788457898
I will close this pr first, let's discuss this in the issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1821970227
I am checking this, the current fix is causing some other failures that need to be fixed first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1409012266
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
I agree with @Gallardot, it's ok to use `core.request.get_body()` if the `content-length` is missing, the client should ensure the input is correct.
But we should not check the `err` value of `local client_body_reader, err = httpc:get_client_body_reader()`, because the `err` will be `nil` if the `content-length` is missing. https://github.com/ledgetech/lua-resty-http/blob/master/lib/resty/http.lua#L999
So the code is like
```
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if client_body_reader then
params.body = client_body_reader
else
params.body = core.request.get_body()
end
end
```
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
I agree with @Gallardot, it's ok to use `core.request.get_body()` if the `content-length` is missing, the client should ensure the input is correct.
But we should not check the `err` value of `local client_body_reader, err = httpc:get_client_body_reader()`, because the `err` will be `nil` if the `content-length` is missing. https://github.com/ledgetech/lua-resty-http/blob/master/lib/resty/http.lua#L999
So the code is like:
```
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if client_body_reader then
params.body = client_body_reader
else
params.body = core.request.get_body()
end
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1410094460
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
my bad, the request already carries the content-length and other necessary headers... we just need to make sure that these headers are also sent to the auth server
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1833290135
@shreemaan-abhishek please fix the code lint error
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1378422113
##########
apisix/plugins/forward-auth.lua:
##########
@@ -117,7 +117,8 @@ function _M.access(conf, ctx)
local httpc = http.new()
httpc:set_timeout(conf.timeout)
-
+ local client_body_reader, err = httpc:get_client_body_reader()
+ params.body=client_body_reader
Review Comment:
Why do you add this? try to increase the `conf.timeout`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "lplcc (via GitHub)" <gi...@apache.org>.
lplcc commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1786900039
but I can't solve this error “ [error] 98340#98340: *40 [lua] init.lua:551: handle_upstream(): failed to set upstream: missing upstream configuration in Route or Service”,
I just added two lines of code in the forward-auth.lua file
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1411850592
##########
t/plugin/forward-auth.t:
##########
@@ -374,3 +401,41 @@ GET /hello
--- more_headers
Authorization: 111
--- error_code: 200
+
+
+
+=== TEST 13: test large body
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin")
+ local http = require("resty.http")
+ local httpc = http.new()
+
+ local tempFileName = os.tmpname()
+ local file = io.open(tempFileName, "wb")
+
+ local fileSizeInBytes = 11 * 1024 * 1024 -- 11MB
+ for i = 1, fileSizeInBytes do
+ file:write(string.char(0))
+ end
+ file:close()
+
+ local large_body = t.read_file(tempFileName)
+ local uri = "http://127.0.0.1:" .. ngx.var.server_port
+ .. "/large-body"
+ local res, err = httpc:request_uri(uri,
+ {
+ method = "POST",
+ body = large_body,
+ headers = {
+ ["Authorization"] = "large-body",
+ ["Content-Type"] = "application/x-www-form-urlencoded"
+ }
+ }
+ )
+
+ ngx.say(res.body)
Review Comment:
```
2023/12/01 17:40:30 [warn] 92639#13489089: *46 a client request body is buffered to a temporary file /Users/guohao/workspace/apisix/t/servroot/client_body_temp/0000000001, client: 127.0.0.1, server: localhost, request: "POST /auth HTTP/1.1", host: "127.0.0.1:1984"
2023/12/01 17:40:30 [info] 92639#13489089: *46 [lua] request.lua:302: get_body(): attempt to read body from file: /Users/guohao/workspace/apisix/t/servroot/client_body_temp/0000000001, client: 127.0.0.1, server: localhost, request: "POST /auth HTTP/1.1", host: "127.0.0.1:1984"
2023/12/01 17:40:30 [warn] 92639#13489089: *42 [lua] plugin.lua:1159: run_plugin(): forward-auth exits with http status code 400, client: 127.0.0.1, server: localhost, request: "POST /large-body HTTP/1.1", host: "127.0.0.1:1984"
2023/12/01 17:40:30 [warn] 92639#13489089: *3 using uninitialized "upstream_scheme" variable while logging request, client: 127.0.0.1, server: localhost, request: "GET /t HTTP/1.1", host: "localhost"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "Gallardot (via GitHub)" <gi...@apache.org>.
Gallardot commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1403965876
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
```lua
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if not err then
params.body = client_body_reader
else
params.body = core.request.get_body()
end
end
```
A minor optimization
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1829043637
@monkeyDluffy6017 yes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1828945717
@shreemaan-abhishek is this pr ready?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1409069915
##########
t/plugin/forward-auth.t:
##########
@@ -374,3 +403,34 @@ GET /hello
--- more_headers
Authorization: 111
--- error_code: 200
+
+
+
+=== TEST 13: test large body
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin")
+ local http = require("resty.http")
+ local httpc = http.new()
+
+ local large_body = t.read_file("t/plugin/forward-auth/fw-auth-large-file.bin")
+ local uri = "http://127.0.0.1:" .. ngx.var.server_port
+ .. "/large-body"
+ local res, err = httpc:request_uri(uri,
+ {
+ method = ngx.HTTP_POST,
+ body = large_body,
+ headers = {
+ Authorization = "large-body"
+ }
+ }
+ )
+
+ if not res then
+ ngx.log(ngx.ERR, err)
+ return
+ end
+ }
+ }
+--- error_code: 200
Review Comment:
Could you test the `response body` or the `response header` too?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1410030305
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
if we go this way other test cases would need to be updated. This might result in a breaking change for users 🤔
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
if we go this way other test cases would need to be updated. This might result in a breaking change for users 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1786719831
THis is recreation of this PR https://github.com/apache/apisix/pull/10377/files trying to solve https://github.com/apache/apisix/issues/10375
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1408870690
##########
t/plugin/forward-auth/fw-auth-large-file.bin:
##########
Review Comment:
It's too big for the project, could you create the file by code when run test cases?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1838128969
It's fixed by https://github.com/apache/apisix/pull/10589
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1401450509
##########
apisix/plugins/forward-auth.lua:
##########
@@ -117,7 +117,8 @@ function _M.access(conf, ctx)
local httpc = http.new()
httpc:set_timeout(conf.timeout)
-
+ local client_body_reader, err = httpc:get_client_body_reader()
+ params.body=client_body_reader
Review Comment:
@Gallardot `conf.timeout` or other conf parameters do not fix this issue and the root cause seems mysterious; I haven't been able to find it out.
> Additionally, if this is a GET request, this approach may not be appropriate.
Not a big deal, a condition check can be used. That said, there should be a better way to address this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "lplcc (via GitHub)" <gi...@apache.org>.
lplcc commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1401595692
##########
apisix/plugins/forward-auth.lua:
##########
@@ -117,7 +117,8 @@ function _M.access(conf, ctx)
local httpc = http.new()
httpc:set_timeout(conf.timeout)
-
+ local client_body_reader, err = httpc:get_client_body_reader()
+ params.body=client_body_reader
Review Comment:
Determine the request method or request body size, but this threshold is not easy to determine
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix:Solve the 403 problem caused by the post request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on PR #10425:
URL: https://github.com/apache/apisix/pull/10425#issuecomment-1818379995
Please make the ci pass
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1409012266
##########
apisix/plugins/forward-auth.lua:
##########
@@ -106,16 +106,20 @@ function _M.access(conf, ctx)
method = conf.request_method
}
+ local httpc = http.new()
if params.method == "POST" then
params.body = core.request.get_body()
+ local client_body_reader, err = httpc:get_client_body_reader()
+ if not err then
+ params.body = client_body_reader
+ end
Review Comment:
I agree with @Gallardot, it's ok to use `core.request.get_body()` if the `content-length` is missing, the client should ensure the input is correct.
But we should not check the `err` value of `local client_body_reader, err = httpc:get_client_body_reader()`, because the `err` will be `nil` if the `content-length` is missing. https://github.com/ledgetech/lua-resty-http/blob/master/lib/resty/http.lua#L999
```
local httpc = http.new()
if params.method == "POST" then
local client_body_reader, err = httpc:get_client_body_reader()
if client_body_reader then
params.body = client_body_reader
else
params.body = core.request.get_body()
end
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: forward-auth request body is too large [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1410842974
##########
t/plugin/forward-auth/fw-auth-large-file.bin:
##########
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org