mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-02-05 00:29:40 +03:00
MySQL backend: Cannot share cipher with organisation #765
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @smerschjohann on GitHub (Aug 3, 2020).
Subject of the issue
If bitwarden_rs is used with mysql backend, it is not possible to share existing ciphers with an organisation.
Your environment
Server Installed 1.16.1
Server Latest 1.16.1
Web Installed 2.15.1
Web Latest 2.15.1
Bitwarden_rs version: In Openshift environment using docker image: bitwardenrs/server-mysql:1.16.1
Install method
Steps to reproduce
Expected behaviour
The cipher can be moved to the organisation.
Actual behaviour
the cipher cannot be stored because of a constraint violation.
Relevant logs
If the contraint is divided in update and delete constraints, it turns out that the delete contraint is violated:
It seems that the server wants to recreate the cipher in the database instead of updating it. By trying that, it violated the key constraints of the ciphers_collections.
It apperas that the folder_collection is also affected.
@smerschjohann commented on GitHub (Aug 3, 2020):
A possible workaround for now: Delete the constraint on the collection tables
@smerschjohann commented on GitHub (Aug 3, 2020):
The issue is the use of replace_into in all of the save() methods:
f724addf9a/src/db/models/user.rs (L186)f724addf9a/src/db/models/cipher.rs (L207)replace_into checks for constraint violations on delete: If there are foreign keys, ON DELETE action will be activated by REPLACE..
Instead of
REPLACE INTO, the use ofINSERT ... ON DUPLICATE KEY UPDATEshould fix the problem, but it seems unavailable in the diesel sdk.I think it cannot be done in a single statement using that framework.
@jobec commented on GitHub (Aug 9, 2020):
As with #1065 , if you switch to MariaDB 10.3 (e.g. image
mariadb:10.3) I'm guessing it'll be fixed.