use crate::config::AppConfig;
pub const AUTH_METHOD_CONNECTION_STRING: &str = "connection_string";
pub const AUTH_METHOD_DEVICE_CODE: &str = "device_code";
pub const AUTH_METHOD_CLIENT_SECRET: &str = "client_secret";
pub struct AuthUtils;
impl AuthUtils {
pub fn is_connection_string_auth(config: &AppConfig) -> bool {
config.azure_ad().auth_method == AUTH_METHOD_CONNECTION_STRING
}
pub fn is_device_code_auth(config: &AppConfig) -> bool {
config.azure_ad().auth_method == AUTH_METHOD_DEVICE_CODE
}
pub fn is_client_secret_auth(config: &AppConfig) -> bool {
config.azure_ad().auth_method == AUTH_METHOD_CLIENT_SECRET
}
pub fn requires_azure_ad(config: &AppConfig) -> bool {
!Self::is_connection_string_auth(config)
}
pub fn supports_discovery(config: &AppConfig) -> bool {
Self::requires_azure_ad(config)
}
pub fn auth_method_description(config: &AppConfig) -> &'static str {
match config.azure_ad().auth_method.as_str() {
AUTH_METHOD_CONNECTION_STRING => "Connection String Authentication",
AUTH_METHOD_DEVICE_CODE => "Azure AD Device Code Flow",
AUTH_METHOD_CLIENT_SECRET => "Azure AD Client Secret Flow",
_ => "Unknown Authentication Method",
}
}
}