Skip to content

πŸ§‘β€πŸ”¬ Prototype: Encourage MFA for owners of top 100 downloaded gems (CLI)#5

Closed
jenshenny wants to merge 6 commits into
masterfrom
encourage-mfa-cli
Closed

πŸ§‘β€πŸ”¬ Prototype: Encourage MFA for owners of top 100 downloaded gems (CLI)#5
jenshenny wants to merge 6 commits into
masterfrom
encourage-mfa-cli

Conversation

@jenshenny
Copy link
Copy Markdown

@jenshenny jenshenny commented Dec 14, 2021

Overview

This prototype relates to the stage of encouraging users to setup mfa in the proposed policy. The regular response is sent back with signin, push/yank gems, and add/remove owners actions along with a message (or warning) to encourage users to set up MFA.

Gem signin

This requires changes to the rubygems' gem signin command as the response from the rubygems.org API when creating an API key is the API key itself. Before creating an API key, an request is sent to api/v1/profile determine if MFA is enabled on the account, and if not, a message gets shown (see Shopify/rubygems#1). This applies to all users and not the targetted ones.

Screen Shot 2021-12-16 at 10 18 43 AM

Gem push/yank gems, and add/remove owners

A message is appended to the end of the response body of these commands. A warning cannot be appended before since these commands can check the beginning of the response body to determine certain states (eg. mfa unauthorized). This applies to users that have been targetted via the mfa_required? method (ie. most downloaded gem owners) on the user.

Screen Shot 2021-12-16 at 10 28 23 AM

aellispierce and others added 4 commits December 13, 2021 19:20
**What does this change do:**

Currently, a users profile can be queried by their id or handle
(`api/v1/profiles/:id|:handle`). This PR
adds the ability for an authenticated user to also query their own
profile without needing to know their id or pass their handle by
making an authenticated call to `api/v1/profile`.

**Why is this neccessary:**

Once MFA can be enabled on specific API keys through the
UI, a user should also be able to enable it on keys that they create
during `gem signin` in the CLI.

However, we only want to ask a user if they would like to enable mfa on
new keys if they have account mfa levels of `ui_only` or
`ui_and_gem_sign`. Users that have MFA disabled or those that have it
enabled for `ui_and_api ` should not be prompted, as it should be auto
enabled or disabled for those levels.

Once an owners mfa level can be queried through the
API, then enabling an authed user to pull their profile will return their MFA level and
help us determine if we should ask them to enable MFA on new keys
created during gem signin.
Comment on lines +2 to +22
before_action :set_user, only: [:show]

def show
@user = User.find_by_slug!(params[:id])
respond_to do |format|
format.json { render json: @user }
format.yaml { render yaml: @user }
end
end

private

def set_user
@user =
if params[:id]
User.find_by_slug!(params[:id])
else
authenticate_or_request_with_http_basic do |username, password|
User.authenticate(username.strip, password)
end
end
end
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Taken from #4

@jenshenny jenshenny requested a review from a team December 16, 2021 16:31
Copy link
Copy Markdown

@jchestershopify jchestershopify left a comment

Choose a reason for hiding this comment

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

Some suggested tweaks, but otherwise LGTM.

Comment thread app/controllers/api/base_controller.rb Outdated
Comment thread app/controllers/api/v1/deletions_controller.rb Outdated
Comment thread app/models/rubygem.rb Outdated
@bettymakes bettymakes changed the title πŸ§‘β€πŸ”¬ Prototype: Encourage MFA for owners of popular gems (CLI) πŸ§‘β€πŸ”¬ Prototype: Encourage MFA for owners of top 100 downloaded gems (CLI) Jan 7, 2022
@jenshenny
Copy link
Copy Markdown
Author

Closing in favor of #9 which uses the most up to date version of how we store and determine encouraging phase vs. the required phase.

@jenshenny jenshenny closed this Jan 12, 2022
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