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

authorize: support naming and listing authorizations #365

Merged
merged 3 commits into from
Sep 27, 2023

Conversation

kyrofa
Copy link
Contributor

@kyrofa kyrofa commented Sep 25, 2023

Over time, gemstash authorizations turn into a pile of opaque tokens and associated permissions. Keeping track of which token belongs to which developer or automated system is required to enable proper revocation or rotation. Today, that requires the use of an external system, which has the added problem of duplicating the key itself.

This PR resolves #364, adding support for keeping this association within Gemstash itself by allowing for authorizations to be named. It also adds support for listing authorizations, so it's easy to determine which key needs to be revoked, rotated, or otherwise updated. See the manpage updates for details on use.

Over time, gemstash authorizations turn into a pile of opaque tokens and
associated permissions. Keeping track of which token belongs to which
developer or automated system is required to enabled proper revocation
or rotation. Today, that requires the use of an external system, which
has the added problem of duplicating the key itself.

Support keeping this association within Gemstash itself by allowing for
authorizations to be named. Also support listing authorizations, so it's
easy to determine which key needs to be revoked, rotated, or otherwise
updated. See the manpage updates for details on use.

Resolve rubygems#364

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
Sequel.migration do
change do
alter_table :authorizations do
add_column :name, String, :size => 191
Copy link
Member

Choose a reason for hiding this comment

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

Size seems oddly specific, am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha! We share that thought. I was honestly just duplicating the existing pattern for String columns in the authorizations table, because they're magic numbers there as well. This number means nothing to me. Would you prefer something different?

Copy link
Member

Choose a reason for hiding this comment

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

I learned, by inspecting the git blame navigation: #64

it "combined with --list results in an error" do
cli_options[:list] = true
expect { Gemstash::CLI::Authorize.new(cli).run }.to raise_error(Gemstash::CLI::Error)
expect(Gemstash::Authorization["auth-key"]).to be # Auth was not actually removed
Copy link
Member

Choose a reason for hiding this comment

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

TIL about this very bare form of Matcher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same. I stole it from another test! One of the beautiful things about open source ❤️ .

expect { Gemstash::CLI::Authorize.new(cli).run }.to raise_error(Gemstash::CLI::Error)
end

it "handles missing authorization" do
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should express "raises an error on missing" so that we describe its behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, fixed.

Copy link
Member

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Wonderful, thank you! A thorough feature, well-described. @kyrofa, this is good.

Edit: if you please, add a CHANGELOG description, should you have one.

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
@kyrofa
Copy link
Contributor Author

kyrofa commented Sep 26, 2023

Edit: if you please, add a CHANGELOG description, should you have one.

Done, does that look right?

Signed-off-by: Kyle Fazzari <kyrofa@ubuntu.com>
@kyrofa kyrofa force-pushed the feature/364/gemstash-auth-names branch from 71e71a8 to 0086bef Compare September 26, 2023 15:29
Copy link
Member

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Grand, let's get this one out!

@olleolleolle olleolleolle merged commit 92f8bdc into rubygems:main Sep 27, 2023
@kyrofa kyrofa deleted the feature/364/gemstash-auth-names branch September 27, 2023 15:14
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.

Authorization tokens are easy to lose track of
2 participants