From c54d5e06e636f0a5e9631cc1563fd2ec26fc9946 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 13 Aug 2024 15:37:27 +0200 Subject: [PATCH] client: change Token struct API tokens between rust & perl code bases are inconsistent... this needs fixing, but for now this is faster and more compatible. Signed-off-by: Wolfgang Bumiller --- proxmox-client/src/auth.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxmox-client/src/auth.rs b/proxmox-client/src/auth.rs index da0386b7..b6698be7 100644 --- a/proxmox-client/src/auth.rs +++ b/proxmox-client/src/auth.rs @@ -31,13 +31,19 @@ pub struct Token { /// The api token's value. pub value: String, + + /// The separator for userid & value, due to inconsistencies between perl and rust based + /// products. + /// FIXME: Make one of them work for both types of products and remove this! + pub perl_compat: bool, } impl Token { pub fn set_auth_headers(&self, request: http::request::Builder) -> http::request::Builder { + let delim = if self.perl_compat { '=' } else { ':' }; request.header( http::header::AUTHORIZATION, - format!("{}={}={}", self.prefix, self.userid, self.value), + format!("{}={}{delim}{}", self.prefix, self.userid, self.value), ) } }