sync s3s, return UnauthorizedAccess error code when credentials is none

This commit is contained in:
weisd
2025-02-25 10:05:03 +08:00
parent dae6616720
commit 9f57ea9bb6
7 changed files with 26 additions and 28 deletions
Generated
+2 -2
View File
@@ -5467,7 +5467,7 @@ checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
[[package]]
name = "s3s"
version = "0.11.0-dev"
source = "git+https://github.com/Nugine/s3s.git?rev=7c78bd75f818783f1263041b61ab08b8182519b4#7c78bd75f818783f1263041b61ab08b8182519b4"
source = "git+https://github.com/Nugine/s3s.git?rev=ab139f72fe768fb9d8cecfe36269451da1ca9779#ab139f72fe768fb9d8cecfe36269451da1ca9779"
dependencies = [
"arrayvec",
"async-trait",
@@ -5514,7 +5514,7 @@ dependencies = [
[[package]]
name = "s3s-policy"
version = "0.11.0-dev"
source = "git+https://github.com/Nugine/s3s.git?rev=7c78bd75f818783f1263041b61ab08b8182519b4#7c78bd75f818783f1263041b61ab08b8182519b4"
source = "git+https://github.com/Nugine/s3s.git?rev=ab139f72fe768fb9d8cecfe36269451da1ca9779#ab139f72fe768fb9d8cecfe36269451da1ca9779"
dependencies = [
"indexmap 2.7.1",
"serde",
+2 -2
View File
@@ -71,10 +71,10 @@ reqwest = { version = "0.12.12", default-features = false, features = ["rustls-t
rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] }
rmp = "0.8.14"
rmp-serde = "1.3.0"
s3s = { git = "https://github.com/Nugine/s3s.git", rev = "7c78bd75f818783f1263041b61ab08b8182519b4", default-features = true, features = [
s3s = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779", default-features = true, features = [
"tower",
] }
s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "7c78bd75f818783f1263041b61ab08b8182519b4" }
s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779" }
shadow-rs = { version = "0.38.0", default-features = false }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.138"
+17 -17
View File
@@ -71,29 +71,29 @@ impl ServiceTraceOpts {
})
.collect();
self.s3 = query_pairs.get("s3").map_or(false, |v| v == "true");
self.os = query_pairs.get("os").map_or(false, |v| v == "true");
self.scanner = query_pairs.get("scanner").map_or(false, |v| v == "true");
self.decommission = query_pairs.get("decommission").map_or(false, |v| v == "true");
self.healing = query_pairs.get("healing").map_or(false, |v| v == "true");
self.batch_replication = query_pairs.get("batch-replication").map_or(false, |v| v == "true");
self.batch_key_rotation = query_pairs.get("batch-keyrotation").map_or(false, |v| v == "true");
self.batch_expire = query_pairs.get("batch-expire").map_or(false, |v| v == "true");
if query_pairs.get("all").map_or(false, |v| v == "true") {
self.s3 = query_pairs.get("s3").is_some_and(|v| v == "true");
self.os = query_pairs.get("os").is_some_and(|v| v == "true");
self.scanner = query_pairs.get("scanner").is_some_and(|v| v == "true");
self.decommission = query_pairs.get("decommission").is_some_and(|v| v == "true");
self.healing = query_pairs.get("healing").is_some_and(|v| v == "true");
self.batch_replication = query_pairs.get("batch-replication").is_some_and(|v| v == "true");
self.batch_key_rotation = query_pairs.get("batch-keyrotation").is_some_and(|v| v == "true");
self.batch_expire = query_pairs.get("batch-expire").is_some_and(|v| v == "true");
if query_pairs.get("all").is_some_and(|v| v == "true") {
self.s3 = true;
self.internal = true;
self.storage = true;
self.os = true;
}
self.rebalance = query_pairs.get("rebalance").map_or(false, |v| v == "true");
self.storage = query_pairs.get("storage").map_or(false, |v| v == "true");
self.internal = query_pairs.get("internal").map_or(false, |v| v == "true");
self.only_errors = query_pairs.get("err").map_or(false, |v| v == "true");
self.replication_resync = query_pairs.get("replication-resync").map_or(false, |v| v == "true");
self.bootstrap = query_pairs.get("bootstrap").map_or(false, |v| v == "true");
self.ftp = query_pairs.get("ftp").map_or(false, |v| v == "true");
self.ilm = query_pairs.get("ilm").map_or(false, |v| v == "true");
self.rebalance = query_pairs.get("rebalance").is_some_and(|v| v == "true");
self.storage = query_pairs.get("storage").is_some_and(|v| v == "true");
self.internal = query_pairs.get("internal").is_some_and(|v| v == "true");
self.only_errors = query_pairs.get("err").is_some_and(|v| v == "true");
self.replication_resync = query_pairs.get("replication-resync").is_some_and(|v| v == "true");
self.bootstrap = query_pairs.get("bootstrap").is_some_and(|v| v == "true");
self.ftp = query_pairs.get("ftp").is_some_and(|v| v == "true");
self.ilm = query_pairs.get("ilm").is_some_and(|v| v == "true");
if let Some(threshold) = query_pairs.get("threshold") {
let duration = parse_duration(threshold)?;
+2 -2
View File
@@ -19,7 +19,7 @@ impl IAMAuth {
impl S3Auth for IAMAuth {
async fn get_secret_key(&self, access_key: &str) -> S3Result<SecretKey> {
if access_key.is_empty() {
return Err(s3_error!(NotSignedUp, "Your account is not signed up"));
return Err(s3_error!(UnauthorizedAccess, "Your account is not signed up"));
}
if let Ok(key) = self.simple_auth.get_secret_key(access_key).await {
@@ -32,6 +32,6 @@ impl S3Auth for IAMAuth {
}
}
Err(s3_error!(NotSignedUp, "Your account is not signed up2"))
Err(s3_error!(UnauthorizedAccess, "Your account is not signed up2"))
}
}
+1 -4
View File
@@ -67,10 +67,7 @@ fn match_for_io_error(err_status: &Status) -> Option<&std::io::Error> {
}
}
err = match err.source() {
Some(err) => err,
None => return None,
};
err = err.source()?;
}
}
+1 -1
View File
@@ -52,7 +52,7 @@ impl S3Access for FS {
);
if cx.credentials().is_none() {
return Err(s3_error!(AccessDenied, "Signature is required"));
return Err(s3_error!(UnauthorizedAccess, "Signature is required"));
};
// TODO: FIXME: check auth
+1
View File
@@ -550,6 +550,7 @@ impl S3 for FS {
.map(|v| Bucket {
creation_date: v.created.map(Timestamp::from),
name: Some(v.name.clone()),
..Default::default()
})
.collect();