From d589de63ef345707814e4fb1222369cb22edfde3 Mon Sep 17 00:00:00 2001 From: shuiyisong <113876041+shuiyisong@users.noreply.github.com> Date: Tue, 27 Dec 2022 11:04:05 +0800 Subject: [PATCH] feat: pub `auth_mysql` & add auth boxed err (#788) * chore: minor openup * chore: open up auth_mysql and return () * chore: typo change * chore: change according to ci * chore: change according to ci * chore: remove tonic status in auth error --- src/servers/src/auth.rs | 30 ++++++++++++++++----------- src/servers/src/auth/user_provider.rs | 30 +++++++++++++-------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/servers/src/auth.rs b/src/servers/src/auth.rs index f787c3fed9..7ab9994f7c 100644 --- a/src/servers/src/auth.rs +++ b/src/servers/src/auth.rs @@ -18,6 +18,7 @@ pub const DEFAULT_USERNAME: &str = "greptime"; use std::sync::Arc; +use common_error::ext::BoxedError; use common_error::prelude::ErrorExt; use common_error::status_code::StatusCode; use snafu::{Backtrace, ErrorCompat, OptionExt, Snafu}; @@ -28,7 +29,7 @@ use crate::auth::user_provider::StaticUserProvider; pub trait UserProvider: Send + Sync { fn name(&self) -> &str; - async fn auth(&self, id: Identity<'_>, password: Password<'_>) -> Result; + async fn auth(&self, id: Identity<'_>, password: Password<'_>) -> Result; } pub type UserProviderRef = Arc; @@ -76,7 +77,7 @@ impl UserInfo { } } -pub fn user_provider_from_option(opt: &String) -> Result { +pub fn user_provider_from_option(opt: &String) -> Result { let (name, content) = opt.split_once(':').context(InvalidConfigSnafu { value: opt.to_string(), msg: "UserProviderOption must be in format `