cedarcode / webauthn-rails-demo-app

Rails app demonstrating a WebAuthn password-less login
https://webauthn.cedarcode.com
Apache License 2.0
99 stars 39 forks source link

atob fails on user ids with underscores #66

Closed ghost closed 4 years ago

ghost commented 5 years ago

The Encoder uses atob to encode a user id into a ByteArray. This fails on usernames with underscores like cool_dude_123 (which could be a unique username used by an application).

Uint8Array.from should work here for encoding strings with underscores.

user: {
    id: Uint8Array.from(
        "UZSL85T9AFC", c => c.charCodeAt(0)),
    name: "lee@webauthn.guide",
    displayName: "Lee",
 }

This was taken from Duo Security's great writeup on Webauthn.

grzuy commented 5 years ago

Hi @tomek-bt,

Thanks for the issue report! Sorry I am not sure I totally understand what the issue is...

Are you saying that if you try register with username cool_dude_123, the registration doesn't work? If that's what you saying I am not able to reproduce that, can you?

ghost commented 5 years ago

ahh maybe I went about this the wrong way. I dropped into a Javascript console and pasted the function

  function strToBin(str) {
    console.log(str);
    return Uint8Array.from(atob(str), c => c.charCodeAt(0));
  }

Then tried strToBin('foo_bar'), but I can't seem to reproduce this in the web app atob-error

grzuy commented 5 years ago

Gotcha.