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

Document/suggest how to send ArrayBuffer data #79

Closed
lgarron opened this issue Oct 3, 2018 · 2 comments · Fixed by #85
Closed

Document/suggest how to send ArrayBuffer data #79

lgarron opened this issue Oct 3, 2018 · 2 comments · Fixed by #85
Assignees

Comments

@lgarron
Copy link
Contributor

lgarron commented Oct 3, 2018

The documentation on this project includes such examples as:

authenticator_data = "..." # As returned by `navigator.credentials.get`

This doesn't make sense on its own, because WebAuthn mostly uses ArrayBuffers to send/receive data, and those can't be sent over the wire and received in Ruby natively like a string or an array. Different applications handle this differently:

https://github.com/cedarcode/webauthn-rails-demo-app encodes from/to ArrayBuffer by mapping the bytes to 8-bit ASCII:

https://github.com/cedarcode/webauthn-rails-demo-app/blob/3afc964edfd3efeb4ad161d4b08a434e8370fd7a/app/assets/javascripts/application.js#L37-L46

https://github.com/duo-labs/webauthn uses websafe/urlsafe base 64 (and hex):

https://github.com/duo-labs/webauthn/blob/fa6cd954884baf24fc5a51656ce21c1a1ef574bc/static/js/webauthn.js#L227-L231

I think either an ASCII string or regular base 64 would be preferable, assuming the former has no compatibility issues with most JSON transports. In addition, it would be nice if there was a way to "directly" read a response from the client, like the load_from_json method in https://github.com/castle/ruby-u2f , since pretty much every client of the library is going to have to do something similar.

So:

  1. Are you willing to stick with a particular encoding suggestion?
  2. Would you be willing to add a convenience method for constructing the AuthenticatorResponse classes from JSON?
@grzuy grzuy self-assigned this Oct 6, 2018
@grzuy
Copy link
Contributor

grzuy commented Oct 6, 2018

The documentation on this project includes such examples as:

authenticator_data = "..." # As returned by `navigator.credentials.get`

This doesn't make sense on its own, because WebAuthn mostly uses ArrayBuffers to send/receive data, and those can't be sent over the wire and received in Ruby natively like a string or an array. Different applications handle this differently:

True. This is a bit confusing. Needs an update.

We should say something like those arguments are expected to be ruby strings with binary encoding, like ASCII-8BIT.

I think either an ASCII string or regular base 64 would be preferable, assuming the former has no compatibility issues with most JSON transports. In addition, it would be nice if there was a way to "directly" read a response from the client, like the load_from_json method in https://github.com/castle/ruby-u2f , since pretty much every client of the library is going to have to do something similar.

So:

  1. Are you willing to stick with a particular encoding suggestion?

  2. Would you be willing to add a convenience method for constructing the AuthenticatorResponse classes from JSON?

So, we had some of that baked into the main public API, but we removed it #48 to let the gem be user-agent agnostic.

Providing convenience methods instead of baking it in the main API should be definitely something to consider.

@grzuy
Copy link
Contributor

grzuy commented Oct 7, 2018

Closed this one after merging update/clarification to the README.

Created separate issue talking about your request for a convenience method: #87.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants