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

[spaceship] Automate phone number selection for "request code via SMS" in 2FA with SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER env var #14436

Merged
merged 20 commits into from Apr 19, 2019

Conversation

janpio
Copy link
Member

@janpio janpio commented Mar 19, 2019

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

2FA with token entry is a hassle to fastlane users. Some use cases also force people to use trusted phone numbers instead of the usual pushed tokens, so we can streamline their workflow by allowing them to skip the pushed token and remove the necessary interaction to get a token sent to a specific phone number.

Description

The new environment variable SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER allows you to set a phone number, that is automatically used as the recipient of the 2FA token. You do not have to "escape" the normal input via inputting sms and then selecting your phone number from a dropdown any more.

Testing

I wrote a few tests for the specific methods I introduced that helped me to make sure they actually do what I expected them to do. Then I manually tested via bundle exec fastlane spaceauth as it basically just does the spaceship login - which is what this code impacts.

Unrelated changes

This PR also includes a little comment in the cert runner and changes the way fastlane spaceauth handles exceptions - before they were just swallowed, but as my new code raises one if it can't find the correct phone number, that was not very good for testing. Now they are bubbled up to the user.

closes #13980


Review Notes

  • I am not really happy with the code of phone_id_from_number, the way I find the phone_id for the value of the ENV variable via the regex pattern, and especially the way I build it looks really crap and complicated. Is there a better way to do this?
  • Does my spec file make sense? It worked for me when writing the initial code, but are those actually good tests? Should I do more here? The whole file was completely untested before. Now at least those two methods I touched are tested a tiny bit.

@janpio janpio changed the title [spaceship] Automate phone number selection for "request code via SMS" in 2FA [spaceship] Automate phone number selection for "request code via SMS" in 2FA with SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER env var Mar 19, 2019
@janpio janpio marked this pull request as ready for review March 22, 2019 16:29
@max-ott
Copy link
Contributor

max-ott commented Mar 22, 2019

Thanks for your great work @janpio 🙏 Will test this and give feedback. Is only running bundle exec fastlane spaceauth required to test this with having the right ENV set?

@janpio
Copy link
Member Author

janpio commented Mar 22, 2019

That should execute that code, yes. But testing in other circumstances (normal spaceship usage) is of course also welcome.

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

@janpio I left a few small suggestions about masking numbers and changing some of the CLI output but this is so 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

@janpio
Copy link
Member Author

janpio commented Apr 4, 2019

Documentation part of this PR is taken care of via #14524 which will create https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md

@janpio janpio force-pushed the janpio-spaceship_2fa_force_sms_with_number branch from eeef6e8 to 00da023 Compare April 18, 2019 09:03
and some empty lines for structure
Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

This is so goooooood! We are shipping this tomorrow 💪

@joshdholtz joshdholtz merged commit 483cf98 into master Apr 19, 2019
@joshdholtz joshdholtz deleted the janpio-spaceship_2fa_force_sms_with_number branch April 19, 2019 00:51
@fastlane-bot
Copy link

Hey @janpio 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.121.0 🚀

@fastlane fastlane locked and limited conversation to collaborators Jun 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[spaceship] Skip 2FA pushed token entry (to trusted phone selection), select correct phone no automatically
5 participants