* Re: [pve-devel] [PATCH proxmox-openid-rs] fix Open ID with Azure as provider
@ 2022-04-01 4:21 Dietmar Maurer
2022-04-01 8:57 ` Mira Limbeck
0 siblings, 1 reply; 3+ messages in thread
From: Dietmar Maurer @ 2022-04-01 4:21 UTC (permalink / raw)
To: Proxmox VE development discussion, Mira Limbeck
> let response = if let Method::POST = request.method {
> - req.send(&*request.body)
> + let bytes = request.body.as_slice();
> + req.send_bytes(bytes)
Does this have the side effect of changing the transfer encoding? If so, it is worth to add an inline comment.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH proxmox-openid-rs] fix Open ID with Azure as provider
2022-04-01 4:21 [pve-devel] [PATCH proxmox-openid-rs] fix Open ID with Azure as provider Dietmar Maurer
@ 2022-04-01 8:57 ` Mira Limbeck
0 siblings, 0 replies; 3+ messages in thread
From: Mira Limbeck @ 2022-04-01 8:57 UTC (permalink / raw)
To: Dietmar Maurer, Proxmox VE development discussion
On 4/1/22 06:21, Dietmar Maurer wrote:
>> let response = if let Method::POST = request.method {
>> - req.send(&*request.body)
>> + let bytes = request.body.as_slice();
>> + req.send_bytes(bytes)
> Does this have the side effect of changing the transfer encoding? If so, it is worth to add an inline comment.
This makes sure that `Transfer-Encoding` is not set at all, but instead
`Content-Length` is set.
AFAIK either one of those is required, but not both at the same time.
And some endpoints don't seem to accept `Transfer-Encoding: chunked`.
I'll add an inline comment mentioning that, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH proxmox-openid-rs] fix Open ID with Azure as provider
@ 2022-03-31 13:33 Mira Limbeck
0 siblings, 0 replies; 3+ messages in thread
From: Mira Limbeck @ 2022-03-31 13:33 UTC (permalink / raw)
To: pve-devel
Azure doesn't accept `Transfer-Encoding: chunked` on their token endpoint,
but with the switch to ureq we always send requests with this set.
Fix by switching to `Content-Length` in the header instead. ureq only
sets `Transfer-Encoding: chunked` when the body length is not known
beforehand, which is the case when using `send`. See
https://github.com/algesten/ureq/blob/main/README.md#content-length-and-transfer-encoding
See https://forum.proxmox.com/threads/openid-401-with-azure-ad.105892/
for the issue.
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
---
probably also fixes https://bugzilla.proxmox.com/show_bug.cgi?id=3916,
but I could only reproduce this exact error message with Azure until
now.
src/http_client.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/http_client.rs b/src/http_client.rs
index a2bf6ee..7e63275 100644
--- a/src/http_client.rs
+++ b/src/http_client.rs
@@ -75,7 +75,8 @@ pub fn http_client(request: HttpRequest) -> Result<HttpResponse, Error> {
}
let response = if let Method::POST = request.method {
- req.send(&*request.body)
+ let bytes = request.body.as_slice();
+ req.send_bytes(bytes)
} else {
req.call()
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-01 9:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 4:21 [pve-devel] [PATCH proxmox-openid-rs] fix Open ID with Azure as provider Dietmar Maurer
2022-04-01 8:57 ` Mira Limbeck
-- strict thread matches above, loose matches on Subject: below --
2022-03-31 13:33 Mira Limbeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox