refactor: remove external owner compat bridges (#3741)

This commit is contained in:
Zhengchao An
2026-06-22 18:28:35 +08:00
committed by GitHub
parent 539c68778d
commit d3796d6c10
25 changed files with 618 additions and 618 deletions
+155 -2
View File
@@ -12,10 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use self::storage_compat::IamStore;
use crate::error::{Error, Result};
use manager::IamCache;
use oidc::OidcSys;
use rustfs_ecstore::api::{
config as ecstore_config, error as ecstore_error, global as ecstore_global, notification as ecstore_notification,
storage as ecstore_storage,
};
use std::sync::{Arc, OnceLock};
use store::object::ObjectStore;
use sys::IamSys;
@@ -33,11 +36,161 @@ pub mod keyring;
pub mod manager;
pub mod oidc;
pub mod oidc_state;
mod storage_compat;
pub mod store;
pub mod sys;
pub mod utils;
pub(crate) const IAM_CONFIG_ROOT_PREFIX: &str = ecstore_config::RUSTFS_CONFIG_PREFIX;
pub(crate) type IamEcstoreError = ecstore_error::Error;
pub(crate) type IamStorageError = ecstore_error::StorageError;
pub(crate) type IamStorageResult<T> = ecstore_error::Result<T>;
pub(crate) type IamStore = ecstore_storage::ECStore;
pub(crate) type IamConfigObjectInfo = <IamStore as rustfs_storage_api::ObjectOperations>::ObjectInfo;
pub(crate) type IamConfigObjectOptions = <IamStore as rustfs_storage_api::ObjectOperations>::ObjectOptions;
pub(crate) async fn read_iam_config_no_lock(api: Arc<IamStore>, file: &str) -> IamStorageResult<Vec<u8>> {
ecstore_config::com::read_config_no_lock(api, file).await
}
pub(crate) async fn read_iam_config_with_metadata(
api: Arc<IamStore>,
file: &str,
opts: &IamConfigObjectOptions,
) -> IamStorageResult<(Vec<u8>, IamConfigObjectInfo)> {
ecstore_config::com::read_config_with_metadata(api, file, opts).await
}
pub(crate) async fn save_iam_config(api: Arc<IamStore>, file: &str, data: Vec<u8>) -> IamStorageResult<()> {
ecstore_config::com::save_config(api, file, data).await
}
pub(crate) async fn save_iam_config_with_opts(
api: Arc<IamStore>,
file: &str,
data: Vec<u8>,
opts: &IamConfigObjectOptions,
) -> IamStorageResult<()> {
ecstore_config::com::save_config_with_opts(api, file, data, opts).await
}
pub(crate) async fn delete_iam_config(api: Arc<IamStore>, file: &str) -> IamStorageResult<()> {
ecstore_config::com::delete_config(api, file).await
}
pub(crate) fn classify_iam_system_path_failure_reason(err: &IamEcstoreError) -> &'static str {
ecstore_error::classify_system_path_failure_reason(err)
}
pub(crate) async fn is_iam_first_cluster_node_local() -> bool {
ecstore_global::is_first_cluster_node_local().await
}
pub(crate) struct IamNotificationPeerErr {
pub(crate) err: Option<IamEcstoreError>,
}
impl From<ecstore_notification::NotificationPeerErr> for IamNotificationPeerErr {
fn from(value: ecstore_notification::NotificationPeerErr) -> Self {
Self { err: value.err }
}
}
pub(crate) async fn notify_iam_delete_policy(policy_name: &str) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.delete_policy(policy_name)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_load_policy(policy_name: &str) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_policy(policy_name)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_delete_user(access_key: &str) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.delete_user(access_key)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_load_user(access_key: &str, temp: bool) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_user(access_key, temp)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_load_service_account(access_key: &str) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_service_account(access_key)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_delete_service_account(access_key: &str) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.delete_service_account(access_key)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_load_group(group: &str) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys.load_group(group).await.into_iter().map(Into::into).collect(),
None => Vec::new(),
}
}
pub(crate) async fn notify_iam_load_policy_mapping(
user_or_group: &str,
user_type: u64,
is_group: bool,
) -> Vec<IamNotificationPeerErr> {
match ecstore_notification::get_global_notification_sys() {
Some(notification_sys) => notification_sys
.load_policy_mapping(user_or_group, user_type, is_group)
.await
.into_iter()
.map(Into::into)
.collect(),
None => Vec::new(),
}
}
static IAM_SYS: OnceLock<Arc<IamSys<ObjectStore>>> = OnceLock::new();
static OIDC_SYS: OnceLock<Arc<OidcSys>> = OnceLock::new();