Merge pull request #147 from rustfs/iam-sys-4

fix: make cargo check happy
This commit is contained in:
bestgopher
2024-12-04 20:50:35 +08:00
committed by GitHub
13 changed files with 22 additions and 33 deletions

View File

@@ -14,7 +14,7 @@ chacha20poly1305 = { version = "0.10.1", optional = true }
jsonwebtoken = "9.3.0"
pbkdf2 = { version = "0.12.2", optional = true }
rand = { workspace = true, optional = true }
sha2 = "0.10.8"
sha2 = { version = "0.10.8", optional = true }
thiserror.workspace = true
serde_json.workspace = true
@@ -24,6 +24,7 @@ test-case.workspace = true
time.workspace = true
[features]
default = ["crypto", "fips"]
fips = []
crypto = [
"dep:aes-gcm",
@@ -31,8 +32,8 @@ crypto = [
"dep:chacha20poly1305",
"dep:pbkdf2",
"dep:rand",
"dep:sha2",
]
default = ["crypto", "fips"]
[lints.clippy]
unwrap_used = "deny"

View File

@@ -37,7 +37,7 @@ fn decryp<T: aes_gcm::aead::Aead>(stream: T, nonce: &[u8], data: &[u8]) -> Resul
.map_err(Error::ErrDecryptFailed)
}
#[cfg(all(not(test), not(feature = "crypto")))]
#[cfg(not(any(test, feature = "crypto")))]
pub fn decrypt_data(_password: &[u8], data: &[u8]) -> Result<Vec<u8>, crate::Error> {
Ok(data.to_vec())
}

View File

@@ -55,7 +55,7 @@ fn encrypt<T: aes_gcm::aead::Aead>(
Ok(ciphertext)
}
#[cfg(all(not(test), not(feature = "crypto")))]
#[cfg(not(any(test, feature = "crypto")))]
pub fn encrypt_data(_password: &[u8], data: &[u8]) -> Result<Vec<u8>, crate::Error> {
Ok(data.to_vec())
}

View File

