diff --git a/Cargo.lock b/Cargo.lock index 22896bf..c3d13b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,7 +1324,7 @@ dependencies = [ [[package]] name = "ic-oss" -version = "0.9.6" +version = "0.9.7" dependencies = [ "bytes", "candid", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "ic-oss-can" -version = "0.9.6" +version = "0.9.7" dependencies = [ "candid", "ciborium", @@ -1354,7 +1354,7 @@ dependencies = [ [[package]] name = "ic-oss-cli" -version = "0.9.6" +version = "0.9.7" dependencies = [ "anyhow", "candid", @@ -1375,7 +1375,7 @@ dependencies = [ [[package]] name = "ic-oss-types" -version = "0.9.6" +version = "0.9.7" dependencies = [ "base64 0.22.1", "candid", @@ -1466,7 +1466,7 @@ dependencies = [ [[package]] name = "ic_oss_bucket" -version = "0.9.6" +version = "0.9.7" dependencies = [ "base64 0.22.1", "candid", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "ic_oss_cluster" -version = "0.9.6" +version = "0.9.7" dependencies = [ "candid", "ciborium", diff --git a/Cargo.toml b/Cargo.toml index f566b68..cd9ad16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ strip = true opt-level = 's' [workspace.package] -version = "0.9.6" +version = "0.9.7" edition = "2021" repository = "https://github.com/ldclabs/ic-oss" keywords = ["file", "storage", "oss", "s3", "icp"] diff --git a/src/ic_oss_bucket/src/store.rs b/src/ic_oss_bucket/src/store.rs index 7fcab36..1e34fe5 100644 --- a/src/ic_oss_bucket/src/store.rs +++ b/src/ic_oss_bucket/src/store.rs @@ -148,9 +148,11 @@ impl Bucket { now_sec as i64, ) .map_err(|err| (401, err))?; - if token.subject == ctx.caller && &token.audience == canister { + + if &token.audience == canister { ctx.ps = Policies::try_from(token.policies.as_str()).map_err(|err| (403u16, err))?; + ctx.caller = token.subject; return Ok(ctx); } } @@ -194,9 +196,10 @@ impl Bucket { now_sec as i64, ) .map_err(|err| (401, err))?; - if token.subject == ctx.caller && &token.audience == canister { + if &token.audience == canister { ctx.ps = Policies::try_from(token.policies.as_str()).map_err(|err| (403u16, err))?; + ctx.caller = token.subject; return Ok(ctx); } } @@ -1905,10 +1908,33 @@ mod test { 1, 1, ) + .is_ok()); + assert!(tree + .add_folder( + FolderMetadata { + parent: 1, + name: "fd2".to_string(), + ..Default::default() + }, + 3, + 2, + 1, + ) + .is_ok()); + assert!(tree + .add_folder( + FolderMetadata { + parent: 1, + name: "fd2".to_string(), + ..Default::default() + }, + 4, + 2, + 1, + ) .err() .unwrap() .contains("children exceeds limit")); - tree.get_mut(&0).unwrap().status = 1; assert!(tree .add_folder( @@ -1917,7 +1943,7 @@ mod test { name: "fd2".to_string(), ..Default::default() }, - 2, + 4, 1, 2, ) @@ -1932,7 +1958,7 @@ mod test { name: "fd2".to_string(), ..Default::default() }, - 2, + 4, 1, 2, ) diff --git a/src/ic_oss_types/src/file.rs b/src/ic_oss_types/src/file.rs index 8228399..3af5443 100644 --- a/src/ic_oss_types/src/file.rs +++ b/src/ic_oss_types/src/file.rs @@ -161,6 +161,7 @@ pub struct MoveInput { pub to: u32, } +#[derive(Debug)] pub struct UrlFileParam { pub file: u32, pub hash: Option>,