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

WebAuthn integration #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

apowers313
Copy link

Two major updates:

  1. Added setup functionality to main BobPay page (register and delete all registrations)
  2. Added WebAuthn to payment button

Two major flaws to be solved:

  1. This is currently running off Git CDN pointed to my personal repo for the FIDO functionality. Not ideal (and hopefully not much traffic or GitHub will be mad). I'm open to either committing the file locally, doing a git submodule, or switching Git CDN to the "release" URL they like people to use. For now, it makes for easy development.
  2. If WebAuthn fails during payment, it just throws an error. I'm guessing that it'd be nicer to show an error and retry, but I'm not sure the preferred way of doing that. Alternatively we could just make the payment fail, if that's easier. Let me know.

Caveat: WebAuthn isn't currently working on my phone due to SafetyNet issues, so I haven't been able to test this out on a mobile device. Development was done with Firefox on the desktop, and the arguments passed to WebAuthn are probably wrong for Chrome. I'll update my FIDO repo with the correct WebAuthn functionality once I have a working phone.

@madmath
Copy link
Collaborator

madmath commented Oct 13, 2017

HI Adam,

Since BobPay is meant to be sample code for a payment app, I would rather have two versions. The current one at /pay, and one that supports authn at /pay-authn for example. It leads to code duplication, but at least people will know where to look. It shouldn't be too much work to duplicate the registration links and functions. Let me know if that's ok with you.

@rsolomakhin
Copy link
Collaborator

@madmath How would the payment handler know to open /pay-authn instead of /pay?

@madmath
Copy link
Collaborator

madmath commented Oct 14, 2017

Sorry if I was unclear, I meant that there would be two payment apps on bobpay.xyz. One at /pay and the other at /pay-authn, installable separately and usable separately too.


paymentRequestClient.postMessage(paymentAppResponse);
window.close();
var authn = new WebAuthnTransaction();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we should feature-detect for web authentication functionality to avoid breaking the demo for those who don't have it turned on:

if (window.WebAuthnTransacttion) {
  var authn = new WebAuthnTransaction();
  // Web Authentication flow.
} else {
  var paymentAppResponse = {
  // The existing flow without Web Authentication.
}

@@ -225,6 +225,14 @@ <h2 class="section-heading">Install BobPay</h2>
</p>
<input id="alipay" type="checkbox" value="">AliPay</label>
<p id="bobpayerror" class="error-message"></p>
<br>
<br>
<h2 class="section-heading">Setup FIDO / WebAuthn</h2>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's put the WebAuthn code into a <div id="webauthn"> and show it only if Web Authentication is enabled.

<div id="webauthn" style="display: none;">
  ...
</div>
<script>
  if (window.WebAuthnTransaction) {
    document.getElementById('webauthn').style.display = 'block';
  }
</script>

@rsolomakhin
Copy link
Collaborator

@madmath Do you think a single payment app would be more manageable with feature-detection for Web Authentication?

@madmath
Copy link
Collaborator

madmath commented Oct 14, 2017

Sorry to disappoint, I don't. The goal for BobPay is to provide the canonical sample for Payment Handler, and in its vanilla form I don't think we should include other code that conflate it with WebAuthn, and make the example less understandable. What's the problem with installing either one of two apps?

  1. BobPay (/pay)
  2. BobPay with WebAuthn! (/pay-authn)

Duplicate the "pay" folder to "pay-authn" and provide two links at the bottom of BobPay.xyz so that people can choose which they want to register.

@rsolomakhin
Copy link
Collaborator

OK, let's go with two separate apps, @madmath.

@apowers313
Copy link
Author

In that case should I just maintain my fork separately? Makes maintenance easier (i.e. - merge upstream changes) and I can add you guys as contributors if you need any control.

@rsolomakhin
Copy link
Collaborator

@apowers313 If maintaining a fork is easier for you, go for it. We don't require control.

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