-
Notifications
You must be signed in to change notification settings - Fork 21
Totp MFA Database Design #297
Comments
(@vbudhram by the way, I made an "MFA" milestone to link all the breakdown issues here together) |
Thank you! When you get a chance mind taking a look through? |
Hrm, turns out it's not as easy to review things in an issue as it is in a PR :-) This mostly looks good to me, some random thoughts from my initial read-through:
Ultimately I think we'll have to iterate both this and mozilla/fxa-auth-server#2262 a bit concurrently during implementation, but 👍 to the general shape of this so far. |
I'll put up a PR to reflex change so that we could iterate a little quicker.
Agreed, we can use the (uid, codeHash) combo.
Didn't really think of that, but no they are not. I would say that recovery code is its own type of verification method. I will make table generic to reflect that.
I like
My line of thought here was that by always pulling back the totp information we would always know whether or not to display screen. One solution might be to add a
Yea, think we should only support one totp per user.
👍🏽
Will add! |
Are there other modules we can take a look at? I'm concerned that the SpeakEasy module doesn't work with Authy ( speakeasyjs/speakeasy#95 ) |
@vladikoff That is interesting, I originally planned to prototype with speakeasy, but can build using the otplib. I am also not opposed to writing our own TOTP library. |
After working through this, opting to break this issue up into three separate and independent ones.
|
fxa-auth-db-mysql
This issue outlines specific engineering database tasks needed to support TOPT based multifactor authentication.
At a high level, TOTP data is returned in
sessionTokenWithVerificationStatus
and actual token verification is done in the auth-server via Speakeasy module.New Tables
Totp Table
Totp Recovery Code Table
Alter Tables
Sessions Table
email-2fa, totp-2fa
New stored procedures
.createTotpToken(uid, shared_secret, epoch)
Parameters:
defaults to 0
Returns:
{}
.generateTotpRecoveryCodes(uid)
Deletes all current recovery codes for uid and generates now ones.
Parameters:
Returns:
.consumeTotpRecoveryCode(uid, codeHash)
Consumes the recovery code and deletes from table if successful.
Parameters:
Returns:
{}
error.notFound()
Alter stored procedures
.sessionTokenWithVerificationStatus(id)
Parameters:
tokenId
- (Buffer32) the id of the token to retrieveReturns:
{ ... }
anderror.notFound()
if this token does not existerror.wrap()
New endpoints
Create TOTP Code
PUT
/totp/<uid>
uid
: hex128shared_secret
: stringepoch
: epochGenerate recovery codes
POST
/totp/<uid>/recoveryCodes/generate
uid
: stringConsume recovery codes
PUT
/totp/<uid>/recoveryCodes
uid
: hex128code
: stringThe text was updated successfully, but these errors were encountered: