proxmox-rest-server: make check_auth async
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
//! Provides authentication primitives for the HTTP server
|
||||
use anyhow::format_err;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
use anyhow::format_err;
|
||||
|
||||
use proxmox::api::UserInformation;
|
||||
|
||||
@ -55,16 +58,15 @@ impl UserApiAuth {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiAuth for UserApiAuth {
|
||||
|
||||
fn check_auth(
|
||||
async fn check_auth_async(
|
||||
&self,
|
||||
headers: &http::HeaderMap,
|
||||
method: &hyper::Method,
|
||||
) -> Result<(String, Box<dyn UserInformation + Sync + Send>), AuthError> {
|
||||
|
||||
// fixme: make all IO async
|
||||
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
let auth_data = Self::extract_auth_data(headers);
|
||||
@ -124,3 +126,13 @@ impl ApiAuth for UserApiAuth {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiAuth for UserApiAuth {
|
||||
fn check_auth<'a>(
|
||||
&'a self,
|
||||
headers: &'a http::HeaderMap,
|
||||
method: &'a hyper::Method,
|
||||
) -> Pin<Box<dyn Future<Output = Result<(String, Box<dyn UserInformation + Sync + Send>), AuthError>> + Send + 'a>> {
|
||||
Box::pin(self.check_auth_async(headers, method))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user