mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
Remove unused crates (#1394)
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -8130,11 +8130,9 @@ name = "rustfs-lock"
|
|||||||
version = "0.0.5"
|
version = "0.0.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes",
|
|
||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
"futures",
|
"futures",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rustfs-protos",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -8143,7 +8141,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tonic",
|
"tonic",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -8269,7 +8266,6 @@ dependencies = [
|
|||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"prost 0.14.1",
|
"prost 0.14.1",
|
||||||
"rustfs-common",
|
"rustfs-common",
|
||||||
"rustfs-credentials",
|
|
||||||
"tonic",
|
"tonic",
|
||||||
"tonic-prost",
|
"tonic-prost",
|
||||||
"tonic-prost-build",
|
"tonic-prost-build",
|
||||||
|
|||||||
@@ -170,12 +170,6 @@ pub const KI_B: usize = 1024;
|
|||||||
/// Default value: 1048576
|
/// Default value: 1048576
|
||||||
pub const MI_B: usize = 1024 * 1024;
|
pub const MI_B: usize = 1024 * 1024;
|
||||||
|
|
||||||
/// Environment variable for gRPC authentication token
|
|
||||||
/// Used to set the authentication token for gRPC communication
|
|
||||||
/// Example: RUSTFS_GRPC_AUTH_TOKEN=your_token_here
|
|
||||||
/// Default value: No default value. RUSTFS_SECRET_KEY value is recommended.
|
|
||||||
pub const ENV_GRPC_AUTH_TOKEN: &str = "RUSTFS_GRPC_AUTH_TOKEN";
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ pub const DEFAULT_ACCESS_KEY: &str = "rustfsadmin";
|
|||||||
/// Example: --secret-key rustfsadmin
|
/// Example: --secret-key rustfsadmin
|
||||||
pub const DEFAULT_SECRET_KEY: &str = "rustfsadmin";
|
pub const DEFAULT_SECRET_KEY: &str = "rustfsadmin";
|
||||||
|
|
||||||
/// Environment variable for gRPC authentication token
|
/// Environment variable for RPC authentication token
|
||||||
/// Used to set the authentication token for gRPC communication
|
/// Used to set the authentication token for RPC communication
|
||||||
/// Example: RUSTFS_GRPC_AUTH_TOKEN=your_token_here
|
/// Example: RUSTFS_RPC_SECRET=your_token_here
|
||||||
/// Default value: No default value. RUSTFS_SECRET_KEY value is recommended.
|
/// Default value: No default value. RUSTFS_SECRET_KEY value is recommended.
|
||||||
pub const ENV_GRPC_AUTH_TOKEN: &str = "RUSTFS_GRPC_AUTH_TOKEN";
|
pub const ENV_RPC_SECRET: &str = "RUSTFS_RPC_SECRET";
|
||||||
|
|
||||||
/// IAM Policy Types
|
/// IAM Policy Types
|
||||||
/// Used to differentiate between embedded and inherited policies
|
/// Used to differentiate between embedded and inherited policies
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use crate::{DEFAULT_SECRET_KEY, ENV_GRPC_AUTH_TOKEN, IAM_POLICY_CLAIM_NAME_SA, INHERITED_POLICY_TYPE};
|
use crate::{DEFAULT_SECRET_KEY, ENV_RPC_SECRET, IAM_POLICY_CLAIM_NAME_SA, INHERITED_POLICY_TYPE};
|
||||||
use rand::{Rng, RngCore};
|
use rand::{Rng, RngCore};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@@ -25,8 +25,8 @@ use time::OffsetDateTime;
|
|||||||
/// Global active credentials
|
/// Global active credentials
|
||||||
static GLOBAL_ACTIVE_CRED: OnceLock<Credentials> = OnceLock::new();
|
static GLOBAL_ACTIVE_CRED: OnceLock<Credentials> = OnceLock::new();
|
||||||
|
|
||||||
/// Global gRPC authentication token
|
/// Global RPC authentication token
|
||||||
static GLOBAL_GRPC_AUTH_TOKEN: OnceLock<String> = OnceLock::new();
|
pub static GLOBAL_RUSTFS_RPC_SECRET: OnceLock<String> = OnceLock::new();
|
||||||
|
|
||||||
/// Initialize the global action credentials
|
/// Initialize the global action credentials
|
||||||
///
|
///
|
||||||
@@ -181,15 +181,15 @@ pub fn gen_secret_key(length: usize) -> std::io::Result<String> {
|
|||||||
Ok(key_str)
|
Ok(key_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the gRPC authentication token from environment variable
|
/// Get the RPC authentication token from environment variable
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// * `String` - The gRPC authentication token
|
/// * `String` - The RPC authentication token
|
||||||
///
|
///
|
||||||
pub fn get_grpc_token() -> String {
|
pub fn get_rpc_token() -> String {
|
||||||
GLOBAL_GRPC_AUTH_TOKEN
|
GLOBAL_RUSTFS_RPC_SECRET
|
||||||
.get_or_init(|| {
|
.get_or_init(|| {
|
||||||
env::var(ENV_GRPC_AUTH_TOKEN)
|
env::var(ENV_RPC_SECRET)
|
||||||
.unwrap_or_else(|_| get_global_secret_key_opt().unwrap_or_else(|| DEFAULT_SECRET_KEY.to_string()))
|
.unwrap_or_else(|_| get_global_secret_key_opt().unwrap_or_else(|| DEFAULT_SECRET_KEY.to_string()))
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
|
|||||||
@@ -15,11 +15,8 @@
|
|||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
use base64::engine::general_purpose;
|
use base64::engine::general_purpose;
|
||||||
use hmac::{Hmac, KeyInit, Mac};
|
use hmac::{Hmac, KeyInit, Mac};
|
||||||
use http::HeaderMap;
|
use http::{HeaderMap, HeaderValue, Method, Uri};
|
||||||
use http::HeaderValue;
|
use rustfs_credentials::{DEFAULT_SECRET_KEY, ENV_RPC_SECRET, get_global_secret_key_opt};
|
||||||
use http::Method;
|
|
||||||
use http::Uri;
|
|
||||||
use rustfs_credentials::get_global_action_cred;
|
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
@@ -33,12 +30,16 @@ pub const TONIC_RPC_PREFIX: &str = "/node_service.NodeService";
|
|||||||
|
|
||||||
/// Get the shared secret for HMAC signing
|
/// Get the shared secret for HMAC signing
|
||||||
fn get_shared_secret() -> String {
|
fn get_shared_secret() -> String {
|
||||||
if let Some(cred) = get_global_action_cred() {
|
rustfs_credentials::GLOBAL_RUSTFS_RPC_SECRET
|
||||||
cred.secret_key
|
.get_or_init(|| {
|
||||||
} else {
|
rustfs_utils::get_env_str(
|
||||||
// Fallback to environment variable if global credentials are not available
|
ENV_RPC_SECRET,
|
||||||
std::env::var("RUSTFS_RPC_SECRET").unwrap_or_else(|_| "rustfs-default-secret".to_string())
|
get_global_secret_key_opt()
|
||||||
}
|
.unwrap_or_else(|| DEFAULT_SECRET_KEY.to_string())
|
||||||
|
.as_str(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate HMAC-SHA256 signature for the given data
|
/// Generate HMAC-SHA256 signature for the given data
|
||||||
|
|||||||
@@ -30,15 +30,12 @@ workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
bytes.workspace = true
|
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
rustfs-protos.workspace = true
|
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tonic.workspace = true
|
tonic.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
url.workspace = true
|
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustfs-common.workspace = true
|
rustfs-common.workspace = true
|
||||||
rustfs-credentials = { workspace = true }
|
|
||||||
flatbuffers = { workspace = true }
|
flatbuffers = { workspace = true }
|
||||||
prost = { workspace = true }
|
prost = { workspace = true }
|
||||||
tonic = { workspace = true, features = ["transport"] }
|
tonic = { workspace = true, features = ["transport"] }
|
||||||
|
|||||||
Reference in New Issue
Block a user