-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
Add rubygem scope to API key create API endpoint #3136
Conversation
db9e565
to
80dcd3f
Compare
@jenshenny any idea how to move this forward? 🤔 |
@jenshenny is out for the next week. I'm not sure where we got to on this but it looks like we'd need to do a fair amount of rebasing. |
Thanks for pinging me on this, it fell off my radar. At the point in time in which the PR was opened, it was ready for review. I'll rebase this PR and the RubyGems one rubygems/rubygems#5710 to get it up to date and make sure the changes make sense. Afterwards, I'll request some reviews! |
9c7a8d7
to
7d1e3db
Compare
Codecov Report
@@ Coverage Diff @@
## master #3136 +/- ##
=======================================
Coverage 98.77% 98.77%
=======================================
Files 209 209
Lines 5135 5139 +4
=======================================
+ Hits 5072 5076 +4
Misses 63 63
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
7d1e3db
to
c51be12
Compare
@@ -277,7 +277,7 @@ def self.should_expect_otp_for_update | |||
authorize_with("#{@user.email}:#{@user.password}") | |||
end | |||
|
|||
context "oh successful save" do | |||
context "on successful save" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
I'm sorry for such a long time without review. |
We did it! 😊 |
Adds onto: #2944
Adds support to scope an API key to a gem when creating an API key through the API. This will be used when the user runs
gem signin
.How is this implemented?
Added a
rubygem_name
param to API key create. Duringgem signin
, the client asks for the name of the gem.CLI PR: rubygems/rubygems#5710
Alternatives
I thought about having the user select from a list of their gems but it's difficult to display correctly if the user has many gems. Furthermore, the only endpoint that returns the gems someone owns requires an API key with the
index_rubygems
scope which can't work because the command is creating an API key. So if we were going to go down this path, we would need to allow for basic auth to the endpoint instead.Other Notes
I omitted adding the
rubygem_name
param to update for now asassign_attributes
autosaves associations and "half saves" the api key if validations fail. I have a branch with a monkey patch for it but I want to spend more time figuring out if there's a better way. Nonetheless, the update endpoint won't be used forgem signin
.Testing
Rubygem.create(name: "a-gem")
,Ownership.create_confirmed(Rubygem.find_by_name("a-gem", User.first, User.first
)RUBYGEMS_HOST=http://localhost:3000 ruby -Ilib bin/gem signin
in the rubygems directory