From baeb17826db95bee532dee5ea9b8e0f1a5cf7a33 Mon Sep 17 00:00:00 2001 From: David Mulder Date: Tue, 14 May 2024 12:49:18 -0600 Subject: [PATCH 1/2] Add check_user_exists This validates whether a Azure Entra ID user exists. Signed-off-by: David Mulder --- src/auth.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/auth.rs b/src/auth.rs index 36f1f57..ca79e6c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1133,6 +1133,26 @@ impl PublicClientApplication { } } + /// Check if a user exists in Azure Entra ID + /// + /// # Arguments + /// + /// * `username` - Typically a UPN in the form of an email address. + /// + /// # Returns + /// * Success: true|false + /// * Failure: An MsalError, indicating the failure. + pub async fn check_user_exists(&self, username: &str) -> Result { + let request_id = Uuid::new_v4().to_string(); + let auth_config = self + .request_auth_config_internal(vec![], &request_id, None) + .await?; + let cred_type = self + .get_cred_type(username, &auth_config, &request_id) + .await?; + Ok(cred_type.if_exists_result == 0) + } + /// Initiate an MFA flow via user credentials. /// /// # Arguments @@ -2318,6 +2338,19 @@ impl BrokerClientApplication { self.app.acquire_token_by_device_flow(flow).await } + /// Check if a user exists in Azure Entra ID + /// + /// # Arguments + /// + /// * `username` - Typically a UPN in the form of an email address. + /// + /// # Returns + /// * Success: true|false + /// * Failure: An MsalError, indicating the failure. + pub async fn check_user_exists(&self, username: &str) -> Result { + self.app.check_user_exists(username).await + } + /// Initiate an MFA flow for enrollment via user credentials. /// /// # Arguments From d3a70d7ba2f17293bb97fe97b786edf04e32d641 Mon Sep 17 00:00:00 2001 From: David Mulder Date: Tue, 14 May 2024 12:50:05 -0600 Subject: [PATCH 2/2] Version 0.1.23 Signed-off-by: David Mulder --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 422e84f..6b2b3ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "msal" description = "Microsoft Authentication Library for Rust" -version = "0.1.22" +version = "0.1.23" edition = "2021" authors = [ "David Mulder "