Skip to content

feat: Accounts_OAuth_Flow_Engine Setting#40876

Open
yash-rajpal wants to merge 4 commits into
feat/phishing-resistant-mfafrom
toggle-passport-flow-setting
Open

feat: Accounts_OAuth_Flow_Engine Setting#40876
yash-rajpal wants to merge 4 commits into
feat/phishing-resistant-mfafrom
toggle-passport-flow-setting

Conversation

@yash-rajpal

@yash-rajpal yash-rajpal commented Jun 10, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Adds a new setting Accounts_OAuth_Flow_Engine to toggle between new passport and legacy meteor OAuth flows.

Issue(s)

Steps to test or reproduce

Further comments

Due to some limitations on express and how routing works in our app, as of now we don't have a way of unmounting routes and middlewares when the setting is toggled. So this PR works around this issue by skipping the current route and router on basis of setting value.

PRM-50

Summary by CodeRabbit

  • New Features

    • Added selectable OAuth flow engine (Modern vs Legacy) in settings.
    • OAuth providers (Dolphin, Drupal, GitLab, Nextcloud, WordPress) now support either flow at runtime.
  • Settings

    • New setting entry to choose the OAuth flow engine with descriptive labels.
  • UI

    • Login buttons adapt behavior based on the selected OAuth flow.
  • Localization

    • Added translation keys for the new flow engine setting and descriptions.

@dionisio-bot

dionisio-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c761471

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc3b19f6-3ecb-40fa-ae8f-b8f726770a97

📥 Commits

Reviewing files that changed from the base of the PR and between d37a3ea and c761471.

📒 Files selected for processing (3)
  • apps/meteor/server/configuration/configurePassport.ts
  • apps/meteor/server/settings/oauth.ts
  • packages/i18n/src/locales/en.i18n.json
✅ Files skipped from review due to trivial changes (1)
  • packages/i18n/src/locales/en.i18n.json
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/server/configuration/configurePassport.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/server/configuration/configurePassport.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/server/configuration/configurePassport.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/server/configuration/configurePassport.ts
🔇 Additional comments (2)
apps/meteor/server/settings/oauth.ts (1)

10-11: LGTM!

apps/meteor/server/configuration/configurePassport.ts (1)

87-93: LGTM!


Walkthrough

Adds a selectable Accounts_OAuth_Flow_Engine setting and updates server routes, provider configuration, Passport gating, and client login UI to branch between the legacy Meteor OAuth and a Passport-based flow.

Changes

OAuth Flow Engine Dual-Mode Setup

Layer / File(s) Summary
OAuth Flow Engine Setting and Localization
apps/meteor/server/settings/oauth.ts, packages/i18n/src/locales/en.i18n.json
Registers Accounts_OAuth_Flow_Engine (select: meteor / passport) and adds English i18n keys for the selector and labels.
OAuth Route Handlers with Flow Engine Gating
apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts, apps/meteor/server/lib/oauth/configureOAuthServices.ts
Gates /_oauth routes on Accounts_OAuth_Flow_Engine: run passport.authenticate only when set to 'passport', otherwise skip the router. Adjusts passport.authenticate options (failWithError, remove failureFlash, keep failureRedirect and keepSessionInfo).
Passport Configuration Guard
apps/meteor/server/configuration/configurePassport.ts
Adds an early-return in the Accounts_OAuth_* watcher so OAuth service configuration runs only when Accounts_OAuth_Flow_Engine === 'passport'.
OAuth Provider Conditional Configuration
apps/meteor/app/dolphin/server/lib.ts, apps/meteor/app/drupal/server/lib.ts, apps/meteor/app/gitlab/server/lib.ts, apps/meteor/app/nextcloud/server/lib.ts, apps/meteor/app/wordpress/server/lib.ts
Each provider now instantiates CustomOAuth and builds a merged completeConfig; configuration is chosen at runtime: call addPassportCustomOAuth(...) when flow engine is 'passport', otherwise call CustomOAuth.configure(...). Settings watchers now include Accounts_OAuth_Flow_Engine.
Login UI OAuth Flow Selection
packages/web-ui-registration/src/LoginServices.tsx, packages/web-ui-registration/src/LoginServicesButton.tsx
LoginServices derives enableNewOAuthFlow from Accounts_OAuth_Flow_Engine and passes it to LoginServicesButton; the button gates redirect-to-/oauth/${service} behavior on that flag and updates prop types/deps.

Sequence Diagram

