Box::pin authenticate function
This commit is contained in:
@@ -38,8 +38,7 @@ pub struct Username {
|
||||
|
||||
impl Server {
|
||||
pub async fn authenticate(&self, req: &AuthRequest) -> trc::Result<AccessToken> {
|
||||
match self
|
||||
.route_auth_request(req)
|
||||
match Box::pin(self.route_auth_request(req))
|
||||
.await
|
||||
.and_then(|token| token.assert_has_permission(Permission::Authenticate))
|
||||
{
|
||||
|
||||
@@ -430,7 +430,7 @@ impl Http {
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "dev_mode", feature = "test_mode"))]
|
||||
let server_name = "127.0.0.1:8080";
|
||||
let server_name = "127.0.0.1";
|
||||
|
||||
Http {
|
||||
url_https: if !bp.registry.is_recovery_mode() {
|
||||
|
||||
@@ -82,12 +82,13 @@ impl Authenticator for Server {
|
||||
};
|
||||
|
||||
// Authenticate
|
||||
let access_token = Box::pin(self.authenticate(&AuthRequest::from_credentials(
|
||||
credentials,
|
||||
session.session_id,
|
||||
session.remote_ip,
|
||||
)))
|
||||
.await?;
|
||||
let access_token = self
|
||||
.authenticate(&AuthRequest::from_credentials(
|
||||
credentials,
|
||||
session.session_id,
|
||||
session.remote_ip,
|
||||
))
|
||||
.await?;
|
||||
|
||||
// Cache credentials
|
||||
self.inner.cache.http_auth.insert(
|
||||
|
||||
@@ -49,7 +49,7 @@ impl ClientRegistrationHandler for Server {
|
||||
) -> trc::Result<HttpResponse> {
|
||||
let tenant_id = if !self.core.oauth.allow_anonymous_client_registration {
|
||||
// Authenticate request
|
||||
let (_, access_token) = Box::pin(self.authenticate_headers(req, &session)).await?;
|
||||
let (_, access_token) = self.authenticate_headers(req, &session).await?;
|
||||
|
||||
// Validate permissions
|
||||
access_token.enforce_permission(Permission::OAuthClientRegistration)?;
|
||||
|
||||
@@ -47,7 +47,7 @@ impl<T: SessionStream> Session<T> {
|
||||
.id(args.tag.clone())
|
||||
})?;
|
||||
|
||||
Box::pin(self.authenticate(credentials, args.tag)).await
|
||||
self.authenticate(credentials, args.tag).await
|
||||
} else {
|
||||
self.receiver.request = receiver::Request {
|
||||
tag: args.tag,
|
||||
|
||||
@@ -13,14 +13,14 @@ impl<T: SessionStream> Session<T> {
|
||||
pub async fn handle_login(&mut self, request: Request<Command>) -> trc::Result<()> {
|
||||
let arguments = request.parse_login()?;
|
||||
|
||||
Box::pin(self.authenticate(
|
||||
self.authenticate(
|
||||
Credentials::Basic {
|
||||
username: arguments.username.to_string(),
|
||||
secret: arguments.password.to_string(),
|
||||
mfa_token: None,
|
||||
},
|
||||
arguments.tag,
|
||||
))
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ impl<T: SessionStream> Session<T> {
|
||||
match (token.mechanism, &mut token.credentials) {
|
||||
(AUTH_PLAIN, _) => {
|
||||
if let Some(credentials) = Credentials::decode_sasl_challenge_plain(&response) {
|
||||
return Box::pin(self.authenticate(credentials)).await;
|
||||
return self.authenticate(credentials).await;
|
||||
}
|
||||
}
|
||||
(
|
||||
@@ -84,20 +84,20 @@ impl<T: SessionStream> Session<T> {
|
||||
Ok(true)
|
||||
} else {
|
||||
*secret = response.into_string();
|
||||
Box::pin(self.authenticate(std::mem::replace(
|
||||
self.authenticate(std::mem::replace(
|
||||
&mut token.credentials,
|
||||
Credentials::Basic {
|
||||
username: String::new(),
|
||||
secret: String::new(),
|
||||
mfa_token: None,
|
||||
},
|
||||
)))
|
||||
))
|
||||
.await
|
||||
};
|
||||
}
|
||||
(AUTH_OAUTHBEARER | AUTH_XOAUTH2, _) => {
|
||||
if let Some(credentials) = Credentials::decode_sasl_challenge_oauth(&response) {
|
||||
return Box::pin(self.authenticate(credentials)).await;
|
||||
return self.authenticate(credentials).await;
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
|
||||
Reference in New Issue
Block a user