GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix email 2FA completion for encoded Admin usernames by Storypapst · Pull Request #728 · OpenResilienceInitiative/ORISO-UserService

Conversation

@Storypapst

@Storypapst Storypapst commented Jul 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Why

Email-based 2FA verification succeeded in the identity provider but UserService then searched Keycloak with the encoded OTP-SPI username. Keycloak stores this Admin identity under the raw username, so the empty search result caused an IndexOutOfBoundsException. The active marker was never written and the mandatory 2FA setup gate appeared again.

What changed

  • Keep the encoded username for OTP verification.
  • Decode the username only for the subsequent Keycloak email update.
  • Cover both encoded and already-raw usernames with regression tests.

Verification

  • Red: the new encoded-username regression failed because changeEmailAddress received the encoded value.
  • Green focused suite: 23 tests passed.
  • Full Java 21 unit suite: 3,747 tests, 0 failures, 0 errors, 7 skipped.
  • Spotless and git diff --check: passed.
  • PreDev hotfix image: docker.io/storypapst/oriso-e2e@sha256:3d287644f7fa84a76c3231ca9c3d540a25ba4ba90f02b42d601aa3c4a9f60eba (linux/amd64).
  • Managed Test Access run 13377183-ab35-4216-a98a-109baac116be passed with Simpson identity Herb Powell ([email protected]).
  • Runtime flow: reset factor → request email OTP (204) → retrieve OTP through Test Access → validate (204) → reload.
  • Persisted readback after reload: isEnabled=true, isActive=true, isToEncourage=true, type=EMAIL; no mandatory setup dialog.
  • UserService logs contained no IndexOutOfBoundsException or email-2FA completion error during the passing run.

Closes #727

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Storypapst
fix: persist email 2FA for encoded usernames
fc2be91
@Storypapst
Storypapst requested review from Hassan9215 and shazia-k July 23, 2026 16:06
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Fixed email address updates during one-time password verification to use the correct decoded username.
    • Preserved expected behavior when the provided username is already in its raw format.
  • Tests

    • Added coverage for email verification and email address updates with both encoded and raw usernames.

Walkthrough

validateOneTimePassword now uses the decoded username when updating a Keycloak email address while retaining the original username for OTP verification. Tests cover both encoded and already-raw usernames.

Changes

Email verification username handling

Layer / File(s) Summary
Normalize username for email updates
src/main/java/de/caritas/cob/userservice/api/IdentityManager.java, src/test/java/de/caritas/cob/userservice/api/IdentityManagerTest.java
Email updates use the decoded username, while OTP verification retains the supplied username; regression tests cover encoded and raw usernames.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • OpenResilienceInitiative/ORISO-UserService#508: Updates IdentityManager and tests for decoding usernames during email ownership checks.

Suggested labels: coderabbit

Suggested reviewers: hassan9215, shazia-k

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing email 2FA completion for encoded Admin usernames.
Description check ✅ Passed The description matches the PR and explains the same fix, tests, and verification steps.
Linked Issues check ✅ Passed The code changes satisfy #727 by decoding the username for the Keycloak update, keeping the encoded value for OTP verification, and adding regression tests.
Out of Scope Changes check ✅ Passed The diff is narrowly scoped to the reported fix and related tests, with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/email-otp-user-lookup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Storypapst
Storypapst marked this pull request as ready for review July 23, 2026 16:18
@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Storypapst

Storypapst commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot added the coderabbit label Jul 23, 2026
coderabbitai[bot]
coderabbitai Bot reviewed Jul 23, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/test/java/de/caritas/cob/userservice/api/IdentityManagerTest.java (1)

43-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the raw username is retained for OTP verification.

The current stub causes an incorrect OTP username to fail indirectly via a null result. Explicitly verify the interaction so the test documents both sides of the contract.

Suggested test strengthening
-    identityManager.validateOneTimePassword(RAW_USERNAME, "123456");
+    assertThat(identityManager.validateOneTimePassword(RAW_USERNAME, "123456"))
+        .isEqualTo(validationResult);
 
