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

Maintainer Role #4883

Merged
merged 30 commits into from
Oct 14, 2024
Merged

Maintainer Role #4883

merged 30 commits into from
Oct 14, 2024

Conversation

colby-swandale
Copy link
Member

@colby-swandale colby-swandale commented Jul 11, 2024

What's this about?

RubyGems.org currently has a single implicit role assigned to everyone who is an owner of a given gem. This role lets any gem owner do any, and all, things to a gem without restriction, such as adding & removing other owners, publishing new versions, yanking versions etc. In recent years, a strong desire in the community as emerged for a role system to be introduced for groups & businesses to better align their organizational structure and reduce the impact blast of any potential account take over.

What this Pull Request introduces

  • This Pull Request adds the formal concept of a Owner & Maintainer role and what permissions are granted.
  • Adds a new field to Ownership that assigns a particular role for the that gem + owner relationship
  • Adds a new form to edit an existing ownership to allow user's roles to be updated (Owners or Maintainers cannot update their own Role).

What this Pull Request is not introducing

  • Fine grained access controls. Permissions & Roles will remain specified in source code and cannot be modified by users.

Technical Details

We've added a new field to the Ownership table that records the user's current role. Inside Rails this is mapped from a string, either maintainer or owner to a new mapped integer in Access which is the thing that's stored in Postgres.

This integer is then used to determine what level of access is granted inside the Rubygem policy.

Decisions made for this Pull Request

The blast radius of this change if things goes wrong is very big, worst case is we stop anyone from publishing new versions. So a priority on maintaining the status quo was put in place to guide this PR.

  • All existing ownerships will remain untouched with the same permissions they currently have.
  • The default role offered to users in our UI will remain as "Owner" the same role that was implicitly assigned.

Owner vs Maintainer

Owner Maintainer
Manage Owners
Publish Version
Yank Version
Manage Adoptions
Manage Trusted Publishing

Screenshots

Viewing current owners and their role
Screenshot 2024-08-13 at 3 03 39 PM

Updating a user's role
Screenshot 2024-08-13 at 3 03 40 PM

User notification of their role being updated
Screenshot 2024-08-14 at 5 14 53 PM

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 97.79412% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.97%. Comparing base (ea8688c) to head (fc63946).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
app/policies/organization_policy.rb 88.88% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4883      +/-   ##
==========================================
+ Coverage   96.95%   96.97%   +0.01%     
==========================================
  Files         421      424       +3     
  Lines        8777     8892     +115     
==========================================
+ Hits         8510     8623     +113     
- Misses        267      269       +2     

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

@colby-swandale colby-swandale changed the title 🚧 Maintainer Role Maintainer Role Aug 12, 2024
@colby-swandale colby-swandale marked this pull request as ready for review August 14, 2024 09:25
app/avo/resources/ownership_resource.rb Outdated Show resolved Hide resolved
app/controllers/api/v1/owners_controller.rb Outdated Show resolved Hide resolved
db/migrate/20240717081704_add_access_level_to_ownership.rb Outdated Show resolved Hide resolved
app/avo/resources/ownership_resource.rb Outdated Show resolved Hide resolved
app/models/ownership.rb Outdated Show resolved Hide resolved
app/controllers/api/v1/owners_controller.rb Outdated Show resolved Hide resolved
app/views/owners/_owners_table.html.erb Show resolved Hide resolved
@colby-swandale colby-swandale force-pushed the colby/maintainer-role branch 2 times, most recently from 5f2b2de to 7146007 Compare September 5, 2024 05:44
app/models/rubygem.rb Outdated Show resolved Hide resolved
app/views/owners/_owners_table.html.erb Outdated Show resolved Hide resolved
config/locales/en.yml Outdated Show resolved Hide resolved
app/controllers/api/v1/owners_controller.rb Outdated Show resolved Hide resolved
app/models/ownership.rb Show resolved Hide resolved
app/policies/rubygem_policy.rb Outdated Show resolved Hide resolved
Copy link
Member

@martinemde martinemde left a comment

Choose a reason for hiding this comment

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

I think it looks good, I need to finish reading through the tests so I'll approve when I'm done, but wanted to get these comments in.

app/models/events/rubygem_event.rb Outdated Show resolved Hide resolved
config/brakeman.ignore Outdated Show resolved Hide resolved
colby-swandale and others added 22 commits October 9, 2024 15:41
Replace the raw sql with something nicer
Make authorization failures more helpful on ownership changes.
We were sometimes returning just the text 'Forbidden' when
really we need to say that you can't edit your own role or
explain the authorization problem, if possible, then redirect
back to the rubygem page.
Co-authored-by: Martin Emde <martinemde@users.noreply.github.com>
Copy link
Member

@martinemde martinemde left a comment

Choose a reason for hiding this comment

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

I reviewed changes since last time. Looks good.

test/mailers/previews/mailer_preview.rb Outdated Show resolved Hide resolved
@colby-swandale colby-swandale merged commit 8021e2e into master Oct 14, 2024
18 checks passed
@colby-swandale colby-swandale deleted the colby/maintainer-role branch October 14, 2024 07:14
@colby-swandale colby-swandale mentioned this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants