feat(nacos): add access control support

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-16 11:23:53 +08:00
1 parent 1838a4726e
commit c63c517b4f
67 files changed
+9062 -135

No files matched your search

+2 -1
View File
@@ -1259,7 +1259,7 @@ async fn test_connection_with_info_inner(
DatabaseType::Nacos => {
let admin_config = state.nacos_admin_config_for_connection(connection_id, &config).await?;
let adapter = state.nacos_registry.build_transient_config(admin_config).await?;
adapter.test_connection().await?;
adapter.test_connection_with_scope_validation().await?;
Ok("Connection successful".to_string())
}
DatabaseType::Consul => {
@@ -1386,6 +1386,7 @@ pub async fn connect_db(
let mut connected_db_config = db_config.clone();
state.remove_connection_pools_detached(&id).await;
drop_nacos_adapters_for_connection_ids(state.inner(), std::slice::from_ref(&id)).await;
state.reset_connection_transport_for_config(&id, &db_config).await;
let (host, port) = state.connection_host_port(&id, &db_config).await?;
+115
View File
@@ -22,6 +22,14 @@ pub async fn nacos_list_namespaces(
dbx_core::nacos::service::nacos_list_namespaces_core(&state, &connection_id).await
}
#[tauri::command]
pub async fn nacos_sidebar_snapshot(
state: State<'_, Arc<AppState>>,
connection_id: String,
) -> Result<dbx_core::nacos::NacosNamespaceSidebarSnapshot, String> {
dbx_core::nacos::service::nacos_sidebar_snapshot_core(&state, &connection_id).await
}
#[tauri::command]
pub async fn nacos_create_namespace(
state: State<'_, Arc<AppState>>,
@@ -120,6 +128,113 @@ pub async fn nacos_login_rnacos_console(
dbx_core::nacos::service::nacos_login_rnacos_console_core(&state, &connection_id, captcha).await
}
#[tauri::command]
pub async fn nacos_list_users(
state: State<'_, Arc<AppState>>,
connection_id: String,
query: dbx_core::nacos::NacosUserQuery,
) -> Result<dbx_core::nacos::NacosUserList, String> {
dbx_core::nacos::service::nacos_list_users_core(&state, &connection_id, query).await
}
#[tauri::command]
pub async fn nacos_create_user(
state: State<'_, Arc<AppState>>,
connection_id: String,
req: dbx_core::nacos::NacosUserCreate,
) -> Result<(), String> {
dbx_core::nacos::service::nacos_create_user_core(&state, &connection_id, req).await
}
#[tauri::command]
pub async fn nacos_update_user(
state: State<'_, Arc<AppState>>,
connection_id: String,
req: dbx_core::nacos::NacosUserUpdate,
) -> Result<(), String> {
dbx_core::nacos::service::nacos_update_user_core(&state, &connection_id, req).await
}
#[tauri::command]
pub async fn nacos_delete_user(
state: State<'_, Arc<AppState>>,
connection_id: String,
username: String,
) -> Result<(), String> {
dbx_core::nacos::service::nacos_delete_user_core(&state, &connection_id, username).await
}
#[tauri::command]
pub async fn nacos_list_role_bindings(
state: State<'_, Arc<AppState>>,
connection_id: String,
query: dbx_core::nacos::NacosRoleQuery,
) -> Result<dbx_core::nacos::NacosRoleList, String> {
dbx_core::nacos::service::nacos_list_role_bindings_core(&state, &connection_id, query).await
}
#[tauri::command]
pub async fn nacos_assign_role(
state: State<'_, Arc<AppState>>,
connection_id: String,
binding: dbx_core::nacos::NacosRoleBinding,
) -> Result<(), String> {
dbx_core::nacos::service::nacos_assign_role_core(&state, &connection_id, binding).await
}
#[tauri::command]
pub async fn nacos_remove_role(
state: State<'_, Arc<AppState>>,
connection_id: String,
binding: dbx_core::nacos::NacosRoleBinding,
) -> Result<(), String> {
dbx_core::nacos::service::nacos_remove_role_core(&state, &connection_id, binding).await
}
#[tauri::command]
pub async fn nacos_access_snapshot(
state: State<'_, Arc<AppState>>,
connection_id: String,
) -> Result<dbx_core::nacos::NacosAccessControlSnapshot, String> {
dbx_core::nacos::service::nacos_access_snapshot_core(&state, &connection_id).await
}
#[tauri::command]
pub async fn nacos_start_access_operation(
state: State<'_, Arc<AppState>>,
connection_id: String,
req: dbx_core::nacos::NacosAccessOperationRequest,
) -> Result<dbx_core::nacos::NacosAccessOperationResult, String> {
dbx_core::nacos::service::nacos_start_access_operation_core(&state, &connection_id, req).await
}
#[tauri::command]
pub async fn nacos_get_access_operation(
state: State<'_, Arc<AppState>>,
connection_id: String,
operation_id: String,
) -> Result<dbx_core::nacos::NacosAccessOperationResult, String> {
dbx_core::nacos::service::nacos_get_access_operation_core(&state, &connection_id, &operation_id).await
}
#[tauri::command]
pub async fn nacos_retry_access_operation(
state: State<'_, Arc<AppState>>,
connection_id: String,
retry: dbx_core::nacos::NacosAccessOperationRetry,
) -> Result<dbx_core::nacos::NacosAccessOperationResult, String> {
dbx_core::nacos::service::nacos_retry_access_operation_core(&state, &connection_id, retry).await
}
#[tauri::command]
pub async fn nacos_undo_access_operation(
state: State<'_, Arc<AppState>>,
connection_id: String,
operation_id: String,
) -> Result<dbx_core::nacos::NacosAccessOperationResult, String> {
dbx_core::nacos::service::nacos_undo_access_operation_core(&state, &connection_id, &operation_id).await
}
#[tauri::command]
pub async fn nacos_list_services(
state: State<'_, Arc<AppState>>,
+13
View File
@@ -1931,6 +1931,7 @@ pub fn run() {
commands::consul_cmd::consul_mesh_exported_services_apply,
commands::nacos_cmd::nacos_test_connection,
commands::nacos_cmd::nacos_list_namespaces,
commands::nacos_cmd::nacos_sidebar_snapshot,
commands::nacos_cmd::nacos_create_namespace,
commands::nacos_cmd::nacos_update_namespace,
commands::nacos_cmd::nacos_list_configs,
@@ -1942,6 +1943,18 @@ pub fn run() {
commands::nacos_cmd::nacos_rollback_config,
commands::nacos_cmd::nacos_get_rnacos_console_captcha,
commands::nacos_cmd::nacos_login_rnacos_console,
commands::nacos_cmd::nacos_list_users,
commands::nacos_cmd::nacos_create_user,
commands::nacos_cmd::nacos_update_user,
commands::nacos_cmd::nacos_delete_user,
commands::nacos_cmd::nacos_list_role_bindings,
commands::nacos_cmd::nacos_assign_role,
commands::nacos_cmd::nacos_remove_role,
commands::nacos_cmd::nacos_access_snapshot,
commands::nacos_cmd::nacos_start_access_operation,
commands::nacos_cmd::nacos_get_access_operation,
commands::nacos_cmd::nacos_retry_access_operation,
commands::nacos_cmd::nacos_undo_access_operation,
commands::nacos_cmd::nacos_list_services,
commands::nacos_cmd::nacos_get_service,
commands::nacos_cmd::nacos_create_service,