-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add FIDO2 passwordless login support with security keys #16
base: master
Are you sure you want to change the base?
Conversation
petschekr
commented
Aug 24, 2019
- Adds support for logging in with FIDO2 security keys without a password 🎉
- Test using a compatible security that can perform User Verification in addition to User Presence (i.e. YubiKey 5 series vs YubiKey 4 series)
- Minor unrelated bug fixes
- Logging in with [email protected] for the CAS now provides a better error message with log out link
- Missing MIME types for static content have been added
public readonly passportStrategy: Strategy; | ||
private readonly timeout = 60000; // 60 seconds | ||
private readonly fidoInstance = new Fido2Lib({ | ||
cryptoParams: [-7], // ECC only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document why this is -7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I find this weird too but it's a spec thing:
The alg is a number described in the COSE registry; for example, -7 indicates that the server accepts Elliptic Curve public keys using a SHA-256 signature algorithm
done(null, false, { "message": "Registration timed out. Please try again." }); | ||
return; | ||
} | ||
let email = session.email.trim().toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a standard email sanitizer for all strategies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will add
origin: createLink(request, "").slice(0, -1), // Removes trailing slash from origin | ||
factor: "first", | ||
publicKey: user.services.fido2.publicKey || "", | ||
prevCounter: user.services.fido2.prevCounter || Number.MAX_SAFE_INTEGER, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why Number.MAX_SAFE_INTEGER?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that the counter prevents replay attacks because it must always be increasing. If we stored that the last auth was with counter set to 100, a replay of 100 or anything less than that will be rejected. If the prevCounter
value is undefined or null for some reason, we set it to the maximum allowed number in JS so that the auth attempt will be rejected.
done(null, false, { "message": "Invalid session values" }); | ||
return; | ||
} | ||
if (Date.now() >= (session.fidoChallengeTime || 0) + this.timeout) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this logic to the top level of the passport callback since it's repeated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
Fun fact: Chrome on Android allegedly implements FIDO2 but cannot unlock the YubiKey due to a bug in Google Play Services (tracking issue I filed: https://bugs.chromium.org/p/chromium/issues/detail?id=997538) causing our site to reject the login attempt. As I see it, we have two options:
|