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 — Fix/us c01 remove matrix password plaintext by shazia-k · Pull Request #124 · OpenResilienceInitiative/ORISO-UserService Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR removes persisted plaintext Matrix passwords for users/consultants and switches Matrix operations (login/room creation/join/joined-rooms) to Synapse admin impersonation, backed by a DB migration that drops the matrix_password columns. It also adds regression/smoke tests to ensure passwords are not stored and that messaging still works without them.
Changes:
matrix_password columns from user and consultant tables via Liquibase.loginUserViaAdmin(...) / createRoomForMatrixUser(...).Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/de/caritas/cob/userservice/api/adapters/matrix/MatrixSynapseService.java | Adds admin-impersonation login + room/joined-rooms flows to avoid stored user/consultant passwords. |
| src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/MatrixMessageController.java | Refactors message/send/read/sync/upload to use admin impersonation for users/consultants (agency service account still uses password where applicable). |
| src/main/java/de/caritas/cob/userservice/api/service/session/DirectSessionMatrixRoomService.java | Uses admin impersonation for room provisioning and joins; no longer relies on stored consultant/user passwords. |
| src/main/java/de/caritas/cob/userservice/api/service/session/AgencyPreAssignmentRoomService.java | Removes dependency on user’s stored password when auto-joining holding rooms. |
| src/main/java/de/caritas/cob/userservice/api/facade/CreateUserFacade.java | Stops persisting Matrix password on user after Matrix account creation. |
| src/main/java/de/caritas/cob/userservice/api/facade/CreateChatFacade.java | Switches group-chat room creation/invites/joins to admin impersonation (no stored participant passwords). |
| src/main/java/de/caritas/cob/userservice/api/facade/assignsession/AssignEnquiryFacade.java | Updates enquiry assignment Matrix flows to admin impersonation and removes consultant password dependency. |
| src/main/java/de/caritas/cob/userservice/api/admin/service/consultant/create/CreateConsultantSaga.java | Stops persisting consultant Matrix password during consultant creation saga. |
| src/main/java/de/caritas/cob/userservice/api/facade/SessionSupervisorFacade.java | Uses admin impersonation tokens for supervisor add/remove Matrix operations. |
| src/main/java/de/caritas/cob/userservice/api/facade/sessionlist/RocketChatRoomInformationProvider.java | Fetches joined rooms via admin impersonation (no consultant password). |
| src/main/java/de/caritas/cob/userservice/api/model/User.java | Removes matrixPassword field mapping. |
| src/main/java/de/caritas/cob/userservice/api/model/Consultant.java | Removes matrixPassword field mapping. |
| src/main/resources/db/changelog/userservice-dev-master.xml | Includes the new drop-matrix-password changeset. |
| src/main/resources/db/changelog/userservice-local-master.xml | Includes the new drop-matrix-password changeset. |
| src/main/resources/db/changelog/userservice-prod-master.xml | Includes the new drop-matrix-password changeset. |
| src/main/resources/db/changelog/userservice-staging-master.xml | Includes the new drop-matrix-password changeset. |
| src/main/resources/db/changelog/changeset/0053_drop_matrix_password/0053_changeSet.xml | Adds Liquibase changeset wiring for dropping columns. |
| src/main/resources/db/changelog/changeset/0053_drop_matrix_password/dropMatrixPasswordColumns.sql | Drops the matrix_password columns from user and consultant. |
| src/test/java/de/caritas/cob/userservice/api/security/UsC01MatrixPasswordSmokeTest.java | Smoke tests ensuring no persisted matrixPassword field and messaging uses impersonation. |
| src/test/java/de/caritas/cob/userservice/api/helper/PlainCredentialsHolderTest.java | Verifies ThreadLocal credentials are cleared and don’t leak across requests. |
| src/test/java/de/caritas/cob/userservice/api/adapters/matrix/MatrixSynapseServiceTest.java | Tests admin impersonation token acquisition behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
…ix-password-plaintext # Conflicts: # src/main/java/de/caritas/cob/userservice/api/admin/service/consultant/create/CreateConsultantSaga.java # src/main/resources/db/changelog/userservice-dev-master.xml # src/main/resources/db/changelog/userservice-local-master.xml # src/main/resources/db/changelog/userservice-prod-master.xml # src/main/resources/db/changelog/userservice-staging-master.xml
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| MatrixCreateUserResponseDTO matrixBody = new MatrixCreateUserResponseDTO(); | ||
| matrixBody.setUserId(MATRIX_USER_ID); | ||
| when(matrixSynapseService.createUser( | ||
| eq("plainuser"), eq(REGISTRATION_PASSWORD), eq("plainuser"))) | ||
| .thenReturn(ResponseEntity.ok(matrixBody)); |
| verify(matrixSynapseService) | ||
| .createUser(eq("plainuser"), eq(REGISTRATION_PASSWORD), eq("plainuser")); | ||
| verify(matrixSynapseService, never()).loginUser(anyString(), eq(REGISTRATION_PASSWORD)); |
| String matrixUsername = | ||
| isConsultant | ||
| ? extractMatrixUsername( | ||
| consultantService | ||
| .getConsultant(keycloakUserId) |
| <include file="db/changelog/changeset/0050_security05_deletion_lifecycle/0050_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0051_backfill_deletion_read_only_until/0051_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0052_invite_links_topic/0052_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0053_consultant_topic/0053_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0053_drop_matrix_password/0053_changeSet.xml"/> | ||
| </databaseChangeLog> |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 19 out of 19 changed files in this pull request and generated 9 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| MatrixCreateUserResponseDTO matrixBody = new MatrixCreateUserResponseDTO(); | ||
| matrixBody.setUserId(MATRIX_USER_ID); | ||
| when(matrixSynapseService.createUser( | ||
| eq("plainuser"), eq(REGISTRATION_PASSWORD), eq("plainuser"))) | ||
| .thenReturn(ResponseEntity.ok(matrixBody)); |
| verify(matrixSynapseService) | ||
| .createUser(eq("plainuser"), eq(REGISTRATION_PASSWORD), eq("plainuser")); | ||
| verify(matrixSynapseService, never()).loginUser(anyString(), eq(REGISTRATION_PASSWORD)); |
| @Mock private MatrixSynapseService matrixSynapseService; | ||
| @Mock private TenantService tenantService; | ||
| @Mock private AgencyService agencyService; | ||
|
|
||
| @InjectMocks private CreateUserFacade createUserFacade; |
| <include file="db/changelog/changeset/0050_security05_deletion_lifecycle/0050_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0051_backfill_deletion_read_only_until/0051_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0052_invite_links_topic/0052_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0053_consultant_topic/0053_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0053_drop_matrix_password/0053_changeSet.xml"/> | ||
| </databaseChangeLog> |
| long now = System.currentTimeMillis(); | ||
| impersonationTokenCache.entrySet().removeIf(e -> now >= e.getValue().expiryMs); | ||
|
|
||
| CachedImpersonationToken cached = impersonationTokenCache.get(matrixUserId); | ||
| if (cached != null) { | ||
| return cached.token; | ||
| } |
| addedByConsultant.getMatrixUserId().substring(1).split(":")[0]; | ||
| } | ||
|
|
||
| String addedByConsultantPassword = addedByConsultant.getMatrixPassword(); | ||
| if (addedByConsultantPassword == null) { | ||
| if (addedByConsultant.getMatrixUserId() == null) { | ||
| throw new InternalServerErrorException( |
| // Login supervisor and join room | ||
| String supervisorMatrixUsername = null; | ||
| if (supervisorMatrixUserId.startsWith("@")) { |
| String consultantMatrixUsername = null; | ||
| if (consultant.getMatrixUserId() != null && consultant.getMatrixUserId().startsWith("@")) { | ||
| consultantMatrixUsername = consultant.getMatrixUserId().substring(1).split(":")[0]; | ||
| } | ||
|
|
| // Extract consultant username | ||
| String consultantMatrixUsername = null; | ||
| if (consultant.getMatrixUserId() != null && consultant.getMatrixUserId().startsWith("@")) { | ||
| consultantMatrixUsername = consultant.getMatrixUserId().substring(1).split(":")[0]; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| void loginUserViaAdmin_Should_ReturnNull_When_AdminCredentialsMissing() { | ||
| when(matrixConfig.getAdminUsername()).thenReturn(""); | ||
| when(matrixConfig.getAdminPassword()).thenReturn(""); | ||
|
|
||
| assertThat(matrixSynapseService.loginUserViaAdmin(MATRIX_USER_ID), nullValue()); | ||
| class MatrixSynapseServiceTest { |
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.ArgumentMatchers.eq; |
| MatrixCreateUserResponseDTO matrixBody = new MatrixCreateUserResponseDTO(); | ||
| matrixBody.setUserId(MATRIX_USER_ID); | ||
| when(matrixSynapseService.createUser( | ||
| eq("plainuser"), eq(REGISTRATION_PASSWORD), eq("plainuser"))) | ||
| .thenReturn(ResponseEntity.ok(matrixBody)); |
| verify(matrixSynapseService) | ||
| .createUser(eq("plainuser"), eq(REGISTRATION_PASSWORD), eq("plainuser")); | ||
| verify(matrixSynapseService, never()).loginUser(anyString(), eq(REGISTRATION_PASSWORD)); |
| <include file="db/changelog/changeset/0050_security05_deletion_lifecycle/0050_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0051_backfill_deletion_read_only_until/0051_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0052_invite_links_topic/0052_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0053_consultant_topic/0053_changeSet.xml"/> | ||
| <include file="db/changelog/changeset/0053_drop_matrix_password/0053_changeSet.xml"/> | ||
| </databaseChangeLog> |
| <changeSet author="oriso" id="dropMatrixPasswordColumns"> | ||
| <sqlFile path="db/changelog/changeset/0053_drop_matrix_password/dropMatrixPasswordColumns.sql" | ||
| stripComments="true"/> |
Co-authored-by: Cursor <[email protected]>
There was an error while loading. Please reload this page.
|
@BjoernLudwig FYI: this was the reason why we had today not chat working. @shazia-k Rolled it back now and will think of an alternative. @joro4b @Hassan9215 @Shirloin @nikunjdecyb @einsteinjava @shanzaeimran @Kadyan25 @radaljj Any ideas are welcome. @shazia-k if you can please describe the issue better you see so far 🙏 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Storypapst Any other suggestions are welcome. |
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.