2FA failed with DatabaseError #640

Closed
opened 2026-02-04 21:59:40 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @j4y4r on GitHub (Mar 13, 2020).

Subject of the issue

I have an issue when trying to add 2FA via a solo tab security key.
After activation i can't login because of an database error.

Your environment

  • Bitwarden_rs version: Version 2.12.0

  • Install method: packages from aur(archlinux)

  • Clients used: Vivaldi | 2.11.1811.28

  • Reverse proxy and version: Apache/2.4.41

  • Version of mysql/postgresql: 12.1 postgresql

  • Other relevant information:

Steps to reproduce

he 2FA has been enabled via the Web Interface, added the device, clicked the button on the key and everything seems fine.
After logout and trying to login with my credentials the Webinterface now wants me to tab the key, after doing so an error appears.

Expected behaviour

Enabling a FIDO2 device and logging in to the Webinterface.

Actual behaviour

Databse contstraint error.

Relevant logs

I found this in the sever log when taping the key

[2020-03-13 09:19:23][request][INFO] POST /identity/connect/token
2020-03-13 09:19:24.018 CET [810257] ERROR:  duplicate key value violates unique constraint "twofactor_user_uuid_atype_key"
2020-03-13 09:19:24.018 CET [810257] DETAIL:  Key (user_uuid, atype)=(xxx, 4) already exists.
2020-03-13 09:19:24.018 CET [810257] STATEMENT:  INSERT INTO "twofactor" ("uuid", "user_uuid", "atype", "enabled", "data", "last_used") VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT ("uuid") DO UPDATE SET "user_uuid" = $7, "atype" = $8, "enabled" = $9, "data" = $10, "last_used" = $11
[2020-03-13 09:19:24][error][ERROR] Error saving twofactor.
[CAUSE] DatabaseError(
     UniqueViolation,
     "duplicate key value violates unique constraint \"twofactor_user_uuid_atype_key\"",
 )
 [2020-03-13 09:19:24][response][INFO] POST /identity/connect/token (login) => 400 Bad Request
 [2020-03-13 09:19:24][error][ERROR] Error saving twofactor.
                                           [CAUSE] DatabaseError(
                                               UniqueViolation,
                                               "duplicate key value violates unique constraint \"twofactor_user_uuid_atype_key\"",
                                           )
 [2020-03-13 09:19:24][response][INFO] POST /identity/connect/token (login) => 400 Bad Request
Originally created by @j4y4r on GitHub (Mar 13, 2020). ### Subject of the issue I have an issue when trying to add 2FA via a solo tab security key. After activation i can't login because of an database error. ### Your environment * Bitwarden_rs version: Version 2.12.0 * Install method: packages from aur(archlinux) * Clients used: Vivaldi | 2.11.1811.28 * Reverse proxy and version: Apache/2.4.41 * Version of mysql/postgresql: 12.1 postgresql * Other relevant information: ### Steps to reproduce he 2FA has been enabled via the Web Interface, added the device, clicked the button on the key and everything seems fine. After logout and trying to login with my credentials the Webinterface now wants me to tab the key, after doing so an error appears. ### Expected behaviour Enabling a FIDO2 device and logging in to the Webinterface. ### Actual behaviour Databse contstraint error. ### Relevant logs I found this in the sever log when taping the key ``` [2020-03-13 09:19:23][request][INFO] POST /identity/connect/token 2020-03-13 09:19:24.018 CET [810257] ERROR: duplicate key value violates unique constraint "twofactor_user_uuid_atype_key" 2020-03-13 09:19:24.018 CET [810257] DETAIL: Key (user_uuid, atype)=(xxx, 4) already exists. 2020-03-13 09:19:24.018 CET [810257] STATEMENT: INSERT INTO "twofactor" ("uuid", "user_uuid", "atype", "enabled", "data", "last_used") VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT ("uuid") DO UPDATE SET "user_uuid" = $7, "atype" = $8, "enabled" = $9, "data" = $10, "last_used" = $11 [2020-03-13 09:19:24][error][ERROR] Error saving twofactor. [CAUSE] DatabaseError( UniqueViolation, "duplicate key value violates unique constraint \"twofactor_user_uuid_atype_key\"", ) [2020-03-13 09:19:24][response][INFO] POST /identity/connect/token (login) => 400 Bad Request [2020-03-13 09:19:24][error][ERROR] Error saving twofactor. [CAUSE] DatabaseError( UniqueViolation, "duplicate key value violates unique constraint \"twofactor_user_uuid_atype_key\"", ) [2020-03-13 09:19:24][response][INFO] POST /identity/connect/token (login) => 400 Bad Request ```
Author
Owner

@mqus commented on GitHub (Mar 13, 2020):

It seems that you have the same problem as #635, which was fixed in the master branch but didn't get a release yet...

@dani-garcia Could we get a release? The last one was at the start of January...

In the meantime, you could try to use https://aur.archlinux.org/packages/bitwarden_rs-git/ and modify it to use postgresql... but if you can wait, I would recommend you to wait.

Edit:fixed issue reference, thanks ;)

@mqus commented on GitHub (Mar 13, 2020): It seems that you have the same problem as #635, which was fixed in the master branch but didn't get a release yet... @dani-garcia Could we get a release? The last one was at the start of January... In the meantime, you could try to use https://aur.archlinux.org/packages/bitwarden_rs-git/ and modify it to use postgresql... but if you *can* wait, I would recommend you to wait. Edit:fixed issue reference, thanks ;)
Author
Owner

@dani-garcia commented on GitHub (Mar 13, 2020):

I think you mean #635, but yeah this is probably the same issue, I've created a new release thanks for reminding me!

Once it's built this should be solved.

@dani-garcia commented on GitHub (Mar 13, 2020): I think you mean #635, but yeah this is probably the same issue, I've created a new release thanks for reminding me! Once it's built this should be solved.
Author
Owner

@j4y4r commented on GitHub (Mar 14, 2020):

i did not look at closed issues... 🤦‍♂️

@mqus
of course i could not wait and modified the existing postgres aur package to use the latest release.

@dani-garcia
thanks for you quick answer and the new release, this issue is now fixed, i was able to login using the solo key :)

@j4y4r commented on GitHub (Mar 14, 2020): i did not look at closed issues... :man_facepalming: @mqus of course i could not wait and modified the existing postgres aur package to use the latest release. @dani-garcia thanks for you quick answer and the new release, this issue is now fixed, i was able to login using the solo key :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#640