Skip to content

Commit

Permalink
fix: fix access_token for ic_oss_bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 23, 2024
1 parent 76650be commit 3cf65e4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
36 changes: 31 additions & 5 deletions src/ic_oss_bucket/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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(
Expand All @@ -1917,7 +1943,7 @@ mod test {
name: "fd2".to_string(),
..Default::default()
},
2,
4,
1,
2,
)
Expand All @@ -1932,7 +1958,7 @@ mod test {
name: "fd2".to_string(),
..Default::default()
},
2,
4,
1,
2,
)
Expand Down
1 change: 1 addition & 0 deletions src/ic_oss_types/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ pub struct MoveInput {
pub to: u32,
}

#[derive(Debug)]
pub struct UrlFileParam {
pub file: u32,
pub hash: Option<ByteArray<32>>,
Expand Down

0 comments on commit 3cf65e4

Please sign in to comment.