MyHomeworkSpace / client

The MyHomeworkSpace client.
MIT License
4 stars 4 forks source link

WebAuthn Support #153

Open willbarkoff opened 3 years ago

willbarkoff commented 3 years ago

It would be amazing if we could support hardware tokens with U2F :lock:.

willbarkoff commented 3 years ago

Ok, so looking into this it really doesn't seem too hard. The two main go libraries to do this are duo-labs/webauthn and koesie10/webauthn. JS implements it really nicely (https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API).

The only issue is actually debugging this. You need a secure context, and the way that we currently do local development, it isn't considered a secure context. (This was actually the main thing stopping me from doing #87).

Looking into this a bit more, it's actually not too hard. You need to generate a local certificate and have your computer trust it. Instructions are here, and I'll probably add them to the README at some point.

thatoddmailbox commented 3 years ago

Alternatively, if you're using Chrome, you can go to chrome://flags and add "http://app.myhomework.invalid" to the list of "Insecure origins treated as secure". There's also probably a Firefox alternative with about:config.

willbarkoff commented 3 years ago

Turns out it wasn't too hard at all :)

image

I'll add instructions to the README

willbarkoff commented 3 years ago

I've implemented like half of this so far. The current plan is that a user must have TOTP setup to set up WebAuthn. A user may have both TOTP and WebAuthn setup. A user cannot have WebAuthn setup without TOTP.

Here's what's been done so far, and what needs to be done:

Since these features aren't finished yet, I've pushed them to MyHomeworkSpace/client@webauthn and MyHomeworkSpace/api-server@webauthn