diff --git a/proxy/src/auth/backend/console.rs b/proxy/src/auth/backend/console.rs index 098233c648..3085f0b0e4 100644 --- a/proxy/src/auth/backend/console.rs +++ b/proxy/src/auth/backend/console.rs @@ -49,6 +49,12 @@ impl UserFacingError for ConsoleAuthError { } } +impl From<&auth::credentials::ClientCredsParseError> for ConsoleAuthError { + fn from(e: &auth::credentials::ClientCredsParseError) -> Self { + ConsoleAuthError::BadProjectName(e.clone()) + } +} + // TODO: convert into an enum with "error" #[derive(Serialize, Deserialize, Debug)] struct GetRoleSecretResponse { @@ -92,14 +98,9 @@ impl<'a> Api<'a> { async fn get_auth_info(&self) -> Result { let mut url = self.endpoint.clone(); - let project_name = self - .creds - .project_name - .as_ref() - .map_err(|e| ConsoleAuthError::BadProjectName(e.clone()))?; url.path_segments_mut().push("proxy_get_role_secret"); url.query_pairs_mut() - .append_pair("project", project_name) + .append_pair("project", self.creds.project_name.as_ref()?) .append_pair("role", &self.creds.user); // TODO: use a proper logger @@ -121,12 +122,8 @@ impl<'a> Api<'a> { /// Wake up the compute node and return the corresponding connection info. async fn wake_compute(&self) -> Result { let mut url = self.endpoint.clone(); - let project_name = self - .creds - .project_name - .as_ref() - .map_err(|e| ConsoleAuthError::BadProjectName(e.clone()))?; url.path_segments_mut().push("proxy_wake_compute"); + let project_name = self.creds.project_name.as_ref()?; url.query_pairs_mut().append_pair("project", project_name); // TODO: use a proper logger