Skip to content

[PM-45362] Store the SCIM userName as ExternalName - #8943

Draft
sven-bitwarden wants to merge 1 commit into
ac/pm-45362/add-external-name-columnfrom
ac/pm-45362/scim-save-external-name
Draft

sven-bitwarden wants to merge 1 commit into
ac/pm-45362/add-external-name-columnfrom
ac/pm-45362/scim-save-external-name

Conversation

@sven-bitwarden

Copy link
Copy Markdown
Contributor

🎟️ Tracking

PM-45362

Part 2 of 2, stacked on the column PR (base branch ac/pm-45362/add-external-name-column). Together they replace #8901.

📔 Objective

SCIM discarded the submitted userName and returned the member's email in its place, so identity providers whose userName differs from the email (Entra sends the UPN) could never find the member again: Finding A from the Entra validation report. This stores it in OrganizationUser.ExternalName.

  • Create (POST): stores userName as ExternalName on all three create paths (staged, invite, and the vNext invite command), and returns 409 when another member already has that userName.
  • PATCH: replaces userName by path or by value object. It returns 400 for an empty, blank or over-300-character value (userName is required by RFC 7643, and saving NULL keeps the stored value), and 409 for a duplicate.
  • GET and filtering: userName is ExternalName, falling back to the email for members provisioned before it was stored, and filter=userName eq "x" matches the same value, ignoring case. One helper (OrganizationUserUserDetailsExtensions) defines it for the response, the filter and the duplicate checks.
  • Unchanged: PUT still applies only active, as before.

Members provisioned before this change keep answering to their email, and identity providers that send their email as userName see no difference.

Tests: unit tests for create, PATCH (including the 300/301-character limits) and the filter, plus an integration test that creates a member whose userName differs from their email on each create path, then finds them by userName.

🤖 AI-assisted review

Standard local review (code-review-local), diffed against the column branch: approved, no findings.

SCIM discarded the submitted userName and returned the member's email
instead, so identity providers that send a userName different from the
email (Entra sends the UPN) could never find the member again.

- Create stores userName as ExternalName on all three paths (staged,
  invite, and the vNext invite command), and returns 409 when another
  member already has that userName.
- PATCH replaces it by path or value object. It returns 400 for an
  empty, blank or over-300-character userName, and 409 for a duplicate.
- GET returns ExternalName, falling back to the email for members
  provisioned before it was stored, and `userName eq` filters on the
  same value, ignoring case.
@sven-bitwarden sven-bitwarden added the ai-review-vnext Request a Claude code review using the vNext workflow label Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR stores the SCIM userName as OrganizationUser.ExternalName on all three create paths (staged, legacy invite, and the vNext invite command). It also adds PATCH support for userName, both by path and by value object, and makes userName resolve to ExternalName with an email fallback for GET responses, userName eq filtering, and duplicate detection. I traced each create path through to persistence. The staged and vNext paths reach OrganizationUser_CreateMany and _CreateManyWithCollectionsAndGroups through JSON serialization of the entity. The legacy path reaches OrganizationService.InviteUserAsync. All of these pick up the column added in the base layer. The validation (blank or over 300 characters returns 400, duplicate returns 409) and the unit and integration tests match the behavior described in the PR.

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.72131% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.84%. Comparing base (ff4c6b6) to head (20420d7).

Files with missing lines Patch % Lines
...itwarden_license/src/Scim/Users/PostUserCommand.cs 81.81% 0 Missing and 2 partials ⚠️

❗ There is a different number of reports uploaded between BASE (ff4c6b6) and HEAD (20420d7). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (ff4c6b6) HEAD (20420d7)
2 1
Additional details and impacted files
@@                           Coverage Diff                            @@
##           ac/pm-45362/add-external-name-column    #8943      +/-   ##
========================================================================
- Coverage                                 75.12%   68.84%   -6.28%     
========================================================================
  Files                                      2756     2757       +1     
  Lines                                    118250   118297      +47     
  Branches                                  10863    10870       +7     
========================================================================
- Hits                                      88830    81445    -7385     
- Misses                                    26755    34299    +7544     
+ Partials                                   2665     2553     -112     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review-vnext Request a Claude code review using the vNext workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant