Repository navigation
chore: Merge 4.77.1 into single-server - #7804
Merged
Merged
Conversation
(cherry picked from commit 8e769ae)
* fix: scope getServerInfo request headers to known servers Only attach the stored auth headers when the user is already signed in to the requested server, and add tests. * fix: only send auth headers in getServerInfo to servers the user is signed in to Drops the Basic auth handling and skipCustomHeaders option from the previous commit and reverts fetch.ts to develop. * remove comment * coderabbit suggestion * fix: address review comments for deep-link consent and getServerInfo - extract getSessionHeaders to fix oxlint complexity - move getServerInfo test to __tests__ folder - prompt before first request to new deep-link host * fix: scope Basic Authorization to requested server in getServerInfo Load Basic auth only for the requested host and skip global customHeaders so deep links to unknown hosts no longer receive the active workspace credentials. * refactor: pass serverRecord to ensureDeepLinkLoginConsent and cover the known-host branch The callers already hold serverRecord, so the consent check no longer re-reads MMKV and the database. The known-host test now uses a server record without a signed-in user so it reaches the new branch. * fix: scope Basic Authorization on the cloud lookup and add-server requests getUniqueId and the add-server requests (getLoginServices, getLoginSettings) still merged the global custom headers, so the current workspace's Basic Authorization reached the requested host after the scoped /api/info call. getUniqueId now sends only the requested server's stored Basic auth, and handleServerRequest points the global Basic auth at the requested server before making any request. * fix: keep Basic auth and session headers scoped to the right server - restore the active workspace's Basic auth when the add-workspace flow is closed - stop sending the global Basic auth to the releases.rocket.chat lookup - require the stored token, not only the user id, before sending session headers - cover the call-push consent branches * fix: end the VoIP call when the sign-in prompt is declined * test: restore customHeaders after each fetch test and drop redundant skipCustomHeaders assertions * revert: move applyBasicAuth handling in selectServer out of this PR * Revert "revert: move applyBasicAuth handling in selectServer out of this PR" This reverts commit 48a3f45. * revert: drop VoIP call cleanup on declined deep-link consent Reverts 924bbf7. The extra handleVoipAcceptFailed call on the decline branch is not part of the credential-leak fix this PR is about. * fix: restore the active workspace's Basic auth when the add-workspace flow finishes Re-apply the connected workspace's stored Basic auth on FINISH_ADD so a failed probe can't leave the probed host's header on later requests. * fix: restore the active workspace's Basic auth as soon as the add-workspace probe ends handleServerRequest swaps the global Basic auth to the probed host and only handed it back on FINISH_ADD, so a failed connect left the active workspace's requests carrying the wrong Authorization until the form unmounted. Restore it in a finally block instead and drop the FINISH_ADD watcher, which keyed off sdk.host before the new connection existed. * fix: address review comments on scoped probe auth and deep-link consent - Guard hardware back while the add-workspace check runs so the active workspace Basic auth can't leak to the probed host - Drop the redundant global Basic auth write in NewServerView - Let fetch callers' headers win over global custom headers and add the getBasicAuthKey helper - Send per-request Basic auth in getLoginServices/getLoginSettings and scope the global swap in getWebsocketInfo to the handshake only, so the probe no longer touches the shared headers - Thread the requested server version through the cloud unique-id lookup - Neutral deep-link consent copy for tokenless links * chore(i18n): add Deep_link_open_* strings for tokenless deep-link consent * refactor: simplify scoped Basic auth handling and share stored-session lookup - keep the add-workspace websocket handshake swap inline in getWebsocketInfo - read the stored user id and token through getStoredSession everywhere - select the deep-link consent copy from a table instead of repeated ternaries - only swallow hardware back while connecting when there is a workspace to return to - remove explanatory comments from tests * refactor: fold add-workspace back guard into handleBackPress * test: cover the add-workspace hardware back guard in NewServerView * fix: restore the active workspace headers before the add-workspace handshake settles * fix: scope the auto-lock time sync request to the requested server's Basic auth * refactor: share applyBasicAuth and finish the deep-link consent rename * fix: end the VoIP call when the deep-link open prompt is declined Also rename shouldAutoConfirmDeepLinkLogin to shouldAutoConfirmDeepLinkConsent now that it gates both prompts. * test: seed a stale header in the reselect test and use ~/ imports in the new tests * fix: skip the DM navigation when the deep-link open prompt is declined after a failed VoIP accept Declining the prompt only needs to end the call and reset the VoIP state. Running the full failed-accept handler also tried to open a DM with the caller on the active workspace, which is not the host the user declined. * fix: send Basic auth to the iframe SSO endpoint only on the server's own origin The iframe login fetch went through the shared headers, so it carried the active workspace's Basic Authorization to whatever host Accounts_Iframe_api_url points at. It now sends the stored Basic auth only when the URL has the same origin as the server. * test: drop dead active-server setup from the probeAuth tests * refactor: restore isLoggedInServer to read only the user id * test: use ~/ imports for collaborators in getServerInfo and getLoginSettings tests * test: move logout test into __tests__ and use ~/ paths in jest.mock calls * test: use fake timers in getServerTimeSync tests to stop leaking the race timeout * test path fix * test: drive the probe handshake through the real SDK so header timing is pinned at WebSocket construction * refactor: rename getBasicAuthHeader module to serverBasicAuth * fix: send /api/info the requested server's own stored session * refactor: read the stored session through getStoredSession in removeServer test: cover the back handler when connecting flips after mount * fix: send each page of the public settings fetch the requested server's own Basic auth * refactor: address review feedback on basic auth and deep-link consent helpers Drop the unreachable early-return applyBasicAuth and its test, fold setBasicAuth into applyBasicAuth, rename the probe test array, and pass isKnownHost to ensureDeepLinkConsent. * fix: time out the add-workspace probe when the host never answers Race the probe against a 30s timer so a host that accepts the connection and never responds can't leave the user stuck on Add workspace, and show a dedicated Connection_timed_out message. * fix: abort the add-workspace probe requests when it times out or is superseded A probe that timed out kept its settings and login-services requests running, so a late reply could overwrite the active workspace's settings. The probe now shares one abort signal across its requests and closes the websocket probe on abort. * using workspace instead of server * some more changes * refactor: share the workspace basic auth helpers and abort the whole add-workspace probe Every per-workspace request now goes through fetchForWorkspace, and the websocket handshake header swap through withBasicAuth, both in serverBasicAuth, so a call site can no longer forget to scope the Basic auth. The probe's abort signal now also reaches the /api/info, unique-id and supported-versions requests; an abort that comes from that signal leaves the store alone instead of failing the active workspace's connection. The NewServerView back handler is back to plain functions with explicit effect deps, the getLoginSettings tests live in getSettings.test.ts, and the fetch spy shared by the basic auth tests is testUtils/mockGlobalFetch. * refactor: drop unrequested renames in logout test and deep-link auto-confirm helper * fix: send the shared Basic auth only to the workspace origin fetch attaches the shared Authorization only to the origin applyBasicAuth recorded it for, and fetchForWorkspace sends the stored Basic auth only to the server's own origin. This replaces the per-call Authorization overrides on the supported-versions lookup and the iframe SSO request, and moves the origin comparison into isSameOrigin next to getOrigin. * refactor: restore the inline session read in removeServer Logout is left for a follow-up, so removeServer reads the stored user id and token the way it did before. * refactor: let the deep-link callers decide whether consent is needed Drops the isKnownHost flag from ensureDeepLinkConsent. handleOpenDifferentServer and handleClickCallPush now skip the prompt for known hosts without a token. * test: move the logout test into __tests__ Uses ~/ paths in the jest.mock calls. * refactor: share the deep-link consent predicate between both callers handleOpenDifferentServer and handleClickCallPush repeated the same "token or unknown host" condition, which pushed handleClickCallPush over the cognitive complexity limit. Name it once as requiresDeepLinkConsent. * refactor: keep the add-workspace probe result typed through the timeout race
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (73)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed changes
Patch release 4.77.1 for single-server: the same cherry-picks as #7779, applied on top of
single-server.rc_token/rc_uid) only when it is on the workspace's origin.All five applied with no conflicts (
NewServerViewauto-merged). The diff between this branch and4.77.1is the same as the existing diff betweensingle-serverand the 4.77.0 release, so the single-server changes are untouched.Issue(s)
https://rocketchat.atlassian.net/browse/NATIVE-1740
How to test or reproduce
rc_token/rc_uid.Screenshots
Types of changes
Checklist
Further comments