diff --git a/src/auth/src/common.rs b/src/auth/src/common.rs index 16e1ecec2b4c..109a98175d4c 100644 --- a/src/auth/src/common.rs +++ b/src/auth/src/common.rs @@ -40,7 +40,7 @@ pub fn user_provider_from_option(opt: &String) -> Result { match name { STATIC_USER_PROVIDER => { let provider = - StaticUserProvider::try_from(content).map(|p| Arc::new(p) as UserProviderRef)?; + StaticUserProvider::new(content).map(|p| Arc::new(p) as UserProviderRef)?; Ok(provider) } _ => InvalidConfigSnafu { diff --git a/src/auth/src/user_provider/static_user_provider.rs b/src/auth/src/user_provider/static_user_provider.rs index 591a116b9281..e6d474389431 100644 --- a/src/auth/src/user_provider/static_user_provider.rs +++ b/src/auth/src/user_provider/static_user_provider.rs @@ -23,7 +23,7 @@ use secrecy::ExposeSecret; use snafu::{ensure, OptionExt, ResultExt}; use crate::error::{ - Error, IllegalParamSnafu, InvalidConfigSnafu, IoSnafu, Result, UnsupportedPasswordTypeSnafu, + IllegalParamSnafu, InvalidConfigSnafu, IoSnafu, Result, UnsupportedPasswordTypeSnafu, UserNotFoundSnafu, UserPasswordMismatchSnafu, }; use crate::user_info::DefaultUserInfo; @@ -31,10 +31,12 @@ use crate::{auth_mysql, Identity, Password, UserInfoRef, UserProvider}; pub(crate) const STATIC_USER_PROVIDER: &str = "static_user_provider"; -impl TryFrom<&str> for StaticUserProvider { - type Error = Error; +pub(crate) struct StaticUserProvider { + users: HashMap>, +} - fn try_from(value: &str) -> Result { +impl StaticUserProvider { + pub(crate) fn new(value: &str) -> Result { let (mode, content) = value.split_once(':').context(InvalidConfigSnafu { value: value.to_string(), msg: "StaticUserProviderOption must be in format `