@@ -1,5 +1,3 @@
use sha2::digest::InvalidLength;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("unexpected header")]
@@ -8,8 +6,9 @@ pub enum Error {
#[error("invalid encryption algorithm ID: {0}")]
ErrInvalidAlgID(u8),
#[cfg(any(test, feature = "crypto"))]
#[error("{0}")]
ErrInvalidLength(#[from] InvalidLength),
ErrInvalidLength(#[from] sha2::digest::InvalidLength),
#[cfg(any(test, feature = "crypto"))]
#[error("encrypt failed")]

View File

@@ -2,7 +2,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use std::cell::LazyCell;
use std::collections::HashMap;
use std::env::var;
use time::format_description::BorrowedFormatItem;
use time::{Date, OffsetDateTime};
@@ -103,7 +102,7 @@ impl Credentials {
Self::check_key_value(header)
}
pub fn check_key_value(header: CredentialHeader) -> crate::Result<Self> {
pub fn check_key_value(_header: CredentialHeader) -> crate::Result<Self> {
todo!()
}

View File

@@ -93,7 +93,7 @@ impl CacheInner {
self.users.get(user_name).or_else(|| self.sts_accounts.get(user_name))
}
fn get_policy(&self, name: &str, groups: &[String]) -> crate::Result<Vec<Policy>> {
fn get_policy(&self, _name: &str, _groups: &[String]) -> crate::Result<Vec<Policy>> {
todo!()
}
@@ -126,13 +126,13 @@ impl CacheInner {
}
// todo
pub fn is_allowed_sts(&self, args: &Args, parent: &str) -> bool {
pub fn is_allowed_sts(&self, _args: &Args, _parent: &str) -> bool {
warn!("unimplement is_allowed_sts");
false
}
// todo
pub fn is_allowed_service_account(&self, args: &Args, parent: &str) -> bool {
pub fn is_allowed_service_account(&self, _args: &Args, _parent: &str) -> bool {
warn!("unimplement is_allowed_sts");
false
}
@@ -141,7 +141,7 @@ impl CacheInner {
todo!()
}
pub fn policy_db_get(&self, name: &str, groups: &[String]) -> Vec<String> {
pub fn policy_db_get(&self, _name: &str, _groups: &[String]) -> Vec<String> {
todo!()
}
}

View File

@@ -1,5 +1,3 @@
use core::error;
use crate::policy;
#[derive(thiserror::Error, Debug)]

View File

@@ -1,13 +1,12 @@
use std::{borrow::Cow, collections::HashMap, f32::NAN};
use std::{borrow::Cow, collections::HashMap};
use log::{info, warn};
use time::OffsetDateTime;
use crate::{
arn::ARN,
auth::{Credentials, UserIdentity},
cache::{Cache, CacheInner},
policy::{utils::get_values_from_claims, Args, MappedPolicy, Policy, UserType},
auth::UserIdentity,
cache::CacheInner,
policy::{utils::get_values_from_claims, Args, Policy},
store::Store,
Error,
};
@@ -36,7 +35,7 @@ where
.or_else(|| self.cache.sts_accounts.get(user_name))
}
async fn get_policy(&self, name: &str, groups: &[String]) -> crate::Result<Vec<String>> {
async fn get_policy(&self, name: &str, _groups: &[String]) -> crate::Result<Vec<String>> {
if name.is_empty() {
return Err(Error::InvalidArgument);
}
@@ -122,7 +121,7 @@ where
false
}
pub async fn get_combined_policy(&self, policyes: &[String]) -> Policy {
pub async fn get_combined_policy(&self, _policies: &[String]) -> Policy {
todo!()
}

View File

@@ -1,5 +1,3 @@
use std::default;
use serde::{Deserialize, Serialize};
use strum::{EnumString, IntoStaticStr};

View File

@@ -1,7 +1,6 @@
use std::{collections::HashMap, ops::Deref};
use func::Func;
use key::Key;
use serde::{de, Deserialize, Serialize};
pub mod addr;
@@ -56,7 +55,7 @@ impl<'de> Deserialize<'de> for Functions {
return Err(A::Error::custom("invalid codition"));
}
let Some(name) = name else { return Err(A::Error::custom("invalid codition")) };
let Some(_name) = name else { return Err(A::Error::custom("invalid codition")) };
let f = match qualifier {
Some("ForAnyValues") => Func::ForAnyValues,

View File

@@ -1,5 +1,3 @@
use std::borrow::Cow;
use serde::{Deserialize, Serialize};
use super::{action::Action, ActionSet, Args, Effect, Error, Functions, ResourceSet, Validator, ID};

View File

@@ -1,5 +1,3 @@
use std::{fmt::Write, usize};
struct LazyBuf<'a> {
s: &'a str,
buf: Option<Vec<u8>>,

View File

@@ -6,14 +6,14 @@ use ecstore::{
store_api::{HTTPRangeSpec, ObjectIO, ObjectInfo, ObjectOptions, PutObjReader},
utils::path::dir,
};
use futures::{future::try_join_all, SinkExt};
use futures::future::try_join_all;
use log::debug;
use serde::{de::DeserializeOwned, Serialize};
use super::Store;
use crate::{
auth::UserIdentity,
cache::{Cache, CacheEntity, CacheInner},
cache::{Cache, CacheEntity},
policy::{utils::split_path, MappedPolicy, PolicyDoc, UserType},
Error,
};
@@ -102,7 +102,7 @@ impl ObjectStore {
Ok(Some(user))
}
async fn load_mapped_policy(&self, user_type: UserType, name: &str, is_group: bool) -> crate::Result<MappedPolicy> {
async fn load_mapped_policy(&self, user_type: UserType, name: &str, _is_group: bool) -> crate::Result<MappedPolicy> {
let (p, _) = self
.load_iam_config::<MappedPolicy>(&format!("{base}{name}.json", base = user_type.prefix(), name = name))
.await?;