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

Callback handling - why base64 encode rawId instead of using id #119

Closed
truongnmt opened this issue Jul 21, 2021 · 2 comments
Closed

Callback handling - why base64 encode rawId instead of using id #119

truongnmt opened this issue Jul 21, 2021 · 2 comments

Comments

@truongnmt
Copy link

truongnmt commented Jul 21, 2021

First, thanks for the implementation! Carefully written, also the test was really helpful!

By the way, when I read the credential callback implementation:

external_id: Base64.strict_encode64(webauthn_credential.raw_id)

Why do we have to base64 encode the rawId? Why not use webauthn_credential.id straight away?
As written in spec, id is base64(rawId) already. By manually base64(rawId) and save it to the database, what benefit do we have over saving id?
https://www.w3.org/TR/credential-management-1/#dom-credential-id

Beside, in session_controller we use the base64 encoded rawId to create allow list and send to authenticator.

get_options = WebAuthn::Credential.options_for_get(allow: user.credentials.pluck(:external_id))

So overall, save id returned from authenticator then using that id to send back to authenticator make sense to me.

@Brantron
Copy link

Great callout, after using this template as inspiration for my own implementation I came back to make this same issue. Hopefully folks in the future will see this and understand that they can simplify the implementation a bit by using id and not manually encoding the raw_id

@rromanchuk
Copy link

@Brantron have you seen a refreshed implementation on the client side anywhere? I don't use UJS, only Turbo + Stimulus, so I need to refactor all the xhr eventing.

I suppose I should just start fresh, using https://github.com/github/webauthn-json/blob/main/src/dev/demo/index.ts as a guide

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

No branches or pull requests

3 participants