Skip to content

feat: upsert user by oidc - #1224

Merged
yoganandaness merged 29 commits into
developfrom
SWAP-5056-user-office-one-identity-synchronisation
Nov 5, 2025
Merged

feat: upsert user by oidc#1224
yoganandaness merged 29 commits into
developfrom
SWAP-5056-user-office-one-identity-synchronisation

Conversation

@yoganandaness

@yoganandaness yoganandaness commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

Description

Added User Upsert Mutation that handle both Creation and Update of User by OIDC Sub. This endpoint is created for external purpose used by the Authentication Identity team to sync the users in the user office.

Motivation and Context

Synchronization with One Identity Systems(Authentication)

How Has This Been Tested

Attached Unit Test Cases

Fixes

Changes

  1. Added new Mutation upsertUserByOidcSub
  2. Made the column oidc_sub in users table as unique. It still remains non null.

Depends on

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@yoganandaness
yoganandaness requested a review from a team as a code owner October 13, 2025 19:17
@yoganandaness
yoganandaness requested review from ACLay and removed request for a team October 13, 2025 19:17
@yoganandaness
yoganandaness force-pushed the SWAP-5056-user-office-one-identity-synchronisation branch 2 times, most recently from 40650a0 to e31bb22 Compare October 13, 2025 20:04
@yoganandaness
yoganandaness force-pushed the SWAP-5056-user-office-one-identity-synchronisation branch from e31bb22 to 55190f1 Compare October 13, 2025 20:30
@yoganandaness
yoganandaness requested review from TCMeldrum and janosbabik and removed request for ACLay October 13, 2025 20:31
@yoganandaness
yoganandaness force-pushed the SWAP-5056-user-office-one-identity-synchronisation branch from a0abcdf to fb3d7db Compare October 14, 2025 10:42
@Scott-James-Hurley
Scott-James-Hurley self-requested a review October 15, 2025 17:04
Comment thread apps/backend/src/datasources/postgres/UserDataSource.ts Outdated
Comment thread apps/backend/src/datasources/postgres/records.ts
BEGIN
IF register_patch('AddUniqueConstraintToOidcSub.sql', 'yoganandanpandiyan', 'Unique constraint', '2025-10-13') THEN
BEGIN
ALTER TABLE users ADD CONSTRAINT unique_oidc_sub UNIQUE (oidc_sub);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is failing on the stfc db as we have the empty string as the stub on most records. Can we add a step in the to change the stub to null or the user number?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the db seeds were updated 5 months ago to change the oidc_sub of the dummy users 100-102 before they were all 99999 so any database made before that would also fail this patch.

…x to the non empty duplicate values to facilitate smooth process of enforing uniqueness to the oidc_sub
…re into SWAP-5056-user-office-one-identity-synchronisation
…github.com:UserOfficeProject/user-office-core into SWAP-5056-user-office-one-identity-synchronisation
…github.com:UserOfficeProject/user-office-core into SWAP-5056-user-office-one-identity-synchronisation
…github.com:UserOfficeProject/user-office-core into SWAP-5056-user-office-one-identity-synchronisation
…github.com:UserOfficeProject/user-office-core into SWAP-5056-user-office-one-identity-synchronisation
…github.com:UserOfficeProject/user-office-core into SWAP-5056-user-office-one-identity-synchronisation
@yoganandaness
yoganandaness marked this pull request as draft October 30, 2025 12:51
@yoganandaness
yoganandaness force-pushed the SWAP-5056-user-office-one-identity-synchronisation branch 3 times, most recently from 3c8f862 to 3a7e32f Compare October 30, 2025 13:35
@yoganandaness
yoganandaness marked this pull request as ready for review October 30, 2025 13:37
@yoganandaness
yoganandaness force-pushed the SWAP-5056-user-office-one-identity-synchronisation branch from ed2d129 to 827199f Compare October 30, 2025 14:38
@yoganandaness
yoganandaness force-pushed the SWAP-5056-user-office-one-identity-synchronisation branch from 827199f to d470d3d Compare October 30, 2025 15:04
@yoganandaness

Copy link
Copy Markdown
Contributor Author

@TCMeldrum Could you take a look at this again, as there were few undoes and some optimisation.

SET oidc_sub = NULL
WHERE oidc_sub = '';

-- Handle duplicate oidc_sub values by appending a unique suffix. ex., '_1', '_2', etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m a little bit concerned about this. We silently mutate rows, can’t we just let the update fail and manually fix the rows that have the same values?
Instead of trying to be smart, we could select the duplicate values and, if any are found, raise a clear error indicating where the duplicates are and that they need to be fixed.

@yoganandaness
yoganandaness enabled auto-merge (squash) October 31, 2025 13:13

@TCMeldrum TCMeldrum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With manually resoliving our duplicates it looks fine to me. Is there anyway we can tag the next release to remind us this manual check needs to happen?

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

⚠️ Automatic rebase failed due to conflicts. Please rebase manually.

2 similar comments
@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

⚠️ Automatic rebase failed due to conflicts. Please rebase manually.

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

⚠️ Automatic rebase failed due to conflicts. Please rebase manually.

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

⚠️ Automatic rebase failed due to conflicts. Please rebase manually.

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

⚠️ Automatic rebase failed due to conflicts. Please rebase manually.

@yoganandaness
yoganandaness merged commit a024bb0 into develop Nov 5, 2025
22 checks passed
@yoganandaness
yoganandaness deleted the SWAP-5056-user-office-one-identity-synchronisation branch November 5, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants