forked from proxmox-mirrors/proxmox
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 <w.bumiller@proxmox.com>
This commit is contained in:
parent
9923f29622
commit
c54d5e06e6
@ -31,13 +31,19 @@ pub struct Token {
|
|||||||
|
|
||||||
/// The api token's value.
|
/// The api token's value.
|
||||||
pub value: String,
|
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 {
|
impl Token {
|
||||||
pub fn set_auth_headers(&self, request: http::request::Builder) -> http::request::Builder {
|
pub fn set_auth_headers(&self, request: http::request::Builder) -> http::request::Builder {
|
||||||
|
let delim = if self.perl_compat { '=' } else { ':' };
|
||||||
request.header(
|
request.header(
|
||||||
http::header::AUTHORIZATION,
|
http::header::AUTHORIZATION,
|
||||||
format!("{}={}={}", self.prefix, self.userid, self.value),
|
format!("{}={}{delim}{}", self.prefix, self.userid, self.value),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user