Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support grant/revoke writer/owner #1572

Merged
merged 1 commit into from
Feb 25, 2024
Merged

Support grant/revoke writer/owner #1572

merged 1 commit into from
Feb 25, 2024

Conversation

tarrencev
Copy link
Contributor

@tarrencev tarrencev commented Feb 21, 2024

Adds support for granting owners and setup for revoke commands.

Usage: sozo auth grant writer [OPTIONS] <model,contract_address>...
Usage: sozo auth grant owner [OPTIONS] <owner,resource>...

@tarrencev tarrencev marked this pull request as ready for review February 21, 2024 02:12
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: Patch coverage is 48.57143% with 72 lines in your changes are missing coverage. Please review.

Project coverage is 69.63%. Comparing base (640e94d) to head (cf0a8de).
Report is 2 commits behind head on main.

Files Patch % Lines
bin/sozo/src/ops/auth.rs 0.00% 46 Missing ⚠️
bin/sozo/src/ops/mod.rs 0.00% 14 Missing ⚠️
bin/sozo/src/commands/auth.rs 90.66% 7 Missing ⚠️
bin/sozo/src/ops/execute.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1572      +/-   ##
==========================================
- Coverage   70.66%   69.63%   -1.04%     
==========================================
  Files         264      265       +1     
  Lines       25623    26298     +675     
==========================================
+ Hits        18107    18313     +206     
- Misses       7516     7985     +469     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
}
},
_ => todo!(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good first issue. :)

bin/sozo/src/commands/auth.rs Outdated Show resolved Hide resolved
let owner = FieldElement::from_hex_be(owner_part)
.map_err(|_| anyhow::anyhow!("Invalid owner address: {}", owner_part))?;

let resource_parts: Vec<&str> = resource_part.split(':').collect();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the resource can be contract:contract_name, we're expecting the fully qualifier name of the contract or the short name? It will fail here if we have to pass the fully qualified name due to : split.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, this would be an issue for fully qualified name.

We can use split_once for this to capture the first occurrence of : if we wanna maintain this format.

Considering most contract name would be fully qualified name, i think this format can cause a bit of confusion when user do something like contract:examples::action::action_1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm yeah good point. i was following the starkli schema pattern but perhaps we should do something difference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about this a bit more, i feel like it is ok. so going to plan to keep as is, unless you guys feel strongly about it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, this is a needed feature so don't wanna block too much. We can always address it if it becomes an actual concern later.

Comment on lines +64 to +62
impl FromStr for OwnerResource {
type Err = anyhow::Error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much better, nice idea.

bin/sozo/src/commands/auth.rs Outdated Show resolved Hide resolved
bin/sozo/src/commands/auth.rs Outdated Show resolved Hide resolved
let owner = FieldElement::from_hex_be(owner_part)
.map_err(|_| anyhow::anyhow!("Invalid owner address: {}", owner_part))?;

let resource_parts: Vec<&str> = resource_part.split(':').collect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, this would be an issue for fully qualified name.

We can use split_once for this to capture the first occurrence of : if we wanna maintain this format.

Considering most contract name would be fully qualified name, i think this format can cause a bit of confusion when user do something like contract:examples::action::action_1

@tarrencev tarrencev merged commit 82a5bb8 into main Feb 25, 2024
10 of 12 checks passed
@tarrencev tarrencev deleted the authupdate branch February 25, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants