mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-05 12:57:42 +00:00
bb2f765e5d
add iam store feat: add crypto crate introduce decrypt_data and encrypt_data functions Signed-off-by: bestgopher <84328409@qq.com>
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
pub mod object;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use ecstore::store_api::ObjectInfo;
|
|
use serde::{de::DeserializeOwned, Serialize};
|
|
|
|
use crate::{
|
|
auth::UserIdentity,
|
|
cache::Cache,
|
|
policy::{PolicyDoc, UserType, DEFAULT_POLICIES},
|
|
};
|
|
|
|
#[async_trait::async_trait]
|
|
pub trait Store: Clone + Send + Sync + 'static {
|
|
async fn load_iam_config<Item>(&self, path: impl AsRef<str> + Send) -> crate::Result<(Item, ObjectInfo)>
|
|
where
|
|
Item: DeserializeOwned;
|
|
|
|
async fn save_iam_config<Item: Serialize + Send>(&self, item: Item, path: impl AsRef<str> + Send) -> crate::Result<()>;
|
|
|
|
async fn load_all(&self, cache: &Cache) -> crate::Result<()>;
|
|
|
|
fn get_default_policyes() -> HashMap<String, PolicyDoc> {
|
|
DEFAULT_POLICIES
|
|
.iter()
|
|
.map(|(n, p)| {
|
|
(
|
|
n.to_string(),
|
|
PolicyDoc {
|
|
version: 1,
|
|
policy: p.clone(),
|
|
..Default::default()
|
|
},
|
|
)
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
async fn load_users(&self, user_type: UserType) -> crate::Result<HashMap<String, UserIdentity>>;
|
|
|
|
async fn load_policy_docs(&self) -> crate::Result<HashMap<String, PolicyDoc>>;
|
|
}
|