feat: import SAML IdP configuration from a metadata URL - #41481
feat: import SAML IdP configuration from a metadata URL#41481ricardogarim wants to merge 3 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 4c12045 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
🚧 Files skipped from review as they are similar to previous changes (14)
📜 Recent review details⏰ Context from checks skipped due to timeout. (8)
|
| Layer / File(s) | Summary |
|---|---|
Metadata contracts and XML parsing packages/rest-typings/src/v1/saml.ts, apps/meteor/server/lib/saml/..., apps/meteor/tests/unit/server/lib/saml/idpMetadata.spec.ts |
Defines metadata request and result types. Parses certificates, SSO/SLO bindings, and NameID formats. Reports warnings and rejects invalid metadata. |
Protected metadata API apps/meteor/server/api/v1/saml.ts, apps/meteor/server/api/index.ts, apps/meteor/tests/end-to-end/api/SAML.ts |
Registers saml.parseMetadata. Applies permission and SSRF checks, fetches bounded remote XML, parses metadata, and maps failures to API errors. |
SAML settings import UI apps/meteor/client/views/admin/settings/..., packages/i18n/src/locales/en.i18n.json, .changeset/fruity-views-begin.md |
Adds the SAML settings page and metadata modal. Displays parsed values and warnings, supports review edits, and applies changed settings with localized messages. |
Estimated code review effort: 4 (Complex) | ~45 minutes
Suggested labels: type: feature, area: authentication
Suggested reviewers: sampaiodiego, cardoso
Sequence Diagram(s)
sequenceDiagram
participant Administrator
participant SAMLGroupPage
participant SamlMetadataModal
participant saml_parseMetadata
participant RemoteIdP
participant parseIdpMetadata
participant EditableSettings
Administrator->>SAMLGroupPage: Select Import metadata
SAMLGroupPage->>SamlMetadataModal: Open modal
Administrator->>SamlMetadataModal: Submit metadata URL
SamlMetadataModal->>saml_parseMetadata: Request metadata
saml_parseMetadata->>RemoteIdP: Fetch XML with SSRF and size controls
RemoteIdP-->>saml_parseMetadata: Return XML
saml_parseMetadata->>parseIdpMetadata: Parse XML
parseIdpMetadata-->>saml_parseMetadata: Values and warnings
saml_parseMetadata-->>SamlMetadataModal: Return parsed metadata
Administrator->>SamlMetadataModal: Review and edit values
SamlMetadataModal->>SAMLGroupPage: Apply values
SAMLGroupPage->>EditableSettings: Dispatch changed settings
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | 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 concisely describes importing SAML IdP configuration from a metadata URL, which is the main change. |
| 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. |
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- Create stacked PR
- Commit on current branch
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- CORE-2305: 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.
Comment @coderabbitai help to get the list of available commands.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #41481 +/- ##
===========================================
- Coverage 69.04% 69.03% -0.01%
===========================================
Files 4224 4228 +4
Lines 166089 166392 +303
Branches 29557 29598 +41
===========================================
+ Hits 114669 114873 +204
- Misses 46261 46353 +92
- Partials 5159 5166 +7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
931c617 to
d1c3a27
Compare
| return idpDescriptor; | ||
| }; | ||
|
|
||
| const extractSigningCert = (idp: Element, warnings: string[]): string | undefined => { |
There was a problem hiding this comment.
I'm not a fan of mutable params. what about returning a tuple?
| const extractSigningCert = (idp: Element, warnings: string[]): string | undefined => { | |
| const extractSigningCert = (idp: Element, warnings: string[]): { value?: string, warning: string } => { |
this applies to other functions on this file as well.. maybe even better would be having a single type and use it as a return type for all functions.
There was a problem hiding this comment.
addressed in 4e32f3a — the four extractors now return a shared ExtractedValue instead of taking the accumulator. also kept the object shape from your snippet rather than a tuple.
| const changes: { _id: string; value: string; changed: boolean }[] = []; | ||
|
|
||
| // identifier_format is only registered on Enterprise installs; skip any setting that isn't present. | ||
| const add = (setting: ISetting | undefined, value?: string): void => { |
There was a problem hiding this comment.
kinda the same here. this function mutates changes that is defined earlier rather than returning a new value, that you could then populate. for example:
// simplified version
const add = (setting, value) => value !== undefined ? [{ _id: setting._id, value }] : [];
const changes = [
...add(certSetting, values.cert),
...add(entryPointSetting, values.entryPoint),
//...
];There was a problem hiding this comment.
addressed in 4e32f3a — add returns an array now and the entries are spread into changes.
| errorHandler: { warning: capture, error: capture, fatalError: capture }, | ||
| }).parseFromString(xml, 'text/xml'); | ||
|
|
||
| if (!doc || parseError) { |
There was a problem hiding this comment.
the type parseError was typed makes it always as null, and I noticed you never uses its value, so why storing the real error if you're always throwing a InvalidIdpMetadataError('invalid-xml')?
There was a problem hiding this comment.
right on both counts. addressed in 4e32f3a and also merged warning, error and fatalError since they are running same code.
| const location = services | ||
| .filter((s) => s.getAttribute('Binding') === REDIRECT_BINDING) | ||
| .map((s) => s.getAttribute('Location')) | ||
| .find((location): location is string => !!location && isHttpUrl(location)); |
There was a problem hiding this comment.
this block is the same as the previous one on line 77, maybe extract to another helper function?
| return !use || use === 'signing'; | ||
| }); | ||
| if (signingKeys.length > 1) { | ||
| warnings.push('SAML_Metadata_warning_multiple_certs'); |
There was a problem hiding this comment.
even though if there are multiple certs, only one is used after SAMLUtils.isValidCertificate(), so is the warning correct? or should the warning be only added if multiple "valid" certificates are present?
| url, | ||
| { | ||
| ignoreSsrfValidation: false, | ||
| allowList: settings.get<string>('SSRF_Allowlist'), |
There was a problem hiding this comment.
are we ok allowing a request to any URL relying only on this setting? I mean, this setting defaults to empty and is not directly related to SAML.
There was a problem hiding this comment.
this follows the pattern already used across the codebase — ldap.testConnection, the apps HTTP bridge, marketplace and avatar-from-URL all do server-side fetches the same way. and SSRF validation is on here (ignoreSsrfValidation: false), so internal targets — localhost, private ranges, the cloud metadata endpoint — are blocked on every redirect hop, which covers the bulk of the risk.
your point about arbitrary public hosts is fair though, so I'll ping the PM to get a call on whether we want a stricter policy.
| const { warnings, ...values } = parseIdpMetadata(xml); | ||
| return API.v1.success({ ...values, warnings }); | ||
| } catch (err) { | ||
| return API.v1.failure('SAML_Metadata_invalid'); |
There was a problem hiding this comment.
worth it adding warning log here as well so people can diagnose WHY the metadata is invalid, either a parse error or even the err prop may carry the proper reason.
| return lines.join('\n'); | ||
| } | ||
|
|
||
| public static isValidCertificate(cert: string): boolean { |
There was a problem hiding this comment.
nitpick: is an expired certificate also "valid"? maybe renaming to isParsableCertificate would be more "honest"?
There was a problem hiding this comment.
renamed for the sake of clarity 😄 addressed in 4e32f3a.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/server/lib/saml/lib/parsers/IdpMetadata.ts`:
- Around line 65-67: Update the certificate extraction in the IdpMetadata parser
to collect every DS_NS X509Certificate element from each KeyDescriptor before
normalization and parsability filtering, rather than selecting only the first
element. Preserve the existing valid-certificate filtering behavior and add a
test covering an invalid first certificate followed by a valid second
certificate within one KeyDescriptor.
🪄 Autofix
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 Plus
Run ID: 5859087a-c2b1-4a59-995e-fca34a695ac1
📒 Files selected for processing (6)
apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SAMLGroupPage.tsxapps/meteor/server/api/v1/saml.tsapps/meteor/server/lib/saml/lib/Utils.tsapps/meteor/server/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/tests/unit/server/lib/saml/idpMetadata.spec.tspackages/i18n/src/locales/en.i18n.json
🚧 Files skipped from review as they are similar to previous changes (4)
- apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SAMLGroupPage.tsx
- apps/meteor/tests/unit/server/lib/saml/idpMetadata.spec.ts
- apps/meteor/server/api/v1/saml.ts
- packages/i18n/src/locales/en.i18n.json
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: 📦 Build Packages
- GitHub Check: cubic · AI code reviewer
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (5)
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
GitHub Check: Dionisio QA: Some checks did not pass
Conclusion: failure
**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/server/lib/saml/lib/Utils.ts
apps/meteor/**
📄 CodeRabbit inference engine (CLAUDE.md)
The main Rocket.Chat Meteor application resides in
apps/meteor/; place its application code there rather than in other monorepo areas.
Files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/server/lib/saml/lib/Utils.ts
🧠 Learnings (17)
📚 Learning: 2026-03-15T14:31:28.969Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:28.969Z
Learning: In RocketChat/Rocket.Chat, the `UserCreateParamsPOST` type in `apps/meteor/app/api/server/v1/users.ts` (migrated from `packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts`) intentionally has `fields: string` (non-optional) and `settings?: IUserSettings` without a corresponding AJV schema entry. This is a pre-existing divergence carried over verbatim from the original rest-typings source (PR `#39647`). Do not flag this type/schema misalignment during the OpenAPI migration review — it is tracked as a separate follow-up fix.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-04-20T17:11:59.452Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 40225
File: apps/meteor/ee/server/apps/communication/endpoints/appLogsHandler.ts:55-71
Timestamp: 2026-04-20T17:11:59.452Z
Learning: In `apps/meteor/ee/server/apps/communication/endpoints/appLogsHandler.ts`, the concern about an empty `?appId=` query param bypassing the truthy check and overriding the path `appId` in the `makeAppLogsQuery` spread is not relevant. The AJV query schema (`isAppLogsProps`) validates and rejects invalid/empty `appId` values before the action handler is reached, making the in-handler guard sufficient as-is. Do not flag this pattern as a vulnerability in future reviews of this file.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-02-24T19:36:55.089Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-04-10T21:17:22.932Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 40096
File: apps/meteor/ee/server/apps/lib/redactor.ts:3-17
Timestamp: 2026-04-10T21:17:22.932Z
Learning: In RocketChat/Rocket.Chat, `X-User-Id` / `x-user-id` headers must NOT be added to redaction paths in apps log redaction (e.g., `apps/meteor/ee/server/apps/lib/redactor.ts`). The maintainer (d-gubert) has confirmed that X-User-Id is an identifier, not a credential — its presence in logs is useful for diagnostics, and `X-Auth-Token` is the only header that constitutes a real secret. Do not suggest redacting X-User-Id in future reviews of this area.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-04-29T19:33:29.434Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40268
File: apps/meteor/client/startup/startup.ts:48-56
Timestamp: 2026-04-29T19:33:29.434Z
Learning: In `apps/meteor/client/startup/startup.ts`, the heuristic `!userIdStore.getState() && localStorage.getItem('Meteor.loginToken') === null` calling `removeLocalUserData()` (which calls `localStorage.clear()`) is intentional. The maintainer (tassoevan) has confirmed this is acceptable even though it fires on fresh first-time visits with no prior login, not just on expired-token resume scenarios. Do not flag this as destructive or suggest narrowing it to specific E2EE keys in future reviews.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-04-30T19:28:55.669Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36350
File: apps/meteor/client/lib/e2ee/rocketchat.e2e.ts:524-552
Timestamp: 2026-04-30T19:28:55.669Z
Learning: In `apps/meteor/client/lib/e2ee/rocketchat.e2e.ts`, the promises returned by `requestPasswordAlert()` and `requestPasswordModal()` are intentionally left unresolved (hanging) when the user dismisses the E2EE password modal ("Do it later" or "X"). Rejecting the promise would propagate to the catch block in `startClient()`, incorrectly triggering the error alert banner ("Wasn't possible to decode your encryption key"). The hanging promise is the correct design to silently stop the E2EE flow on user dismissal without triggering error states.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-02-24T19:05:56.710Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-02-24T19:09:09.561Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2025-11-19T12:32:29.696Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-02-23T17:53:18.785Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2026-03-14T14:58:58.834Z
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Follow DRY (Do not Repeat Yourself) principles by extracting reusable logic into helper functions
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.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/server/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/server/lib/saml/lib/Utils.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/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/server/lib/saml/lib/Utils.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/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/server/lib/saml/lib/Utils.ts
📚 Learning: 2026-08-05T22:02:59.828Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41707
File: apps/meteor/server/hooks/messages/processThreads.ts:66-68
Timestamp: 2026-08-05T22:02:59.828Z
Learning: In Rocket.Chat Meteor server code, `callbacks.runAsync` returns its input item rather than the asynchronous callback promise. Callers of `afterReadMessages` must invoke `callbacks.runAsync` without awaiting it, keeping read-receipt I/O off the message-send path; this includes `apps/meteor/server/hooks/messages/processThreads.ts`.
Applied to files:
apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.tsapps/meteor/server/lib/saml/lib/Utils.ts
🔇 Additional comments (2)
apps/meteor/server/lib/saml/lib/Utils.ts (1)
121-128: LGTM!apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts (1)
17-20: LGTM!Also applies to: 36-57, 78-132
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
4e32f3a to
4c12045
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Proposed changes (including videos or screenshots)
Setting up SAML today means pasting the IdP signing certificate (PEM) into the admin UI by hand — error‑prone and a common source of misconfiguration (raised by customer MIE after a 7.x → 8.5.1 upgrade).
This adds an "Import IdP metadata" button to the SAML settings header (like the LDAP page). The admin pastes the IdP metadata URL, the server fetches and parses it, and the extracted values are shown in an editable preview. On Apply they are prefilled into the settings form for review before Save — nothing is persisted automatically.
Auto‑filled from the IdP
EntityDescriptor:KeyDescriptor use="signing"→X509CertificateSingleSignOnService(HTTP‑Redirect) →LocationSingleLogoutService→LocationNameIDFormatService‑Provider settings (Issuer, Provider, keys, signature options, mappings) are never touched — they describe Rocket.Chat, not the IdP.
Implementation
POST /v1/saml.parseMetadata(test-admin-options) — returns parsed values, never writes settings. Fetch via@rocket.chat/server-fetchwith SSRF validation on (SSRF_Allowlist), a timeout and a size cap.server/lib/saml/lib/parsers/IdpMetadata.ts— parsesEntityDescriptor, validates the cert as X.509 (SAMLUtils.isValidCertificate) and SSO/SLO Locations ashttp(s).SAMLGroupPage(header button, mirrorsLDAPGroupPage) +SamlMetadataModal(aGenericModalform: fetch → editable preview → apply). TheIdentifier Formatrow appears only when that Enterprise setting is registered.Issue(s)
CORE-2305
Steps to test or reproduce
docker compose -f docker-compose.saml-test.yml up -d127.0.0.1:8080to SSRF Allowlist → Save. (use the IP;localhostcan't be allowlisted)http://127.0.0.1:8080/simplesaml/saml2/idp/metadata.php→ Fetch → Apply → Save.docker-compose.saml-test.ymlMetadata URL:
http://127.0.0.1:8080/simplesaml/saml2/idp/metadata.phpFull SAML login + edge cases
End‑to‑end login: set Custom Provider =
test-sp, Custom Issuer =http://localhost:3000/_saml/metadata/test-sp, User Data Mapping{"username":"uid","email":"email","name":"uid"}→ Save → log in via the SAML button withuser1 / user1pass.Edge cases:
SingleLogoutService→ SLO left blank, no error..../federationmetadata/2007-06/federationmetadata.xml) → first used + warning.Further comments
Summary by CodeRabbit