diff --git a/Cargo.lock b/Cargo.lock index 48f8b3fc9223..7e33035ee0ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1587,6 +1587,23 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "common-users" +version = "0.1.0" +dependencies = [ + "common-base", + "common-exception", + "common-grpc", + "common-management", + "common-meta-api", + "common-meta-store", + "common-meta-types", + "common-tracing", + "jwtk", + "pretty_assertions", + "serde", +] + [[package]] name = "concurrent-queue" version = "1.2.2" @@ -2136,6 +2153,7 @@ dependencies = [ "common-planners", "common-streams", "common-tracing", + "common-users", "criterion", "dyn-clone", "enum_dispatch", @@ -2148,7 +2166,6 @@ dependencies = [ "http", "itertools", "jwt-simple", - "jwtk", "lz4", "maplit", "metrics", diff --git a/Cargo.toml b/Cargo.toml index 56c1a9fb5726..96ca9125f546 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ members = [ "common/meta/app", "common/streams", "common/tracing", + "common/users", # Query "query", diff --git a/common/users/Cargo.toml b/common/users/Cargo.toml new file mode 100644 index 000000000000..2abbb611c45b --- /dev/null +++ b/common/users/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "common-users" +version = "0.1.0" +authors = ["Databend Authors "] +license = "Apache-2.0" +publish = false +edition = "2021" + +[lib] +doctest = false +test = false + +[dependencies] # In alphabetical order +# Workspace dependencies +common-base = { path = "../base" } +common-exception = { path = "../exception" } +common-grpc = { path = "../grpc" } +common-management = { path = "../management" } +common-meta-api = { path = "../meta/api" } +common-meta-store = { path = "../meta/store" } +common-meta-types = { path = "../meta/types" } +common-tracing = { path = "../tracing" } + +# Github dependencies + +# Crates.io dependencies +jwtk = "0.2.3" +serde = { version = "1.0.137", features = ["derive"] } + +[dev-dependencies] +pretty_assertions = "1.2.1" diff --git a/query/src/users/auth/jwt/authenticator.rs b/common/users/src/jwt/authenticator.rs similarity index 90% rename from query/src/users/auth/jwt/authenticator.rs rename to common/users/src/jwt/authenticator.rs index 985c6562af8e..db70fd941f08 100644 --- a/query/src/users/auth/jwt/authenticator.rs +++ b/common/users/src/jwt/authenticator.rs @@ -21,8 +21,6 @@ use jwtk::HeaderAndClaims; use serde::Deserialize; use serde::Serialize; -use crate::Config; - pub struct JwtAuthenticator { //Todo(youngsofun): verify settings, like issuer verifier: RemoteJwksVerifier, @@ -59,12 +57,12 @@ impl CustomClaims { } impl JwtAuthenticator { - pub async fn try_create(cfg: Config) -> Result> { - if cfg.query.jwt_key_file.is_empty() { + pub async fn try_create(jwt_key_file: String) -> Result> { + if jwt_key_file.is_empty() { return Ok(None); } let mut verifier = - RemoteJwksVerifier::new(cfg.query.jwt_key_file, None, Duration::from_secs(15 * 60)); + RemoteJwksVerifier::new(jwt_key_file, None, Duration::from_secs(15 * 60)); verifier.set_require_kid(false); Ok(Some(JwtAuthenticator { verifier })) } diff --git a/query/src/users/auth/jwt/mod.rs b/common/users/src/jwt/mod.rs similarity index 100% rename from query/src/users/auth/jwt/mod.rs rename to common/users/src/jwt/mod.rs diff --git a/query/src/users/mod.rs b/common/users/src/lib.rs similarity index 90% rename from query/src/users/mod.rs rename to common/users/src/lib.rs index fd76dcb1f2e0..8463c5f56163 100644 --- a/query/src/users/mod.rs +++ b/common/users/src/lib.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +mod jwt; mod role_mgr; mod user; mod user_api; @@ -19,11 +20,9 @@ mod user_mgr; mod user_stage; mod user_udf; -pub mod auth; pub mod role_cache_mgr; -pub use auth::auth_mgr::AuthMgr; -pub use auth::auth_mgr::Credential; +pub use jwt::*; pub use role_cache_mgr::RoleCacheMgr; pub use user::CertifiedInfo; pub use user::User; diff --git a/query/src/users/role_cache_mgr.rs b/common/users/src/role_cache_mgr.rs similarity index 99% rename from query/src/users/role_cache_mgr.rs rename to common/users/src/role_cache_mgr.rs index ecdddfe54a12..a5111587d47a 100644 --- a/query/src/users/role_cache_mgr.rs +++ b/common/users/src/role_cache_mgr.rs @@ -26,7 +26,7 @@ use common_exception::Result; use common_meta_types::RoleInfo; use common_tracing::tracing; -use crate::users::UserApiProvider; +use crate::UserApiProvider; struct CachedRoles { roles: HashMap, diff --git a/query/src/users/role_mgr.rs b/common/users/src/role_mgr.rs similarity index 99% rename from query/src/users/role_mgr.rs rename to common/users/src/role_mgr.rs index 55bbb3761f7f..ab335f26d992 100644 --- a/query/src/users/role_mgr.rs +++ b/common/users/src/role_mgr.rs @@ -18,7 +18,7 @@ use common_meta_types::GrantObject; use common_meta_types::RoleInfo; use common_meta_types::UserPrivilegeSet; -use crate::users::UserApiProvider; +use crate::UserApiProvider; impl UserApiProvider { // Get one role from by tenant. diff --git a/query/src/users/user.rs b/common/users/src/user.rs similarity index 100% rename from query/src/users/user.rs rename to common/users/src/user.rs diff --git a/query/src/users/user_api.rs b/common/users/src/user_api.rs similarity index 89% rename from query/src/users/user_api.rs rename to common/users/src/user_api.rs index 8b034706e9f4..87fd69fefecc 100644 --- a/query/src/users/user_api.rs +++ b/common/users/src/user_api.rs @@ -15,6 +15,7 @@ use std::sync::Arc; use common_exception::Result; +use common_grpc::RpcClientConf; use common_management::QuotaApi; use common_management::QuotaMgr; use common_management::RoleApi; @@ -28,17 +29,13 @@ use common_management::UserMgr; use common_meta_api::KVApi; use common_meta_store::MetaStoreProvider; -use crate::Config; - pub struct UserApiProvider { client: Arc, } impl UserApiProvider { - pub async fn create_global(conf: Config) -> Result> { - let client = MetaStoreProvider::new(conf.meta.to_meta_grpc_client_conf()) - .try_get_meta_store() - .await?; + pub async fn create_global(conf: RpcClientConf) -> Result> { + let client = MetaStoreProvider::new(conf).try_get_meta_store().await?; Ok(Arc::new(UserApiProvider { client: client.arc(), })) diff --git a/query/src/users/user_mgr.rs b/common/users/src/user_mgr.rs similarity index 99% rename from query/src/users/user_mgr.rs rename to common/users/src/user_mgr.rs index a11fd041c1db..c631962ceead 100644 --- a/query/src/users/user_mgr.rs +++ b/common/users/src/user_mgr.rs @@ -21,7 +21,7 @@ use common_meta_types::UserInfo; use common_meta_types::UserOption; use common_meta_types::UserPrivilegeSet; -use crate::users::UserApiProvider; +use crate::UserApiProvider; impl UserApiProvider { // Get one user from by tenant. diff --git a/query/src/users/user_stage.rs b/common/users/src/user_stage.rs similarity index 99% rename from query/src/users/user_stage.rs rename to common/users/src/user_stage.rs index de7deba071d1..6925302568d8 100644 --- a/query/src/users/user_stage.rs +++ b/common/users/src/user_stage.rs @@ -17,7 +17,7 @@ use common_exception::Result; use common_meta_types::StageFile; use common_meta_types::UserStageInfo; -use crate::users::UserApiProvider; +use crate::UserApiProvider; /// user stage operations. impl UserApiProvider { diff --git a/query/src/users/user_udf.rs b/common/users/src/user_udf.rs similarity index 98% rename from query/src/users/user_udf.rs rename to common/users/src/user_udf.rs index 7969d0f0cd8e..5cd4947c414a 100644 --- a/query/src/users/user_udf.rs +++ b/common/users/src/user_udf.rs @@ -16,7 +16,7 @@ use common_exception::ErrorCode; use common_exception::Result; use common_meta_types::UserDefinedFunction; -use crate::users::UserApiProvider; +use crate::UserApiProvider; /// UDF operations. impl UserApiProvider { diff --git a/query/tests/it/users/auth/mod.rs b/common/users/tests/it/main.rs similarity index 85% rename from query/tests/it/users/auth/mod.rs rename to common/users/tests/it/main.rs index fb551e3432f5..c073ed1b396c 100644 --- a/query/tests/it/users/auth/mod.rs +++ b/common/users/tests/it/main.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Datafuse Labs. +// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,4 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -mod auth_mgr; +mod role_cache_mgr; +mod role_mgr; +mod user_mgr; +mod user_udf; diff --git a/query/tests/it/users/mod.rs b/common/users/tests/it/mod.rs similarity index 100% rename from query/tests/it/users/mod.rs rename to common/users/tests/it/mod.rs diff --git a/query/tests/it/users/role_cache_mgr.rs b/common/users/tests/it/role_cache_mgr.rs similarity index 91% rename from query/tests/it/users/role_cache_mgr.rs rename to common/users/tests/it/role_cache_mgr.rs index 0d79e30ed80f..403140bfa557 100644 --- a/query/tests/it/users/role_cache_mgr.rs +++ b/common/users/tests/it/role_cache_mgr.rs @@ -17,17 +17,19 @@ use std::collections::HashSet; use common_base::base::tokio; use common_exception::Result; +use common_grpc::RpcClientConf; use common_meta_types::GrantObject; use common_meta_types::RoleInfo; use common_meta_types::UserPrivilegeSet; -use databend_query::catalogs::CATALOG_DEFAULT; -use databend_query::users::role_cache_mgr::find_all_related_roles; -use databend_query::users::RoleCacheMgr; -use databend_query::users::UserApiProvider; +use common_users::role_cache_mgr::find_all_related_roles; +use common_users::RoleCacheMgr; +use common_users::UserApiProvider; + +pub const CATALOG_DEFAULT: &str = "default"; #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_role_cache_mgr() -> Result<()> { - let conf = crate::tests::ConfigBuilder::create().config(); + let conf = RpcClientConf::default(); let user_api = UserApiProvider::create_global(conf).await?; let mut role1 = RoleInfo::new("role1"); diff --git a/query/tests/it/users/role_mgr.rs b/common/users/tests/it/role_mgr.rs similarity index 96% rename from query/tests/it/users/role_mgr.rs rename to common/users/tests/it/role_mgr.rs index c133b6676a5a..db01cdf57e7b 100644 --- a/query/tests/it/users/role_mgr.rs +++ b/common/users/tests/it/role_mgr.rs @@ -15,16 +15,17 @@ use common_base::base::tokio; use common_exception::ErrorCode; use common_exception::Result; +use common_grpc::RpcClientConf; use common_meta_types::GrantObject; use common_meta_types::RoleInfo; use common_meta_types::UserPrivilegeSet; use common_meta_types::UserPrivilegeType; -use databend_query::users::UserApiProvider; +use common_users::UserApiProvider; use pretty_assertions::assert_eq; #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_role_manager() -> Result<()> { - let conf = crate::tests::ConfigBuilder::create().config(); + let conf = RpcClientConf::default(); let tenant = "tenant1"; let role_name = "test-role1".to_string(); diff --git a/query/tests/it/users/user_mgr.rs b/common/users/tests/it/user_mgr.rs similarity index 98% rename from query/tests/it/users/user_mgr.rs rename to common/users/tests/it/user_mgr.rs index f41ca814a980..40a0653add7b 100644 --- a/query/tests/it/users/user_mgr.rs +++ b/common/users/tests/it/user_mgr.rs @@ -15,6 +15,7 @@ use common_base::base::tokio; use common_exception::ErrorCode; use common_exception::Result; +use common_grpc::RpcClientConf; use common_meta_types::AuthInfo; use common_meta_types::GrantObject; use common_meta_types::PasswordHashMethod; @@ -23,13 +24,13 @@ use common_meta_types::UserIdentity; use common_meta_types::UserInfo; use common_meta_types::UserPrivilegeSet; use common_meta_types::UserPrivilegeType; -use databend_query::users::User; -use databend_query::users::UserApiProvider; +use common_users::User; +use common_users::UserApiProvider; use pretty_assertions::assert_eq; #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_user_manager() -> Result<()> { - let conf = crate::tests::ConfigBuilder::create().config(); + let conf = RpcClientConf::default(); let tenant = "test"; let username = "test-user1"; @@ -241,7 +242,7 @@ async fn test_user_manager() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_user_manager_with_root_user() -> Result<()> { - let conf = crate::tests::ConfigBuilder::create().config(); + let conf = RpcClientConf::default(); let tenant = "test"; let username1 = "default"; diff --git a/query/tests/it/users/user_udf.rs b/common/users/tests/it/user_udf.rs similarity index 95% rename from query/tests/it/users/user_udf.rs rename to common/users/tests/it/user_udf.rs index b7d5be3559ee..5901fe009b47 100644 --- a/query/tests/it/users/user_udf.rs +++ b/common/users/tests/it/user_udf.rs @@ -14,13 +14,14 @@ use common_base::base::tokio; use common_exception::Result; +use common_grpc::RpcClientConf; use common_meta_types::UserDefinedFunction; -use databend_query::users::UserApiProvider; +use common_users::UserApiProvider; use pretty_assertions::assert_eq; #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_user_udf() -> Result<()> { - let conf = crate::tests::ConfigBuilder::create().config(); + let conf = RpcClientConf::default(); let tenant = "test"; let description = "this is a description"; diff --git a/query/Cargo.toml b/query/Cargo.toml index bcc054520e16..102f4658f34f 100644 --- a/query/Cargo.toml +++ b/query/Cargo.toml @@ -56,6 +56,7 @@ common-metrics = { path = "../common/metrics" } common-planners = { path = "../common/planners" } common-streams = { path = "../common/streams" } common-tracing = { path = "../common/tracing" } +common-users = { path = "../common/users" } # Github dependencies async-trait = { git = "https://github.com/datafuse-extras/async-trait", rev = "f0b0fd5" } @@ -86,7 +87,6 @@ futures-util = "0.3.21" headers = "0.3.7" http = "0.2.8" itertools = "0.10.3" -jwtk = "0.2.3" lz4 = "1.23.3" metrics = "0.19.0" naive-cityhash = "0.2.0" diff --git a/query/src/users/auth/auth_mgr.rs b/query/src/auth.rs similarity index 96% rename from query/src/users/auth/auth_mgr.rs rename to query/src/auth.rs index 05249c1f2068..6573d8e8d710 100644 --- a/query/src/users/auth/auth_mgr.rs +++ b/query/src/auth.rs @@ -18,10 +18,10 @@ use common_exception::ErrorCode; use common_exception::Result; use common_meta_types::AuthInfo; use common_meta_types::UserInfo; +use common_users::JwtAuthenticator; +use common_users::UserApiProvider; use crate::sessions::QueryContext; -use crate::users::auth::jwt::JwtAuthenticator; -use crate::users::UserApiProvider; pub use crate::Config; pub struct AuthMgr { @@ -45,7 +45,7 @@ impl AuthMgr { pub async fn create(cfg: Config, user_mgr: Arc) -> Result { Ok(AuthMgr { user_mgr, - jwt: JwtAuthenticator::try_create(cfg).await?, + jwt: JwtAuthenticator::try_create(cfg.query.jwt_key_file).await?, }) } diff --git a/query/src/lib.rs b/query/src/lib.rs index 5cfb3333358b..e114b06c8126 100644 --- a/query/src/lib.rs +++ b/query/src/lib.rs @@ -21,6 +21,7 @@ #![feature(box_patterns)] pub mod api; +pub mod auth; pub mod catalogs; pub mod clusters; pub mod common; @@ -35,7 +36,6 @@ pub mod sessions; pub mod sql; pub mod storages; pub mod table_functions; -pub mod users; mod config; mod version; diff --git a/query/src/servers/clickhouse/interactive_worker.rs b/query/src/servers/clickhouse/interactive_worker.rs index 9a9770cd9e82..da5e740fbb06 100644 --- a/query/src/servers/clickhouse/interactive_worker.rs +++ b/query/src/servers/clickhouse/interactive_worker.rs @@ -21,11 +21,11 @@ use opensrv_clickhouse::connection::Connection; use opensrv_clickhouse::CHContext; use opensrv_clickhouse::ClickHouseSession; +use crate::auth::Credential; use crate::servers::clickhouse::interactive_worker_base::InteractiveWorkerBase; use crate::servers::clickhouse::writers::to_clickhouse_err; use crate::servers::clickhouse::writers::QueryWriter; use crate::sessions::SessionRef; -use crate::users::auth::auth_mgr::Credential; pub struct InteractiveWorker { session: SessionRef, diff --git a/query/src/servers/http/middleware.rs b/query/src/servers/http/middleware.rs index c6a3380b3730..876855902d2c 100644 --- a/query/src/servers/http/middleware.rs +++ b/query/src/servers/http/middleware.rs @@ -30,10 +30,10 @@ use poem::Middleware; use poem::Request; use super::v1::HttpQueryContext; +use crate::auth::Credential; use crate::servers::HttpHandlerKind; use crate::sessions::SessionManager; use crate::sessions::SessionType; -use crate::users::auth::auth_mgr::Credential; pub struct HTTPSessionMiddleware { pub kind: HttpHandlerKind, diff --git a/query/src/servers/mysql/mysql_interactive_worker.rs b/query/src/servers/mysql/mysql_interactive_worker.rs index 43a8de864e7e..07af74d78546 100644 --- a/query/src/servers/mysql/mysql_interactive_worker.rs +++ b/query/src/servers/mysql/mysql_interactive_worker.rs @@ -24,6 +24,7 @@ use common_exception::ToErrorCode; use common_io::prelude::*; use common_tracing::tracing; use common_tracing::tracing::Instrument; +use common_users::CertifiedInfo; use metrics::histogram; use opensrv_mysql::AsyncMysqlShim; use opensrv_mysql::ErrorKind; @@ -47,7 +48,6 @@ use crate::sessions::SessionRef; use crate::sql::DfParser; use crate::sql::PlanParser; use crate::sql::Planner; -use crate::users::CertifiedInfo; struct InteractiveWorkerBase { session: SessionRef, diff --git a/query/src/sessions/query_ctx.rs b/query/src/sessions/query_ctx.rs index 356cbae91e75..8330b7aace75 100644 --- a/query/src/sessions/query_ctx.rs +++ b/query/src/sessions/query_ctx.rs @@ -49,10 +49,13 @@ use common_planners::Statistics; use common_streams::AbortStream; use common_streams::SendableDataBlockStream; use common_tracing::tracing; +use common_users::RoleCacheMgr; +use common_users::UserApiProvider; use futures::future::AbortHandle; use opendal::Operator; use crate::api::DataExchangeManager; +use crate::auth::AuthMgr; use crate::catalogs::Catalog; use crate::catalogs::CatalogManager; use crate::clusters::Cluster; @@ -65,9 +68,6 @@ use crate::sessions::Settings; use crate::storages::cache::CacheManager; use crate::storages::stage::StageTable; use crate::storages::Table; -use crate::users::auth::auth_mgr::AuthMgr; -use crate::users::RoleCacheMgr; -use crate::users::UserApiProvider; use crate::Config; #[derive(Clone)] diff --git a/query/src/sessions/query_ctx_shared.rs b/query/src/sessions/query_ctx_shared.rs index aff6286298a7..534de3705f14 100644 --- a/query/src/sessions/query_ctx_shared.rs +++ b/query/src/sessions/query_ctx_shared.rs @@ -30,9 +30,12 @@ use common_exception::Result; use common_io::prelude::FormatSettings; use common_meta_types::UserInfo; use common_planners::PlanNode; +use common_users::RoleCacheMgr; +use common_users::UserApiProvider; use futures::future::AbortHandle; use uuid::Uuid; +use crate::auth::AuthMgr; use crate::catalogs::CatalogManager; use crate::clusters::Cluster; use crate::servers::http::v1::HttpQueryHandle; @@ -41,9 +44,6 @@ use crate::sessions::SessionType; use crate::sessions::Settings; use crate::sql::SQLCommon; use crate::storages::Table; -use crate::users::auth::auth_mgr::AuthMgr; -use crate::users::RoleCacheMgr; -use crate::users::UserApiProvider; use crate::Config; type DatabaseAndTable = (String, String, String); diff --git a/query/src/sessions/session.rs b/query/src/sessions/session.rs index a189de3f9734..ca01004f1b96 100644 --- a/query/src/sessions/session.rs +++ b/query/src/sessions/session.rs @@ -24,6 +24,7 @@ use common_macros::MallocSizeOf; use common_meta_types::GrantObject; use common_meta_types::UserInfo; use common_meta_types::UserPrivilegeType; +use common_users::RoleCacheMgr; use futures::channel::*; use opendal::Operator; @@ -35,7 +36,6 @@ use crate::sessions::SessionManager; use crate::sessions::SessionStatus; use crate::sessions::SessionType; use crate::sessions::Settings; -use crate::users::RoleCacheMgr; use crate::Config; #[derive(MallocSizeOf)] diff --git a/query/src/sessions/session_mgr.rs b/query/src/sessions/session_mgr.rs index 574a8bece2d9..7bb3dfb841b1 100644 --- a/query/src/sessions/session_mgr.rs +++ b/query/src/sessions/session_mgr.rs @@ -32,6 +32,8 @@ use common_metrics::label_counter; use common_tracing::init_query_logger; use common_tracing::tracing; use common_tracing::tracing_appender::non_blocking::WorkerGuard; +use common_users::RoleCacheMgr; +use common_users::UserApiProvider; use futures::future::Either; use futures::StreamExt; use opendal::Operator; @@ -47,8 +49,6 @@ use crate::sessions::ProcessInfo; use crate::sessions::SessionManagerStatus; use crate::sessions::SessionType; use crate::storages::cache::CacheManager; -use crate::users::RoleCacheMgr; -use crate::users::UserApiProvider; use crate::Config; pub struct SessionManager { @@ -111,7 +111,8 @@ impl SessionManager { (Vec::new(), None) }; let mysql_conn_map = Arc::new(RwLock::new(HashMap::with_capacity(max_sessions))); - let user_api_provider = UserApiProvider::create_global(conf.clone()).await?; + let user_api_provider = + UserApiProvider::create_global(conf.meta.to_meta_grpc_client_conf()).await?; let role_cache_manager = Arc::new(RoleCacheMgr::new(user_api_provider.clone())); let exchange_manager = DataExchangeManager::create(conf.clone()); @@ -436,7 +437,7 @@ impl SessionManager { } { - let x = UserApiProvider::create_global(config).await?; + let x = UserApiProvider::create_global(config.meta.to_meta_grpc_client_conf()).await?; *self.user_api_provider.write() = x.clone(); let role_cache_manager = RoleCacheMgr::new(x); diff --git a/query/src/users/auth/mod.rs b/query/src/users/auth/mod.rs deleted file mode 100644 index a43acc56cd47..000000000000 --- a/query/src/users/auth/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2022 Datafuse Labs. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub(crate) mod auth_mgr; -pub mod jwt; diff --git a/query/tests/it/users/auth/auth_mgr.rs b/query/tests/it/auth.rs similarity index 98% rename from query/tests/it/users/auth/auth_mgr.rs rename to query/tests/it/auth.rs index 8c573e817886..c32de82a0b5d 100644 --- a/query/tests/it/users/auth/auth_mgr.rs +++ b/query/tests/it/auth.rs @@ -17,9 +17,9 @@ use base64::URL_SAFE_NO_PAD; use common_base::base::tokio; use common_exception::Result; use common_meta_types::UserIdentity; -use databend_query::users::auth::jwt::CustomClaims; -use databend_query::users::auth::jwt::EnsureUser; -use databend_query::users::Credential; +use common_users::CustomClaims; +use common_users::EnsureUser; +use databend_query::auth::Credential; use jwt_simple::prelude::*; use wiremock::matchers::method; use wiremock::matchers::path; diff --git a/query/tests/it/main.rs b/query/tests/it/main.rs index 576d6529ad8e..6745e143b848 100644 --- a/query/tests/it/main.rs +++ b/query/tests/it/main.rs @@ -11,7 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + mod api; +mod auth; mod catalogs; mod clusters; mod common; @@ -27,5 +29,4 @@ mod sql; mod storages; mod table_functions; mod tests; -mod users; mod version; diff --git a/query/tests/it/servers/http/http_query_handlers.rs b/query/tests/it/servers/http/http_query_handlers.rs index 9749e37816d7..62982d934f3f 100644 --- a/query/tests/it/servers/http/http_query_handlers.rs +++ b/query/tests/it/servers/http/http_query_handlers.rs @@ -22,6 +22,8 @@ use common_base::base::get_free_tcp_port; use common_base::base::tokio; use common_exception::ErrorCode; use common_exception::Result; +use common_users::CustomClaims; +use common_users::EnsureUser; use databend_query::servers::http::middleware::HTTPSessionEndpoint; use databend_query::servers::http::middleware::HTTPSessionMiddleware; use databend_query::servers::http::v1::make_final_uri; @@ -34,8 +36,6 @@ use databend_query::servers::http::v1::QueryResponse; use databend_query::servers::HttpHandler; use databend_query::servers::HttpHandlerKind; use databend_query::sessions::SessionManager; -use databend_query::users::auth::jwt::CustomClaims; -use databend_query::users::auth::jwt::EnsureUser; use headers::Header; use jwt_simple::algorithms::RS256KeyPair; use jwt_simple::algorithms::RSAKeyPairLike;