sequenceDiagram
  participant LoginButton as LoginServicesButton
  participant Client as Browser
  participant Server as Rocket.Chat Server
  participant Passport as Passport
  participant CustomOAuth as CustomOAuth.Handler
  participant Provider as OAuth Provider

  LoginButton->>Client: user clicks login
  Client->>Server: GET /_oauth/:provider (or POST login)
  Server->>Passport: passport.authenticate(...) (if flow engine === 'passport')
  alt passport flow
    Passport->>Provider: OAuth handshake
    Provider-->>Passport: callback
    Passport-->>Server: auth result
  else legacy flow
    Server->>CustomOAuth: CustomOAuth.configure/handle
    CustomOAuth->>Provider: OAuth handshake
    Provider-->>CustomOAuth: callback
    CustomOAuth-->>Server: auth result
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#40203: Builds on the introduction of addPassportCustomOAuth and Passport-based provider wiring which this PR gates behind Accounts_OAuth_Flow_Engine.
  • RocketChat/Rocket.Chat#40609: Modifies GitLab OAuth configuration points to use Passport and re-register the strategy on settings changes; overlaps with this PR's GitLab changes.
  • RocketChat/Rocket.Chat#40591: Changes Nextcloud OAuth wiring; related to this PR's Nextcloud provider adjustments.

Suggested labels

area: authentication

Suggested reviewers

  • ricardogarim
  • KevLehman
  • abhinavkrin
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: introducing a new setting called Accounts_OAuth_Flow_Engine that toggles between OAuth flow implementations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • PRM-50: Request failed with status code 401

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

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

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat/phishing-resistant-mfa@8f3741d). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                      Coverage Diff                       @@
##             feat/phishing-resistant-mfa   #40876   +/-   ##
==============================================================
  Coverage                               ?   69.63%           
==============================================================
  Files                                  ?     3339           
  Lines                                  ?   123320           
  Branches                               ?    21981           
==============================================================
  Hits                                   ?    85876           
  Misses                                 ?    34077           
  Partials                               ?     3367           
Flag Coverage Δ
e2e 59.22% <ø> (?)
e2e-api 45.70% <18.18%> (?)
unit 70.48% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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.

@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label Jun 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/app/nextcloud/server/lib.ts (1)

23-45: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing passport.unuse('nextcloud') before reconfiguration.

Unlike the other provider implementations (Dolphin, Drupal, GitLab, WordPress), this file does not call passport.unuse('nextcloud') at the start of the configuration function. When switching from passport to meteor flow engine, the stale Passport strategy will remain registered, potentially causing unexpected behavior.

