GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(auth): self-service password reset (mirrors Magic Link) by Storypapst · Pull Request #439 · OpenResilienceInitiative/ORISO-UserService Conversation
|
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
📝 WalkthroughWalkthroughAdds self-service password-reset request and confirmation endpoints with validated DTOs, public security rules, localized email delivery, expiring one-time tokens, Keycloak password updates, runtime SMTP configuration, and unit coverage. ChangesPassword reset flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant UserController
participant UserRegistrationControllerDelegate
participant PasswordResetService
participant KeycloakService
Client->>UserController: POST password-reset/request
UserController->>UserRegistrationControllerDelegate: pass validated request
UserRegistrationControllerDelegate->>PasswordResetService: requestPasswordReset(username, locale)
PasswordResetService-->>UserRegistrationControllerDelegate: complete silently
UserRegistrationControllerDelegate-->>Client: 204 No Content
Client->>UserController: POST password-reset/confirm
UserController->>UserRegistrationControllerDelegate: pass validated token and password
UserRegistrationControllerDelegate->>PasswordResetService: confirmPasswordReset(token, newPassword)
PasswordResetService->>KeycloakService: updatePassword(...)
KeycloakService-->>PasswordResetService: update result
PasswordResetService-->>UserRegistrationControllerDelegate: boolean status
UserRegistrationControllerDelegate-->>Client: 204 or 400 response
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Self-review found that confirmPasswordReset removed the one-time token before calling KeycloakService.updatePassword, with no restore on failure — unlike MagicLinkLoginService, which explicitly restores its token when the exchange fails. If Keycloak rejected the new password (e.g. a policy violation), the user's emailed link was burned on the first attempt, forcing them to request an entirely new email instead of just retrying with a different password. Token is now only removed after a successful update.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.java`:
- Around line 103-108: The password-reset CSRF exemption is too broad. In
StatelessCsrfFilter, replace the URI substring check with exact matching for the
four intended POST routes: direct and /service request and confirm paths. In
SecurityConfig, remove the redundant broad password-reset regex while retaining
the existing exact POST matchers.
In
`@src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java`:
- Line 52: Replace the in-memory resetTokens ConcurrentHashMap used by
PasswordResetService with a shared persistent store, such as Redis or the
database, configured with a 120-minute TTL. Update token creation, lookup, and
invalidation to use that store so tokens survive restarts and can be confirmed
across replicas.
- Around line 67-84: Update requestPasswordReset to enqueue the complete account
lookup, eligibility checks, locale resolution, and sendPasswordResetEmailSafely
operation, returning immediately before any account-dependent work executes.
Preserve the existing blank-input guard and ensure the queued task handles
unknown, dummy, or missing-email accounts without changing the external
response.
- Around line 146-178: Update the token storage flow around
generateAndStoreToken so expired entries are removed before inserting each new
token. In the password-reset email dispatch flow, remove the generated
oneTimeToken from storage when message creation or Transport.send fails, while
preserving the existing failure propagation behavior.
- Around line 57-58: Update the passwordResetFrontendBaseUrl configuration in
PasswordResetService to remove the hardcoded production URL default, making the
property required so missing configuration fails validation rather than falling
back to app.oriso.org.
- Around line 179-183: Update the catch block in PasswordResetService to remove
target.getKeycloakUserId() and ex.getMessage() from the warning log. Log only a
generic, non-identifying password-reset email dispatch failure category, without
recipient, SMTP, account, or other exception details.
- Around line 101-109: Update the token confirmation flow around resetTokens and
keycloakService.updatePassword to atomically remove the token only if it still
maps to the validated entry before updating Keycloak. If the Keycloak update
rejects or fails, restore that exact token entry; otherwise keep it removed so
concurrent confirmations cannot reuse it.
In
`@src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.java`:
- Around line 369-390: Update both confirmPasswordReset tests around
UserRegistrationControllerDelegateTest to verify
passwordResetService.confirmPasswordReset is invoked with the exact token and
new password used by each test, while retaining the existing status assertions
so the tests fail if delegation is hardcoded or incorrect.
In
`@src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java`:
- Around line 33-34: Remove the class-level `@MockitoSettings`(strictness =
Strictness.LENIENT) from PasswordResetServiceTest and restore Mockito’s default
strict stubbing; if a specific test requires leniency, apply it only to that
individual stub rather than weakening the entire suite.
- Around line 67-167: Strengthen the requestPasswordReset tests around
PasswordResetService by injecting or mocking a mail-delivery abstraction instead
of allowing Transport.send to contact smtp.invalid. Verify account resolution,
generated reset URL/token, selected locale content, recipient, and invocation
count for valid-send scenarios; retain explicit zero-interaction assertions for
unknown accounts, blank or dummy emails, and unavailable SMTP. Replace
no-exception-only assertions where they cannot detect missing flow behavior, and
flag or remove assertions that provide no meaningful coverage.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a6586411-ca31-4b23-a3f0-297ae8462f67
src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserController.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegate.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetConfirmDTO.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetRequestDTO.javasrc/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.javasrc/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.javasrc/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java⚙️ CodeRabbit configuration file
src/main/**/*.java: Check behavior against the surrounding ORISO flow, not only types. Flag
missing transaction boundaries, swallowed exceptions, N+1 queries, and
privacy regressions around Matrix identifiers, chat content and user data.
Configuration must stay environment-driven — never hardcode hosts, IPs or
credentials (see ADR-005 / finding DB-M04).
Files:
src/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetConfirmDTO.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserController.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetRequestDTO.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegate.javasrc/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java⚙️ CodeRabbit configuration file
src/test/**/*.java: Tests must be able to fail. Flag over-mocking that hides the defect,
assertions that cannot break, and missing edge cases.
Files:
src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.javasrc/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.javaLearnt 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/adapters/web/dto/PasswordResetConfirmDTO.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserController.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetRequestDTO.javasrc/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegate.javasrc/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java[warning] 360-396: Do not use DES
Context: Map.of(
"de",
new EmailContent(
"Passwort zurücksetzen",
"Es wurde eine Änderung der Anmeldeinformationen für Ihren Account Caritas Onlineberatung angefordert. Wenn Sie diese Änderung beantragt haben, klicken Sie auf den unten stehenden Link.",
"Link zum Zurücksetzen von Anmeldeinformationen",
"Die Gültigkeit des Links wird in 120 Minuten verfallen. Sollten Sie keine Änderung vollziehen wollen, können Sie diese Nachricht ignorieren."),
"en",
new EmailContent(
"Reset password",
"A change of login credentials for your Caritas Online Counselling account has been requested. If you requested this change, click the link below.",
"Link to reset login credentials",
"This link will expire in 120 minutes. If you do not want to make this change, you can ignore this message."),
"fr",
new EmailContent(
"Réinitialiser le mot de passe",
"Une modification des informations de connexion de votre compte Caritas Online-Beratung a été demandée. Si vous êtes à l'origine de cette demande, cliquez sur le lien ci-dessous.",
"Lien pour réinitialiser les informations de connexion",
"Ce lien expirera dans 120 minutes. Si vous ne souhaitez pas effectuer cette modification, vous pouvez ignorer ce message."),
"ru",
new EmailContent(
"Сброс пароля",
"Был запрошен сброс учётных данных для входа в ваш аккаунт Caritas Online-Beratung. Если вы запросили это изменение, перейдите по ссылке ниже.",
"Ссылка для сброса учётных данных",
"Срок действия ссылки истекает через 120 минут. Если вы не хотите вносить это изменение, просто проигнорируйте это письмо."),
"ti",
new EmailContent(
"ፓስዎርድ ዳግማይ ምቕማጥ",
"ንኣካውንትካ Caritas Online-Beratung ናይ መእተዊ ሓበሬታ ንምቕያር ተሓቲቱ ኣሎ። እዚ ለውጢ እዚ ንስኻ እንተኾንካ ሓቲትካዮ፣ ነቲ ኣብ ታሕቲ ዘሎ ሊንክ ጠውቕ።",
"ናይ መእተዊ ሓበሬታ ዳግማይ ንምቕማጥ ዝኸውን ሊንክ",
"ጽንዓት እዚ ሊንክ እዚ ኣብ 120 ደቓይቕ ክውዳእ እዩ። እዚ ለውጢ እዚ ክትገብር ዘይትደሊ እንተኾንካ፣ ነዚ መልእኽቲ እዚ ክትንዕቆ ትኽእል ኢኻ።"),
"tr",
new EmailContent(
"Şifreyi sıfırla",
"Caritas Online-Beratung hesabınız için oturum açma bilgilerinizde bir değişiklik talep edildi. Bu değişikliği siz talep ettiyseniz aşağıdaki bağlantıya tıklayın.",
"Oturum açma bilgilerini sıfırlama bağlantısı",
"Bu bağlantının geçerlilik süresi 120 dakika içinde dolacaktır. Bu değişikliği yapmak istemiyorsanız bu mesajı yok sayabilirsiniz."))
Note: [CWE-326] Inadequate Encryption Strength.
(no-des-cipher)
[warning] 366-366: Do not use DES
Context: "Die Gültigkeit des Links wird in 120 Minuten verfallen. Sollten Sie keine Änderung vollziehen wollen, können Sie diese Nachricht ignorieren."
Note: [CWE-326] Inadequate Encryption Strength.
(no-des-cipher)
[warning] 376-376: Do not use DES
Context: "Une modification des informations de connexion de votre compte Caritas Online-Beratung a été demandée. Si vous êtes à l'origine de cette demande, cliquez sur le lien ci-dessous."
Note: [CWE-326] Inadequate Encryption Strength.
(no-des-cipher)
src/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetConfirmDTO.java (1)
1-11: LGTM!src/main/java/de/caritas/cob/userservice/api/adapters/web/dto/PasswordResetRequestDTO.java (1)
1-11: LGTM!src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserController.java (1)
32-33: LGTM!Also applies to: 114-124
src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegate.java (1)
14-15: LGTM!Also applies to: 29-29, 59-59, 96-106
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java (1)
171-267: LGTM!src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.java (1)
23-24: LGTM!Also applies to: 42-42, 76-76, 357-367
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| private final @NonNull KeycloakService keycloakService; | ||
| private final @NonNull RestTemplate restTemplate; | ||
|
|
||
| private final Map<String, ResetTokenEntry> resetTokens = new ConcurrentHashMap<>(); |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Do not keep reset tokens only in process memory.
A restart immediately invalidates every outstanding link, and multiple replicas cannot confirm tokens created by another replica. This breaks the advertised 120-minute validity. Use a shared TTL-backed store such as Redis or the database.
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/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java`
at line 52, Replace the in-memory resetTokens ConcurrentHashMap used by
PasswordResetService with a shared persistent store, such as Redis or the
database, configured with a 120-minute TTL. Update token creation, lookup, and
invalidation to use that store so tokens survive restarts and can be confirmed
across replicas.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged as a deliberate deferral (leaving this thread open). Moving reset tokens to a Redis/DB-backed store is intentionally out of scope for this change. In b51ce31 we documented the constraint prominently at class level: the in-memory store means a restart/crash invalidates every outstanding reset link, and the feature is not safe to run with more than one replica (a confirm routed to a different replica will not find the token). A shared store is tracked as follow-up work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@Storypapst Acknowledged. The limitation is correctly characterized: deployment must remain single-replica, and restarts/crashes invalidate outstanding reset links. Keeping this thread open is appropriate until the shared TTL-backed store follow-up is implemented.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Address CodeRabbit security/stability findings on PasswordResetService: - Never log the Keycloak account id or raw exception message on mail failure; log a generic warning with the exception class only and keep details at DEBUG (no PII). - Remove the hardcoded https://app.oriso.org default for password.reset.frontend.base-url. The property is now required; when unset the feature is disabled (fail closed) with a startup warning and no reset mail is sent. Add the (default-empty) property to application.properties. - Consume the token atomically on confirm: Map.remove() first to kill the concurrent double-confirm race, and re-insert the entry only if the Keycloak update fails so a policy-rejected password can still be retried with the same link (small re-insert window documented). - Bound the in-memory token map: purge expired entries before insert, cap to one outstanding token per account, and remove the token when the mail send fails so nothing leaks for a mail that never went out. - Dispatch the account lookup + mail send on an executor so the HTTP response returns in near-constant time regardless of account existence (mitigates timing-based account enumeration). - Document the single-replica in-memory token-store limitation at class level (deliberate deferral; no Redis/DB store in this change). Co-Authored-By: Claude Fable 5 <[email protected]>
The StatelessCsrfFilter exempted any URI containing the substring "/users/password-reset/", and SecurityConfig carried a redundant broad regex on top of the exact request matchers. Restrict the CSRF exemption to the two exact routes (.../users/password-reset/request and .../confirm, optionally under a /service prefix) and drop the redundant regex, since those endpoints are already permitted by the exact requestMatchers. Co-Authored-By: Claude Fable 5 <[email protected]>
- Drop the class-wide @MockitoSettings(LENIENT) on PasswordResetServiceTest and rely on strict stubbing. - Add a mail-sending seam (PasswordResetMailSender) so request-flow tests capture the recipient, locale and reset URL (base URL + 64-hex-char token format) without opening an SMTP socket, plus a fail-closed test for the unset base URL. - Verify passwordResetService delegation in both the confirm success and failure branches of UserRegistrationControllerDelegateTest. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java (2)
177-183: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winRemove the repeated user lookups.
UserService.findUserByUsernamealready queries encoded and decoded username variants. Retrying it with both variants performs the equivalent repository lookup up to three times per unauthenticated request.As per path instructions, check the surrounding ORISO flow and flag N+1 or excessive queries.
🤖 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/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java` around lines 177 - 183, In the password-reset user resolution flow, remove the fallback lookups for decoded and encoded usernames after the initial userService.findUserByUsername(username) call. Keep a single lookup and preserve the existing empty-result handling, relying on UserService.findUserByUsername to resolve username variants internally.Source: Path instructions
315-322: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftMake per-account token replacement atomic.
Concurrent reset requests can both complete
removeIfbefore either inserts, leaving multiple valid tokens for one account. Use an account-keyed atomic operation or per-account synchronization, and add a concurrent regression test.🤖 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/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java` around lines 315 - 322, Update generateAndStoreToken so removing the existing token and storing the replacement are atomic per Keycloak user account, using an account-keyed atomic operation or synchronization to prevent concurrent requests from leaving multiple valid tokens. Preserve the one-outstanding-token behavior, and add a concurrent regression test covering simultaneous reset requests for the same account.
src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.java (1)
106-110: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winMatch the four permitted paths explicitly.
endsWithstill exempts arbitrary prefixes such as/admin/users/password-reset/request; it is not limited to the direct and/serviceroutes stated by the comment. Compare against the four complete paths and add a negative-prefix test.🤖 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/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.java` around lines 106 - 110, Update the path matching in StatelessCsrfFilter to compare the complete request URI against exactly the four permitted direct and /service password-reset request/confirm paths, replacing the endsWith checks. Preserve case-insensitive matching and add a negative-prefix test confirming paths such as /admin/users/password-reset/request remain protected.Source: Path instructions
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java (1)
82-123: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAssert the no-send behavior directly.
These tests still pass if an email is incorrectly dispatched. Assert
sentMailsis empty in every no-send case; the consultant test should also verify the exact consultant lookup instead of treating “no NPE” as proof.As per path instructions, tests must be able to fail and assertions that cannot expose defects must be flagged.
Also applies to: 169-181
🤖 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/service/auth/PasswordResetServiceTest.java` around lines 82 - 123, The no-send password-reset tests only assert absence of exceptions, so they must directly verify that no email was dispatched. Update requestPasswordReset_Should_CompleteSilently_When_AccountNotFound, the blank-email and dummy-suffix tests, and the SMTP-not-configured test to assert sentMails is empty; in the account-not-found case, also verify the exact consultant lookup arguments rather than relying on no-throw behavior.Source: Path instructions
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java`:
- Around line 68-75: Replace the locally created passwordResetExecutor in
PasswordResetService with an injected, Spring-managed bounded executor.
Configure an explicit queue capacity, rejection policy, and lifecycle shutdown
behavior, and use that executor for password-reset dispatch so overload is
rejected or handled promptly instead of accumulating unbounded work.
- Around line 158-167: The catch in PasswordResetService should restore
resetTokens only for the explicit Keycloak password-policy validation exception;
allow unknown or ambiguous RuntimeExceptions to propagate without reinserting
the consumed token. In PasswordResetServiceTest, use the policy exception for
retry coverage and add an assertion that an unknown failure leaves the token
consumed. Update the affected sites in
src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java
lines 158-167 and
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java
lines 218-230.
---
Outside diff comments:
In
`@src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java`:
- Around line 177-183: In the password-reset user resolution flow, remove the
fallback lookups for decoded and encoded usernames after the initial
userService.findUserByUsername(username) call. Keep a single lookup and preserve
the existing empty-result handling, relying on UserService.findUserByUsername to
resolve username variants internally.
- Around line 315-322: Update generateAndStoreToken so removing the existing
token and storing the replacement are atomic per Keycloak user account, using an
account-keyed atomic operation or synchronization to prevent concurrent requests
from leaving multiple valid tokens. Preserve the one-outstanding-token behavior,
and add a concurrent regression test covering simultaneous reset requests for
the same account.
---
Duplicate comments:
In
`@src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.java`:
- Around line 106-110: Update the path matching in StatelessCsrfFilter to
compare the complete request URI against exactly the four permitted direct and
/service password-reset request/confirm paths, replacing the endsWith checks.
Preserve case-insensitive matching and add a negative-prefix test confirming
paths such as /admin/users/password-reset/request remain protected.
In
`@src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java`:
- Around line 82-123: The no-send password-reset tests only assert absence of
exceptions, so they must directly verify that no email was dispatched. Update
requestPasswordReset_Should_CompleteSilently_When_AccountNotFound, the
blank-email and dummy-suffix tests, and the SMTP-not-configured test to assert
sentMails is empty; in the account-not-found case, also verify the exact
consultant lookup arguments rather than relying on no-throw behavior.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 08db3936-6c77-4d60-b50b-84023a309ba9
src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.javasrc/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.javasrc/main/resources/application.propertiessrc/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.javasrc/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java⚙️ CodeRabbit configuration file
src/main/**/*.java: Check behavior against the surrounding ORISO flow, not only types. Flag
missing transaction boundaries, swallowed exceptions, N+1 queries, and
privacy regressions around Matrix identifiers, chat content and user data.
Configuration must stay environment-driven — never hardcode hosts, IPs or
credentials (see ADR-005 / finding DB-M04).
Files:
src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/interceptor/StatelessCsrfFilter.javasrc/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java⚙️ CodeRabbit configuration file
src/test/**/*.java: Tests must be able to fail. Flag over-mocking that hides the defect,
assertions that cannot break, and missing edge cases.
Files:
src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.javasrc/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.javaLearnt 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/adapters/web/controller/interceptor/StatelessCsrfFilter.javasrc/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java (1)
13-13: LGTM!Also applies to: 63-67, 77-132, 151-157, 172-176, 184-313, 326-496
src/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.java (1)
112-134: LGTM!src/main/resources/application.properties (1)
40-42: LGTM!src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserRegistrationControllerDelegateTest.java (1)
76-76: LGTM!Also applies to: 357-393
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java (1)
17-64: LGTM!Also applies to: 68-79, 125-167, 184-217, 233-294
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…on policy rejection - Replace the fixed thread pool (unbounded queue) with a bounded ThreadPoolExecutor (2..4 threads, 200-slot queue, AbortPolicy) plus @PreDestroy shutdown; overflow is dropped silently so the public endpoint's response stays identical under flood. - Re-insert the one-time token only on a definitive password-policy rejection (CustomValidationHttpStatusException from Keycloak). Any indeterminate failure keeps the token consumed, since the password may already have been applied. - Tests: policy rejection keeps the token, indeterminate failure consumes it. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java (1)
1-1: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAssert that no emails were sent to ensure the tests can fail on regression.
As noted in the previous review, these request-flow tests currently only assert that no exception is thrown. If the service erroneously sent an email or made an external HTTP call, these tests would still pass. As per path instructions, tests must be able to fail. Add explicit negative assertions to preserve the intended no-send behavior as a regression check.
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L84-92: AddassertThat(sentMails).isEmpty();andverify(restTemplate, never()).getForObject(anyString(), any());.src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L71-76: AddassertThat(sentMails).isEmpty();.src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L78-82: AddassertThat(sentMails).isEmpty();.src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L94-104: AddassertThat(sentMails).isEmpty();.src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L106-116: AddassertThat(sentMails).isEmpty();.src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L118-126: AddassertThat(sentMails).isEmpty();.src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java#L172-185: AddassertThat(sentMails).isEmpty();to verify the no-send behavior when SMTP is not configured via consultant fallback.🤖 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/service/auth/PasswordResetServiceTest.java` at line 1, Update the request-flow tests in PasswordResetServiceTest to assert sentMails is empty after each listed no-send scenario, including the SMTP-unconfigured consultant-fallback case. In the test covering the external lookup, also verify restTemplate.getForObject(anyString(), any()) is never called, while preserving the existing test behavior.Source: Path instructions
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java`:
- Line 1: Update the request-flow tests in PasswordResetServiceTest to assert
sentMails is empty after each listed no-send scenario, including the
SMTP-unconfigured consultant-fallback case. In the test covering the external
lookup, also verify restTemplate.getForObject(anyString(), any()) is never
called, while preserving the existing test behavior.
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a4d0421e-4bcb-4935-b873-01004d9f024e
src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.javasrc/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java⚙️ CodeRabbit configuration file
src/test/**/*.java: Tests must be able to fail. Flag over-mocking that hides the defect,
assertions that cannot break, and missing edge cases.
Files:
src/test/java/de/caritas/cob/userservice/api/service/auth/PasswordResetServiceTest.java⚙️ CodeRabbit configuration file
src/main/**/*.java: Check behavior against the surrounding ORISO flow, not only types. Flag
missing transaction boundaries, swallowed exceptions, N+1 queries, and
privacy regressions around Matrix identifiers, chat content and user data.
Configuration must stay environment-driven — never hardcode hosts, IPs or
credentials (see ADR-005 / finding DB-M04).
Files:
src/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.javaLearnt 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/service/auth/PasswordResetService.javasrc/main/java/de/caritas/cob/userservice/api/service/auth/PasswordResetService.java (1)
1-525: LGTM!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai full review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 34 minutes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.