+    verify(identityClient).finishEmailVerification(RAW_USERNAME, "123456");
     verify(identityClient).changeEmailAddress(RAW_USERNAME, EMAIL);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/de/caritas/cob/userservice/api/IdentityManagerTest.java` around
lines 43 - 51, The test should explicitly verify that OTP validation calls
finishEmailVerification with the original RAW_USERNAME and OTP, in addition to
verifying changeEmailAddress uses RAW_USERNAME. Update
validateOneTimePasswordShouldKeepAlreadyRawUsernameForKeycloakEmailUpdate to add
the missing interaction assertion while preserving the existing stubbing and
email-update verification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/test/java/de/caritas/cob/userservice/api/IdentityManagerTest.java`:
- Around line 43-51: The test should explicitly verify that OTP validation calls
finishEmailVerification with the original RAW_USERNAME and OTP, in addition to
verifying changeEmailAddress uses RAW_USERNAME. Update
validateOneTimePasswordShouldKeepAlreadyRawUsernameForKeycloakEmailUpdate to add
the missing interaction assertion while preserving the existing stubbing and
email-update verification.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bd85131-b46d-40fe-8f73-8472c4dfc1d3

📥 Commits

Reviewing files that changed from the base of the PR and between ab1aa79 and fc2be91.

📒 Files selected for processing (2)
  • src/main/java/de/caritas/cob/userservice/api/IdentityManager.java
  • src/test/java/de/caritas/cob/userservice/api/IdentityManagerTest.java
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-07-12T05:15:05.095Z
Learnt from: Storypapst
Repo: OpenResilienceInitiative/ORISO-UserService PR: 420
File: src/main/java/de/caritas/cob/userservice/api/conversation/service/AnonymousConversationCreatorService.java:34-35
Timestamp: 2026-07-12T05:15:05.095Z
Learning: In ORISO-UserService, treat `rocket-chat.enabled` defaulting to `false` (e.g., `Value("${rocket-chat.enabled:false}")`) as an intentional Matrix-only default. Do not flag code paths/config placeholders that use this default-false behavior as a bug in future reviews. Rocket.Chat must be explicitly enabled only by setting `ROCKET_CHAT_ENABLED=true` (or the equivalent `rocket-chat.enabled=true`), consistent with the repository’s `application*.properties`/configuration validator and the disabled Rocket.Chat service wiring.

Applied to files:

  • src/main/java/de/caritas/cob/userservice/api/IdentityManager.java
🔇 Additional comments (2)
src/main/java/de/caritas/cob/userservice/api/IdentityManager.java (1)

36-36: LGTM!

src/test/java/de/caritas/cob/userservice/api/IdentityManagerTest.java (1)

4-4: LGTM!

Also applies to: 29-41

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
coderabbitai[bot]
coderabbitai Bot approved these changes Jul 23, 2026
View reviewed changes
shazia-k
shazia-k approved these changes Jul 23, 2026
View reviewed changes
@shazia-k
shazia-k merged commit f23d717 into pre-dev Jul 23, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@shazia-k
shazia-k deleted the fix/email-otp-user-lookup branch July 23, 2026 20:10
This was referenced Jul 26, 2026
Make identity provisioning compensatable and replay-safe #752
Closed
Decouple identity ports from Keycloak transport models #750
Closed
[Stability] Measure OTP provider admin-session retries #766
Closed
[Stability] Remove the remaining disabled email-supplier tests #768
Closed
Decouple magic-link sessions from Keycloak transport #770
Closed
Route username availability through the identity input port #775
Closed
Route user web identity policy through an input port #777
Closed
Split email-owner lookup from the broad identity client #787
Closed
Split authentication from the broad identity client #789
Closed
Split username availability from the broad identity client #791
Closed
Type and isolate identity second-factor verification #793
Closed
Complete the focused identity email-address mutation boundary #797
Closed
Complete the focused identity account-settings boundary #801
Closed
Move identity profile updates behind a focused port #809
Closed
Move identity password writes behind a focused port #814
Closed
Refactor dummy-email updates behind a focused identity port #820
Closed
This was referenced Jul 28, 2026
Password reset and magic link never send mail: SMTP credentials read from the public settings endpoint #863
Closed
[P6] Login, two-factor authentication and password reset #896
Open
Recovery code for anonymous accounts without e-mail #928
Open
[Stability] Focus identity email address mutations #885
Merged
DpaForwardEmailService and GlobalSmtpTestEmailService onto the e-mail design system #946
Closed
P0: Expose transient Matrix UIA credential to the authenticated browser session #950
Closed
[P0] Registration double-decodes passwords and creates unusable accounts #959
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 7, 2026
[Stability] Type identity second-factor boundary #882
Merged
@Storypapst Storypapst mentioned this pull request Aug 24, 2026
Email 2FA completion fails for encoded Admin usernames #727
Closed
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] approved these changes
@shazia-k shazia-k shazia-k approved these changes
@Hassan9215 Hassan9215 Awaiting requested review from Hassan9215

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Storypapst @shazia-k
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.