🔧 Proposed fix
+import passport from 'passport';
+
 function configureNextcloudOAuth(): void {
+	passport.unuse('nextcloud');
+
 	const enabled = settings.get<boolean>('Accounts_OAuth_Nextcloud');
🤖 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 `@apps/meteor/app/nextcloud/server/lib.ts` around lines 23 - 45, In
configureNextcloudOAuth add a step to unregister any existing Passport strategy
for 'nextcloud' before applying new configuration: call
passport.unuse('nextcloud') (ensure passport is imported or available) at the
start of the function so stale Passport strategies are removed when switching
flow engines; keep this in place whether you then call
addPassportCustomOAuth('nextcloud', config) or Nextcloud.configure(config) to
match the pattern used by other providers.
🧹 Nitpick comments (2)
apps/meteor/server/settings/oauth.ts (2)

10-11: ⚡ Quick win

Clarify user-facing labels for the OAuth flow options.

The labels 'Meteor' and 'New flow' may not clearly convey the choice to administrators. 'New flow' is particularly vague—consider more descriptive labels such as 'Legacy (Meteor)' and 'Modern (Passport)' or use i18n keys for proper localization and clarity.

📝 Suggested improvement
 		await this.add('Accounts_OAuth_Flow_Engine', 'meteor', {
 			type: 'select',
 			values: [
-				{ key: 'meteor', i18nLabel: 'Meteor' },
-				{ key: 'passport', i18nLabel: 'New flow' },
+				{ key: 'meteor', i18nLabel: 'Legacy (Meteor)' },
+				{ key: 'passport', i18nLabel: 'Modern (Passport)' },
 			],
 			public: true,
 			i18nDescription: 'Accounts_OAuth_Flow_Engine_Description',
 		});

Or use i18n keys for proper localization:

 		await this.add('Accounts_OAuth_Flow_Engine', 'meteor', {
 			type: 'select',
 			values: [
-				{ key: 'meteor', i18nLabel: 'Meteor' },
-				{ key: 'passport', i18nLabel: 'New flow' },
+				{ key: 'meteor', i18nLabel: 'Accounts_OAuth_Flow_Engine_Meteor' },
+				{ key: 'passport', i18nLabel: 'Accounts_OAuth_Flow_Engine_Passport' },
 			],
 			public: true,
 			i18nDescription: 'Accounts_OAuth_Flow_Engine_Description',
 		});
🤖 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 `@apps/meteor/server/settings/oauth.ts` around lines 10 - 11, The user-facing
labels for the OAuth flow options are ambiguous; update the entries in the
options array (the objects with key: 'meteor' and key: 'passport') to use
clearer labels such as "Legacy (Meteor)" and "Modern (Passport)" or replace the
hardcoded i18nLabel strings with appropriate i18n keys (e.g., i18nLabel:
'oauth.label.legacy' / 'oauth.label.modern') so administrators see a clear,
localizable choice between the Meteor and Passport flows; ensure you update any
corresponding translation files if you opt for i18n keys.

7-15: Confirm i18n description key + refine label wording

  • i18nDescription: 'Accounts_OAuth_Flow_Engine_Description' is present in packages/i18n/src/locales/en.i18n.json, so the admin UI description won’t be missing.
  • Consider replacing the New flow option label with more descriptive text (e.g., “Passport-based flow”) to improve admin UX.
🤖 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 `@apps/meteor/server/settings/oauth.ts` around lines 7 - 15, Confirm that the
i18n key Accounts_OAuth_Flow_Engine_Description exists (it does) and update the
select option label for key 'passport' in the add call for
'Accounts_OAuth_Flow_Engine' to a more descriptive string such as
"Passport-based flow" (or similar) to improve admin UX; locate the values array
inside the await this.add('Accounts_OAuth_Flow_Engine', 'meteor', { ... }) call
and replace the i18nLabel or displayed label for the { key: 'passport',
i18nLabel: 'New flow' } entry accordingly, ensuring any corresponding i18n key
is added/updated if you change to a translatable label.
🤖 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.

Inline comments:
In `@apps/meteor/app/wordpress/server/lib.ts`:
- Around line 72-78: The WordPress passport branch passes a config missing
clientId/clientSecret to addPassportCustomOAuth, so update the code that
prepares WordPress's config (the same way other providers do) to read clientId
and clientSecret from settings (via settings.get) and merge them into the config
object before calling addPassportCustomOAuth(serviceKey, config); ensure the
final object contains clientId and clientSecret keys so addPassportCustomOAuth's
early-return check finds them.

In `@apps/meteor/server/configuration/configurePassport.ts`:
- Around line 25-33: The current configureOAuth function short-circuits when
Accounts_OAuth_Flow_Engine !== 'passport', leaving any previously-registered
Passport state active; update configureOAuth to detect a transition away from
'passport' and perform teardown: call passport.unuse for any strategies
previously registered (track strategy names created by
createOAuthServiceConfig/configureOAuthServices or derive them from
getOAuthServices), remove or disable Passport-specific routes/middleware that
configureOAuthServices added, and ensure future calls re-register cleanly when
switching back; reference configureOAuth, getOAuthServices,
createOAuthServiceConfig, configureOAuthServices and use passport.unuse (and
route-level gating cleanup) to implement the teardown path.

In `@apps/meteor/server/lib/oauth/configureOAuthServices.ts`:
- Line 84: Remove the noisy console.log in the OAuth callback middleware: locate
the "console.log('In check middleware')" call inside the OAuth callback handling
(the middleware registered in configureOAuthServices / the "check" middleware)
and delete it, or replace it with a conditional debug/log.debug call controlled
by environment or log level if you need traceability; ensure no unconditional
console logging remains in that middleware so production auth callbacks stay
quiet.

---

Outside diff comments:
In `@apps/meteor/app/nextcloud/server/lib.ts`:
- Around line 23-45: In configureNextcloudOAuth add a step to unregister any
existing Passport strategy for 'nextcloud' before applying new configuration:
call passport.unuse('nextcloud') (ensure passport is imported or available) at
the start of the function so stale Passport strategies are removed when
switching flow engines; keep this in place whether you then call
addPassportCustomOAuth('nextcloud', config) or Nextcloud.configure(config) to
match the pattern used by other providers.

---

Nitpick comments:
In `@apps/meteor/server/settings/oauth.ts`:
- Around line 10-11: The user-facing labels for the OAuth flow options are
ambiguous; update the entries in the options array (the objects with key:
'meteor' and key: 'passport') to use clearer labels such as "Legacy (Meteor)"
and "Modern (Passport)" or replace the hardcoded i18nLabel strings with
appropriate i18n keys (e.g., i18nLabel: 'oauth.label.legacy' /
'oauth.label.modern') so administrators see a clear, localizable choice between
the Meteor and Passport flows; ensure you update any corresponding translation
files if you opt for i18n keys.
- Around line 7-15: Confirm that the i18n key
Accounts_OAuth_Flow_Engine_Description exists (it does) and update the select
option label for key 'passport' in the add call for 'Accounts_OAuth_Flow_Engine'
to a more descriptive string such as "Passport-based flow" (or similar) to
improve admin UX; locate the values array inside the await
this.add('Accounts_OAuth_Flow_Engine', 'meteor', { ... }) call and replace the
i18nLabel or displayed label for the { key: 'passport', i18nLabel: 'New flow' }
entry accordingly, ensuring any corresponding i18n key is added/updated if you
change to a translatable label.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3dcc3eea-364f-4a5c-b26b-d6496c9f28ed

📥 Commits

Reviewing files that changed from the base of the PR and between 8f3741d and 1abed54.

📒 Files selected for processing (12)
  • apps/meteor/app/dolphin/server/lib.ts
  • apps/meteor/app/drupal/server/lib.ts
  • apps/meteor/app/gitlab/server/lib.ts
  • apps/meteor/app/nextcloud/server/lib.ts
  • apps/meteor/app/wordpress/server/lib.ts
  • apps/meteor/server/configuration/configurePassport.ts
  • apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
  • apps/meteor/server/lib/oauth/configureOAuthServices.ts
  • apps/meteor/server/settings/oauth.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/web-ui-registration/src/LoginServices.tsx
  • packages/web-ui-registration/src/LoginServicesButton.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/web-ui-registration/src/LoginServices.tsx
  • apps/meteor/app/wordpress/server/lib.ts
  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/app/gitlab/server/lib.ts
  • packages/web-ui-registration/src/LoginServicesButton.tsx
  • apps/meteor/app/drupal/server/lib.ts
  • apps/meteor/app/dolphin/server/lib.ts
  • apps/meteor/server/lib/oauth/configureOAuthServices.ts
  • apps/meteor/app/nextcloud/server/lib.ts
  • apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
  • apps/meteor/server/configuration/configurePassport.ts
🧠 Learnings (4)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • packages/web-ui-registration/src/LoginServices.tsx
  • packages/web-ui-registration/src/LoginServicesButton.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/web-ui-registration/src/LoginServices.tsx
  • apps/meteor/app/wordpress/server/lib.ts
  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/app/gitlab/server/lib.ts
  • packages/web-ui-registration/src/LoginServicesButton.tsx
  • apps/meteor/app/drupal/server/lib.ts
  • apps/meteor/app/dolphin/server/lib.ts
  • apps/meteor/server/lib/oauth/configureOAuthServices.ts
  • apps/meteor/app/nextcloud/server/lib.ts
  • apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
  • apps/meteor/server/configuration/configurePassport.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/app/wordpress/server/lib.ts
  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/app/gitlab/server/lib.ts
  • apps/meteor/app/drupal/server/lib.ts
  • apps/meteor/app/dolphin/server/lib.ts
  • apps/meteor/server/lib/oauth/configureOAuthServices.ts
  • apps/meteor/app/nextcloud/server/lib.ts
  • apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
  • apps/meteor/server/configuration/configurePassport.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/app/wordpress/server/lib.ts
  • apps/meteor/server/settings/oauth.ts
  • apps/meteor/app/gitlab/server/lib.ts
  • apps/meteor/app/drupal/server/lib.ts
  • apps/meteor/app/dolphin/server/lib.ts
  • apps/meteor/server/lib/oauth/configureOAuthServices.ts
  • apps/meteor/app/nextcloud/server/lib.ts
  • apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts
  • apps/meteor/server/configuration/configurePassport.ts
🔇 Additional comments (10)
packages/i18n/src/locales/en.i18n.json (1)

361-362: LGTM!

Also applies to: 7258-7258

packages/web-ui-registration/src/LoginServices.tsx (1)

21-21: LGTM!

Also applies to: 56-62

packages/web-ui-registration/src/LoginServicesButton.tsx (1)

23-23: LGTM!

Also applies to: 29-29, 35-35, 56-56

apps/meteor/server/configuration/configurePassport.ts (1)

100-102: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Accounts_OAuth_Flow_Engine is watched twice, causing duplicate reconfiguration.

The regex watcher at Line 96 already matches Accounts_OAuth_Flow_Engine, so Lines 100-102 invoke configureOAuth a second time per toggle. Since route registration is additive, this can duplicate handlers.

Suggested fix
-	settings.watch('Accounts_OAuth_Flow_Engine', () => {
-		configureOAuth(settings);
-	});
			> Likely an incorrect or invalid review comment.
apps/meteor/server/lib/oauth/addPassportCustomOAuth.ts (1)

50-58: LGTM!

apps/meteor/app/dolphin/server/lib.ts (1)

10-10: LGTM!

Also applies to: 26-27, 52-59, 63-72

apps/meteor/app/drupal/server/lib.ts (1)

7-7: LGTM!

Also applies to: 11-11, 26-27, 43-51, 58-58

apps/meteor/app/gitlab/server/lib.ts (1)

7-7: LGTM!

Also applies to: 22-23, 42-50, 64-64

apps/meteor/app/nextcloud/server/lib.ts (1)

5-5: LGTM!

Also applies to: 9-9, 21-22, 50-56

apps/meteor/app/wordpress/server/lib.ts (1)

8-8: LGTM!

Also applies to: 24-25, 98-99

Comment thread apps/meteor/app/wordpress/server/lib.ts
Comment thread apps/meteor/server/configuration/configurePassport.ts Outdated
Comment thread apps/meteor/server/lib/oauth/configureOAuthServices.ts Outdated
@yash-rajpal yash-rajpal marked this pull request as ready for review June 10, 2026 13:41
@yash-rajpal yash-rajpal requested a review from a team as a code owner June 10, 2026 13:41
@coderabbitai coderabbitai Bot added area: authentication and removed type: feature Pull requests that introduces new feature labels Jun 10, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

5 issues found across 12 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/app/wordpress/server/lib.ts
Comment thread apps/meteor/app/gitlab/server/lib.ts
Comment thread apps/meteor/server/lib/oauth/configureOAuthServices.ts
Comment thread apps/meteor/server/configuration/configurePassport.ts Outdated
Comment thread packages/web-ui-registration/src/LoginServices.tsx

@hacktron-app hacktron-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Severity Count
MEDIUM 1

View full scan results

Comment on lines +7 to +16
await this.add('Accounts_OAuth_Flow_Engine', 'meteor', {
type: 'select',
values: [
{ key: 'meteor', i18nLabel: 'Legacy_Meteor_OAuth' },
{ key: 'passport', i18nLabel: 'Modern_OAuth_System_Browser_and_Deep_Links_Recommended' },
],
public: true,
i18nDescription: 'Accounts_OAuth_Flow_Engine_Description',
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MEDIUM Sensitive OAuth Credentials (Nextcloud Client Secret and Apple Private Key) Missing secret: true Flag

In Rocket.Chat, settings are registered with metadata that controls how they are handled by the system. The secret: true option is used to mark highly sensitive settings (such as API keys, passwords, and client secrets) so that the platform can apply special protections, such as redacting them in logs, excluding them from certain API responses, or masking them in diagnostic exports.

An analysis of apps/meteor/server/settings/oauth.ts reveals that while almost all OAuth provider secrets (such as Google, GitHub, Facebook, Twitter, and LinkedIn) are correctly registered with the secret: true option, the following two highly sensitive credentials are missing this flag:

  1. Accounts_OAuth_Apple_secretKey (the private key used for Apple Sign-In authentication)
  2. Accounts_OAuth_Nextcloud_secret (the client secret used for Nextcloud OAuth authentication)

Because these settings lack the secret: true metadata, they are treated as standard non-sensitive settings. This can lead to the exposure of the Nextcloud Client Secret and the Apple Private Key in plain text in logs, diagnostic reports, or settings export APIs, allowing an attacker with access to these outputs to compromise the OAuth integration or impersonate the server to the identity providers.

Steps to Reproduce

Reviewing apps/meteor/server/settings/oauth.ts shows the discrepancy between Nextcloud/Apple and other OAuth providers:

// Drupal (Correct)
await this.add('Accounts_OAuth_Drupal_secret', '', { type: 'string', enableQuery, secret: true });

// Apple (Vulnerable - missing secret: true)
await this.add('Accounts_OAuth_Apple_secretKey', '', { type: 'string', multiline: true });

// Nextcloud (Vulnerable - missing secret: true)
await this.add('Accounts_OAuth_Nextcloud_secret', '', { type: 'string', enableQuery });
Fix with AI

Open in Cursor Open in Claude

A security vulnerability was found by Hacktron.

File: apps/meteor/server/settings/oauth.ts
Lines: 7-16
Severity: medium

Vulnerability: Sensitive OAuth Credentials (Nextcloud Client Secret and Apple Private Key) Missing secret: true Flag

Description:
In Rocket.Chat, settings are registered with metadata that controls how they are handled by the system. The `secret: true` option is used to mark highly sensitive settings (such as API keys, passwords, and client secrets) so that the platform can apply special protections, such as redacting them in logs, excluding them from certain API responses, or masking them in diagnostic exports.

An analysis of `apps/meteor/server/settings/oauth.ts` reveals that while almost all OAuth provider secrets (such as Google, GitHub, Facebook, Twitter, and LinkedIn) are correctly registered with the `secret: true` option, the following two highly sensitive credentials are missing this flag:
1. `Accounts_OAuth_Apple_secretKey` (the private key used for Apple Sign-In authentication)
2. `Accounts_OAuth_Nextcloud_secret` (the client secret used for Nextcloud OAuth authentication)

Because these settings lack the `secret: true` metadata, they are treated as standard non-sensitive settings. This can lead to the exposure of the Nextcloud Client Secret and the Apple Private Key in plain text in logs, diagnostic reports, or settings export APIs, allowing an attacker with access to these outputs to compromise the OAuth integration or impersonate the server to the identity providers.

Proof of Concept:
Reviewing `apps/meteor/server/settings/oauth.ts` shows the discrepancy between Nextcloud/Apple and other OAuth providers:

```typescript
// Drupal (Correct)
await this.add('Accounts_OAuth_Drupal_secret', '', { type: 'string', enableQuery, secret: true });

// Apple (Vulnerable - missing secret: true)
await this.add('Accounts_OAuth_Apple_secretKey', '', { type: 'string', multiline: true });

// Nextcloud (Vulnerable - missing secret: true)
await this.add('Accounts_OAuth_Nextcloud_secret', '', { type: 'string', enableQuery });
```

Affected Code:
- [oauth.ts:43](https://github.com/RocketChat/Rocket.Chat/blob/master/apps/meteor/server/settings/oauth.ts#L43)
```typescript
await this.add('Accounts_OAuth_Apple_secretKey', '', { type: 'string', multiline: true });
```
- [oauth.ts:113](https://github.com/RocketChat/Rocket.Chat/blob/master/apps/meteor/server/settings/oauth.ts#L113)
```typescript
await this.add('Accounts_OAuth_Nextcloud_secret', '', { type: 'string', enableQuery });
```

Acceptance criteria:
- Acceptance is defined by the **actual reported behavior**, not by tests passing.
- Reproduce the issue, or narrow the exact code path that produces it, *before* changing code. State what you confirmed.
- Fix the underlying cause. Mitigations that paper over the reported behavior do not count as a fix.
- Add a regression test that fails on the unpatched code and passes on the fix. If a regression test is genuinely impractical (e.g. race condition, infra-level issue), say so and explain why.
- Existing tests passing is **not** the bar. Do not declare done on tests-pass theatre.

Only change what is necessary to fix this vulnerability. Do not refactor adjacent code or modify unrelated files.

Triage: Reply !fp <reason> (false positive), !valid (confirmed), or !accepted_risk <reason>. Any other reply is saved as a triage note.
Reason is optional but improves future scans — e.g. !fp internal endpoint, not user-facing.

View finding in Hacktron

@coderabbitai coderabbitai Bot added type: feature Pull requests that introduces new feature and removed area: authentication labels Jun 10, 2026
Comment thread apps/meteor/server/settings/oauth.ts
Comment thread apps/meteor/app/nextcloud/server/lib.ts
Comment thread apps/meteor/server/lib/oauth/configureOAuthServices.ts
Comment thread apps/meteor/server/configuration/configurePassport.ts Outdated
@coderabbitai coderabbitai Bot added area: authentication and removed type: feature Pull requests that introduces new feature labels Jun 10, 2026
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication stat: QA assured Means it has been tested and approved by a company insider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants