Bubka / 2FAuth

A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
https://docs.2fauth.app/
GNU Affero General Public License v3.0
2.28k stars 152 forks source link

import 2FAS #277

Closed captainabloc closed 10 months ago

captainabloc commented 10 months ago

Version

5.0.2

Details & Steps to reproduce

Hi Everyone,

trying to import a 2fas file with the following scheme: "schemaVersion":4,"appVersionCode":5000012,"appVersionName":"5.2.0","appOrigin":"android" leads to "server error" message.

how could I proceed?

image

Expectation

import data from 2fas-backup.2fas (not encrypted)

Error & Logs

[2024-01-10 12:04:58] local.ERROR: Undefined array key "algorithm" {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined array key \"algorithm\" at /srv/app/Services/Migrators/TwoFASMigrator.php:89)

Execution environment

docker-compose

Containerization

Additional information

data folder on debian machine located on /2fauth, docker-compose used, and up.

Bubka commented 10 months ago

Hi,

It's weird, your export file is missing a property normally available in 2FAs export. Could you open the 2fas file with a text editor and check how are composed the otp objects? They look like this, except that at least one of them does not contain the algorithm property:

"otp":
{
    "account": "My account",
    "digits": 6,
    "counter": 0,
    "period": 30,
    "algorithm": "SHA1",
    "tokenType": "TOTP"
}

How many don't have the algorithm property? For them, what is their tokenType?

captainabloc commented 10 months ago

Hi, I have 6 objects. Upon those 6, one only hasn't the algorithmproperty. this is the one for ssh totp:

otp{6}
link:otpauth://totp/account?secret=supersecret&issuer=access
label:ssh@access
account:myaccounts
issuer:access
tokenType:TOTP
source:Link

and indeed, this is the only one not having

    "digits": 6,
    "counter": 0,
    "period": 30,
    "algorithm": "SHA1",

infos

captainabloc commented 10 months ago

and nice catch! removing that one from the file makes it working!

thanks for the trick.

Do you, by chance, know a solution to get that one working too?

Bubka commented 10 months ago

This is what I'm currently looking for. For now all the exports I made with 2FAs always had these missing props.

Can you try this:

Do you get the same code? Is there anything special about how this ssh account was registered into 2FAs?

captainabloc commented 10 months ago

you rock! working perfect now, thanks and congrats for your project.