[PR #6262] [MERGED] Fix sso_user dropped on User::save #21952

Closed
opened 2026-04-30 08:18:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/6262
Author: @Timshel
Created: 9/1/2025
Status: Merged
Merged: 10/13/2025
Merged by: @BlackDex

Base: mainHead: fix/association


📝 Commits (4)

  • e4e5a40 Admin delete SSO association prompt
  • 5cb8fee User.save don't use replace_into
  • 113a5ca User.save use upsert with sqlite
  • ba6176d User.save use upsert with mysql

📊 Changes

2 files changed (+11 additions, -18 deletions)

View changed files

📝 src/db/models/user.rs (+9 -16)
📝 src/static/scripts/admin_users.js (+2 -2)

📄 Description

Should fix https://github.com/dani-garcia/vaultwarden/issues/6179#issuecomment-3242088962 and https://github.com/dani-garcia/vaultwarden/issues/6253

The issue is that if there is no ForeignKeyViolation a User::save first delete the record with sqlite and mysql.

Since the sso_user table was added with ON UPDATE CASCADE ON DELETE CASCADE, the violation was not triggered and the entry was deleted.

I thought changing the save logic was better than changing the cascade logic since :

  • Especially for users update is the happy path (as opposed to the violation being triggered in most cases).
  • It does not prevent using cascade
  • Less of a trap (it was missed during the review and testing, running with SSO_SIGNUPS_MATCH_EMAIL the association was just restored).

Made the change only for User but it probably would apply to most table.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/6262 **Author:** [@Timshel](https://github.com/Timshel) **Created:** 9/1/2025 **Status:** ✅ Merged **Merged:** 10/13/2025 **Merged by:** [@BlackDex](https://github.com/BlackDex) **Base:** `main` ← **Head:** `fix/association` --- ### 📝 Commits (4) - [`e4e5a40`](https://github.com/dani-garcia/vaultwarden/commit/e4e5a400ba2014adfb8bf4bc48f6d98d57edd09e) Admin delete SSO association prompt - [`5cb8fee`](https://github.com/dani-garcia/vaultwarden/commit/5cb8fee0add8ee78440d13f9a3d28bfcdd89d6c5) User.save don't use replace_into - [`113a5ca`](https://github.com/dani-garcia/vaultwarden/commit/113a5cae9f45a2aa48af284838d54603f3cb58d3) User.save use upsert with sqlite - [`ba6176d`](https://github.com/dani-garcia/vaultwarden/commit/ba6176d36d40aa4174da6d39f6aea9aa9fd78909) User.save use upsert with mysql ### 📊 Changes **2 files changed** (+11 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/db/models/user.rs` (+9 -16) 📝 `src/static/scripts/admin_users.js` (+2 -2) </details> ### 📄 Description Should fix https://github.com/dani-garcia/vaultwarden/issues/6179#issuecomment-3242088962 and https://github.com/dani-garcia/vaultwarden/issues/6253 The issue is that if there is no `ForeignKeyViolation` a `User::save` first delete the record with `sqlite` and `mysql`. Since the `sso_user` table was added with `ON UPDATE CASCADE ON DELETE CASCADE`, the violation was not triggered and the entry was deleted. I thought changing the `save` logic was better than changing the cascade logic since : - Especially for users `update` is the happy path (as opposed to the violation being triggered in most cases). - It does not prevent using cascade - Less of a trap (it was missed during the review and testing, running with `SSO_SIGNUPS_MATCH_EMAIL` the association was just restored). Made the change only for `User` but it probably would apply to most table. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 08:18:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#21952