mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 05:17:42 +00:00
refactor: route site replication iam through app context (#3777)
This commit is contained in:
@@ -32,7 +32,7 @@ use crate::admin::site_replication_identity::{
|
||||
};
|
||||
use crate::admin::utils::{encode_compatible_admin_payload, read_compatible_admin_body};
|
||||
use crate::app::context::{
|
||||
resolve_deployment_id, resolve_endpoints_handle, resolve_object_store_handle, resolve_region,
|
||||
resolve_deployment_id, resolve_endpoints_handle, resolve_iam_handle, resolve_object_store_handle, resolve_region,
|
||||
resolve_replication_pool_handle, resolve_runtime_port, resolve_server_config,
|
||||
};
|
||||
use crate::auth::{check_key_valid, get_session_token};
|
||||
@@ -51,11 +51,11 @@ use rustfs_config::{
|
||||
MAX_ADMIN_REQUEST_BODY_SIZE,
|
||||
};
|
||||
use rustfs_iam::error::is_err_no_such_service_account;
|
||||
use rustfs_iam::get_oidc;
|
||||
use rustfs_iam::store::{MappedPolicy, UserType};
|
||||
use rustfs_iam::sys::{
|
||||
NewServiceAccountOpts, SITE_REPLICATOR_SERVICE_ACCOUNT, UpdateServiceAccountOpts, get_claims_from_token_with_secret,
|
||||
};
|
||||
use rustfs_iam::{get_global_iam_sys, get_oidc};
|
||||
use rustfs_madmin::{
|
||||
BucketBandwidth, GroupStatus, IDPSettings, InProgressMetric, InQueueMetric, LDAPConfigSettings, LDAPSettings,
|
||||
OpenIDProviderSettings, PeerInfo, PeerSite, QStat, ReplProxyMetric, ReplicateAddStatus, ReplicateEditStatus,
|
||||
@@ -1114,7 +1114,7 @@ fn reconcile_peer_with_actual_identity(mut state: SiteReplicationState, actual_p
|
||||
}
|
||||
|
||||
async fn site_replicator_service_account_secret(access_key: &str) -> S3Result<String> {
|
||||
let Some(iam_sys) = get_global_iam_sys() else {
|
||||
let Some(iam_sys) = resolve_iam_handle() else {
|
||||
return Err(s3_error!(InvalidRequest, "iam not init"));
|
||||
};
|
||||
|
||||
@@ -1131,7 +1131,7 @@ fn legacy_site_replicator_state_secret(state: &SiteReplicationState) -> Option<S
|
||||
}
|
||||
|
||||
async fn set_site_replicator_service_account_secret(parent_user: &str, secret_key: String) -> S3Result<String> {
|
||||
let Some(iam_sys) = get_global_iam_sys() else {
|
||||
let Some(iam_sys) = resolve_iam_handle() else {
|
||||
return Err(s3_error!(InvalidRequest, "iam not init"));
|
||||
};
|
||||
|
||||
@@ -1177,7 +1177,7 @@ async fn set_site_replicator_service_account_secret(parent_user: &str, secret_ke
|
||||
}
|
||||
|
||||
async fn ensure_site_replicator_service_account(parent_user: &str, rotate_secret: bool) -> S3Result<(String, String)> {
|
||||
let Some(iam_sys) = get_global_iam_sys() else {
|
||||
let Some(iam_sys) = resolve_iam_handle() else {
|
||||
return Err(s3_error!(InvalidRequest, "iam not init"));
|
||||
};
|
||||
|
||||
@@ -1619,7 +1619,7 @@ async fn build_sr_info(state: &SiteReplicationState, local_peer: &PeerInfo) -> S
|
||||
info.buckets.insert(bucket.name, entry);
|
||||
}
|
||||
|
||||
if let Some(iam_sys) = get_global_iam_sys() {
|
||||
if let Some(iam_sys) = resolve_iam_handle() {
|
||||
for (name, policy_doc) in iam_sys.list_policy_docs("").await.map_err(ApiError::from)? {
|
||||
info.policies.insert(
|
||||
name,
|
||||
@@ -3502,7 +3502,7 @@ fn group_info_requires_upsert(update: &rustfs_madmin::GroupAddRemove) -> bool {
|
||||
}
|
||||
|
||||
async fn apply_iam_item(item: SRIAMItem) -> S3Result<()> {
|
||||
let Some(iam_sys) = get_global_iam_sys() else {
|
||||
let Some(iam_sys) = resolve_iam_handle() else {
|
||||
return Err(s3_error!(InvalidRequest, "iam not init"));
|
||||
};
|
||||
let incoming_updated_at = item.updated_at;
|
||||
@@ -4010,7 +4010,7 @@ impl Operation for SRPeerJoinHandler {
|
||||
}
|
||||
|
||||
if !join_req.svc_acct_access_key.is_empty() && !join_req.svc_acct_secret_key.is_empty() {
|
||||
let Some(iam_sys) = get_global_iam_sys() else {
|
||||
let Some(iam_sys) = resolve_iam_handle() else {
|
||||
return Err(s3_error!(InvalidRequest, "iam not init"));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user