[PR #3804] [MERGED] Fix External ID not set during DC Sync #12210

Closed
opened 2026-04-20 15:34:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/3804
Author: @BlackDex
Created: 8/27/2023
Status: Merged
Merged: 10/21/2023
Merged by: @dani-garcia

Base: mainHead: fix-3777


📝 Commits (1)

  • 18d6647 Fix External ID not set during DC Sync

📊 Changes

12 files changed (+75 additions, -40 deletions)

View changed files

migrations/mysql/2023-09-02-212336_move_user_external_id/down.sql (+0 -0)
migrations/mysql/2023-09-02-212336_move_user_external_id/up.sql (+2 -0)
migrations/postgresql/2023-09-02-212336_move_user_external_id/down.sql (+0 -0)
migrations/postgresql/2023-09-02-212336_move_user_external_id/up.sql (+2 -0)
migrations/sqlite/2023-09-02-212336_move_user_external_id/down.sql (+0 -0)
migrations/sqlite/2023-09-02-212336_move_user_external_id/up.sql (+2 -0)
📝 src/api/core/public.rs (+31 -17)
📝 src/db/models/organization.rs (+33 -3)
📝 src/db/models/user.rs (+2 -20)
📝 src/db/schemas/mysql/schema.rs (+1 -0)
📝 src/db/schemas/postgresql/schema.rs (+1 -0)
📝 src/db/schemas/sqlite/schema.rs (+1 -0)

📄 Description

While working on the fix for #3777 I realized the location where the external_id
is stored was wrong. It was stored in the users table, but it actually
should have been stored in the users_organizations table.

This will move the column to the right table. It will not move the
values of the external_id column, because if there are more
organizations, there is no way to really know which organization it is
linked to. Setups using the Directory Connector can clear the sync
cache, and sync again, that will store all the external_id values at
the right location.

Also changed the function to revoke,restore an org-user and set_external_id to return a boolean.
It will state if the value has been changed or not, and if not, we can
prevent a save call to the database.

The users table is not changed to remove the external_id column, thi
to prevent issue when users want to revert back to an earlier version
for some reason. We can do this after a few minor release i think.

Fixes #3777


🔄 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/3804 **Author:** [@BlackDex](https://github.com/BlackDex) **Created:** 8/27/2023 **Status:** ✅ Merged **Merged:** 10/21/2023 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `main` ← **Head:** `fix-3777` --- ### 📝 Commits (1) - [`18d6647`](https://github.com/dani-garcia/vaultwarden/commit/18d66474e01ce931cdf9c84b6ebc6f91e996ec18) Fix External ID not set during DC Sync ### 📊 Changes **12 files changed** (+75 additions, -40 deletions) <details> <summary>View changed files</summary> ➕ `migrations/mysql/2023-09-02-212336_move_user_external_id/down.sql` (+0 -0) ➕ `migrations/mysql/2023-09-02-212336_move_user_external_id/up.sql` (+2 -0) ➕ `migrations/postgresql/2023-09-02-212336_move_user_external_id/down.sql` (+0 -0) ➕ `migrations/postgresql/2023-09-02-212336_move_user_external_id/up.sql` (+2 -0) ➕ `migrations/sqlite/2023-09-02-212336_move_user_external_id/down.sql` (+0 -0) ➕ `migrations/sqlite/2023-09-02-212336_move_user_external_id/up.sql` (+2 -0) 📝 `src/api/core/public.rs` (+31 -17) 📝 `src/db/models/organization.rs` (+33 -3) 📝 `src/db/models/user.rs` (+2 -20) 📝 `src/db/schemas/mysql/schema.rs` (+1 -0) 📝 `src/db/schemas/postgresql/schema.rs` (+1 -0) 📝 `src/db/schemas/sqlite/schema.rs` (+1 -0) </details> ### 📄 Description While working on the fix for #3777 I realized the location where the `external_id` is stored was wrong. It was stored in the `users` table, but it actually should have been stored in the `users_organizations` table. This will move the column to the right table. It will not move the values of the `external_id` column, because if there are more organizations, there is no way to really know which organization it is linked to. Setups using the Directory Connector can clear the sync cache, and sync again, that will store all the `external_id` values at the right location. Also changed the function to revoke,restore an org-user and set_external_id to return a boolean. It will state if the value has been changed or not, and if not, we can prevent a `save` call to the database. The `users` table is not changed to remove the `external_id` column, thi to prevent issue when users want to revert back to an earlier version for some reason. We can do this after a few minor release i think. Fixes #3777 --- <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-20 15:34:13 -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#12210