Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 Add WebAuthn verification URL endpoint by jchestershopify · Pull Request #3305 · rubygems/rubygems.org · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

jchestershopify
Copy link
Contributor
@jchestershopify jchestershopify commented Dec 21, 2022
8000

What problem are you solving?

This PR primarily intendeds to add an endpoint to be consumed by the CLI during the WebAuthn verification flow.

Part of #3298, which adds WebAuthn verification support to the CLI. It builds on the WebauthnVerification model introduced in Shopify#76.

Added in this PR:

  • /api/v1/webauthn_verification
  • WebauthnVerificationController
  • WebauthnUserMethods#refresh_webauthn_verification

Note: The hostname in generated URLs is hardcoded to example.com, pending followup to use Rails config.

What approach did you choose and why?

The approach here is a standard Rails controller, with a singular route. This is because only one verification per User will be valid at a time. Each time a verification path is requested, the relevant path_token is reset.

Logic for creating the WebauthnVerification is located in the UserWebauthnMethods module. While the underlying data for a verification is properly separated from the User (not all users will have a current verification), the User acts as a natural point at which to request that a new WebauthnVerification be created.

What should reviewers focus on?

The tests were inspired by the tests in ApiKeysControllerTest, with scenarios removed that didn't make sense (for example, requiring an OTP code doesn't make sense during the Webauthn verification process). I am keen to get feedback on whether the tests have overlooked key scenarios.

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>

def refresh_webauthn_verification
self.webauthn_verification = WebauthnVerification.create(
path_token: SecureRandom.base58(16),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Base 58 chosen because it plays nicely with manually typing in the code and also with direct copy & paste action. 16 characters doesn't impose an undue burden on folks manually typing, but gives a large search space (58^16 ≈ 1.64×10²⁸) that attackers would need to search to find the path token.

should respond_with :success

should "return Webauthn verification URL with path token" do
response = YAML.load(@response.body)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike the API key controller, we assume for now that YAML is the only supported format. We can add JSON later if necessary, but at the moment this endpoint is only intended for the use of the CLI.

@codecov
Copy link
codecov bot commented Dec 21, 2022

Codecov Report

Merging #3305 (ef3bb54) into webauthn-cli (91f0784) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@              Coverage Diff              @@
##           webauthn-cli    #3305   +/-   ##
=============================================
  Coverage         98.52%   98.53%           
=============================================
  Files               114      115    +1     
  Lines              3396     3412   +16     
=============================================
+ Hits               3346     3362   +16     
  Misses               50       50           
Impacted Files Coverage Δ
...ollers/api/v1/webauthn_verifications_controller.rb 100.00% <100.00%> (ø)
app/models/concerns/user_webauthn_methods.rb 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

It's unclear why this ordering is meaningful to Rails and also
unclear how it evaded the tests. Next order of business is working
out to test to ensure this ordering is not broken in future.
@aellispierce aellispierce requested a review from simi December 22, 2022 17:56
@jchestershopify
Copy link
Contributor Author
jchestershopify commented Dec 22, 2022

@aellispierce looking at ruby/rubygems#6179, I'm wondering if it makes sense for the WebauthnVerificationController#create to include a hostname in the response. In the client (Gem::GemcutterUtilities#rubygems_api_request) it seems to work by taking just the path, not the full URL.

Edit: specifically at L104 in rubygems_api_request.

@aellispierce
Copy link
Member

I'm wondering if it makes sense for the WebauthnVerificationController#create to include a hostname in the response. In the client (Gem::GemcutterUtilities#rubygems_api_request) it seems to work by taking just the path, not the full URL.

@jchestershopify The rubygems_api_request takes the path because you could be sending the request to a different gem host beyond standard rubygems.org (like staging, localhost, your own private gem host, etc), and we want the request to be sent to whatever host you specify.

While we could recreate the full URL on the client, since the client knows the host you're interacting with, that seems more error prone to me and I'm not sure I see the benefit? It'd be an extra step of us having to reconstruct the full url in the client to give to the user instead of just plopping in the response directly from the API. And while we want dynamic hosts when we send requests, we couldn't receive some sort of dynamic host webauthn url. Like a webauthn token created on rubygems.org would not work on localhost:3000 or myprivategemhost.org so we don't need the flexibility of the client being able to create a link with whatever host you've specified.

@jchestershopify
Copy link
Contributor Author

That makes sense, thanks for walking me through it!

Copy link
Member
@aellispierce aellispierce left a comment

Choose a reason for hiding this comment

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

Thanks for all your work on this! 🚀

@aellispierce aellispierce merged commit b96ff1a into rubygems:webauthn-cli Dec 23, 2022
jenshenny pushed a commit that referenced this pull request Jan 12, 2023
* Add WebAuthn verification URL endpoint

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
jenshenny pushed a commit that referenced this pull request Jan 24, 2023
* Add WebAuthn verification URL endpoint

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
jenshenny pushed a commit that referenced this pull request Feb 14, 2023
* Add WebAuthn verification URL endpoint

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
jenshenny pushed a commit that referenced this pull request Apr 4, 2023
* Add WebAuthn verification URL endpoint

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
jenshenny pushed a commit that referenced this pull request Apr 4, 2023
* Add WebAuthn verification URL endpoint

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
jenshenny pushed a commit that referenced this pull request Apr 6, 2023
* Add WebAuthn verification URL endpoint

Hardcoded hostname to example.com, pending followup to use Rails config.

- Add /api/v1/webauthn_verification
- Add WebauthnVerificationController
- Add WebauthnUserMethods#refresh_webauthn_verification

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
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.

2 participants

0