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

feat: users namespace #2471

Merged
merged 69 commits into from
Jul 9, 2024
Merged

feat: users namespace #2471

merged 69 commits into from
Jul 9, 2024

Conversation

gfanton
Copy link
Member

@gfanton gfanton commented Jul 1, 2024

Following and closing #384

This PR adds a user check when adding a new package. The check is based on the first part of the realm path: gno.land/(r|p)/<user_namespace>. It calls gno.land/r/demo/users.GetUserByName(<namespace>) to ensure the user exists and has registered the user namespace.

This PR also adds restricted name ability.

  • Only the admin can add restricted names
  • Restricted names CAN be registered using an admin invite

thanks @anarcher for the base

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Jul 1, 2024
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

Attention: Patch coverage is 27.90698% with 62 lines in your changes missing coverage. Please review.

Project coverage is 54.92%. Comparing base (a7fd05b) to head (5df88c5).

Files Patch % Lines
gno.land/pkg/sdk/vm/keeper.go 17.85% 44 Missing and 2 partials ⚠️
gno.land/pkg/integration/testing_integration.go 63.63% 4 Missing and 4 partials ⚠️
gno.land/pkg/sdk/vm/errors.go 0.00% 6 Missing ⚠️
gno.land/pkg/integration/testing_node.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2471      +/-   ##
==========================================
- Coverage   54.95%   54.92%   -0.04%     
==========================================
  Files         595      595              
  Lines       79568    79646      +78     
==========================================
+ Hits        43727    43743      +16     
- Misses      32533    32588      +55     
- Partials     3308     3315       +7     
Flag Coverage Δ
contribs/gnofaucet 15.31% <ø> (ø)
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 62.54% <27.90%> (-0.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

gno.land/pkg/sdk/vm/keeper.go Outdated Show resolved Hide resolved
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

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

Mostly good.

For the record, I'm still thinking that this logic should live outside the VMKeeper.

gfanton and others added 6 commits July 9, 2024 19:11
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
@gfanton gfanton merged commit abf8af6 into gnolang:master Jul 9, 2024
84 of 86 checks passed
@gfanton gfanton deleted the feat/check-user-perm branch July 9, 2024 18:07
gfanton added a commit to gfanton/gno that referenced this pull request Jul 23, 2024
Co-authored-by: anarcher <anarcher@gmail.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
var reNamespace = regexp.MustCompile(`^gno.land/(?:r|p)/([\.~_a-zA-Z0-9]+)`)

// checkNamespacePermission check if the user as given has correct permssion to on the given pkg path
func (vm *VMKeeper) checkNamespacePermission(ctx sdk.Context, creator crypto.Address, pkgPath string) error {
Copy link
Contributor

@piux2 piux2 Aug 4, 2024

Choose a reason for hiding this comment

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

For better security and trust of the chain, we should consider removing the admin from the system contract entirely. No one should be able to add a contract under /r/system unless it is voted on by the gov DAO or through a chain upgrade that involves consent from the validators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

6 participants