Skip to content

feat: import SAML IdP configuration from a metadata URL - #41481

Open
ricardogarim wants to merge 3 commits into
developfrom
feat/saml-metadata-import
Open

feat: import SAML IdP configuration from a metadata URL#41481
ricardogarim wants to merge 3 commits into
developfrom
feat/saml-metadata-import

Conversation

@ricardogarim

@ricardogarim ricardogarim commented Jul 20, 2026

Copy link
Copy Markdown
Member

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:

Metadata Setting
KeyDescriptor use="signing"X509Certificate Custom Certificate
SingleSignOnService (HTTP‑Redirect) → Location Custom Entry Point
SingleLogoutServiceLocation IDP SLO Redirect URL
NameIDFormat Identifier Format (Enterprise)

Service‑Provider settings (Issuer, Provider, keys, signature options, mappings) are never touched — they describe Rocket.Chat, not the IdP.

Implementation
  • Endpoint POST /v1/saml.parseMetadata (test-admin-options) — returns parsed values, never writes settings. Fetch via @rocket.chat/server-fetch with SSRF validation on (SSRF_Allowlist), a timeout and a size cap.
  • Parser server/lib/saml/lib/parsers/IdpMetadata.ts — parses EntityDescriptor, validates the cert as X.509 (SAMLUtils.isValidCertificate) and SSO/SLO Locations as http(s).
  • UISAMLGroupPage (header button, mirrors LDAPGroupPage) + SamlMetadataModal (a GenericModal form: fetch → editable preview → apply). The Identifier Format row appears only when that Enterprise setting is registered.

Issue(s)

CORE-2305

Steps to test or reproduce

  1. Start a test IdP (details below): docker compose -f docker-compose.saml-test.yml up -d
  2. Admin → General → SSRF Protection → add 127.0.0.1:8080 to SSRF Allowlist → Save. (use the IP; localhost can't be allowlisted)
  3. Admin → SAML → enable → Import IdP metadata → paste http://127.0.0.1:8080/simplesaml/saml2/idp/metadata.phpFetchApplySave.
docker-compose.saml-test.yml
services:
  saml-idp:
    image: kristophjunge/test-saml-idp
    ports: ["8080:8080", "8443:8443"]
    environment:
      SIMPLESAMLPHP_SP_ENTITY_ID: http://localhost:3000/_saml/metadata/test-sp
      SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE: http://localhost:3000/_saml/validate/test-sp
      SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE: http://localhost:3000/_saml/logout/test-sp

Metadata URL: http://127.0.0.1:8080/simplesaml/saml2/idp/metadata.php

Full 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 with user1 / user1pass.

Edge cases:

  • No SingleLogoutService → SLO left blank, no error.
  • Multiple signing certs (e.g. Azure AD .../federationmetadata/2007-06/federationmetadata.xml) → first used + warning.
  • HTML / non‑metadata → "not valid SAML IdP metadata".
  • Private / non‑allowlisted host → SSRF‑blocked error pointing to the allowlist.

Further comments

Review in cubic

Summary by CodeRabbit

  • New Features
    • Added an “Import metadata” option to SAML settings.
    • Administrators can enter an Identity Provider metadata URL and review prefilled certificate, entry point, SLO redirect URL, and identifier format values before saving.
  • Security
    • Added protections against unsafe metadata URLs and restricted access to authorized administrators.
  • Bug Fixes
    • Added validation feedback, warnings, retry support, and handling for invalid, inaccessible, or oversized metadata.
  • Documentation
    • Added guidance to review imported values before saving.

@dionisio-bot

dionisio-bot Bot commented Jul 20, 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 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@ricardogarim ricardogarim added this to the 8.8.0 milestone Jul 20, 2026
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4c12045

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@rocket.chat/rest-typings Patch
@rocket.chat/i18n Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch

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

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9abc313e-42a9-4c09-9b1e-5be808de61a2

📥 Commits

Reviewing files that changed from the base of the PR and between 742009a and 4c12045.

📒 Files selected for processing (15)
  • .changeset/fruity-views-begin.md
  • apps/meteor/client/views/admin/settings/SettingsGroupSelector/SettingsGroupSelector.tsx
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SAMLGroupPage.tsx
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.spec.tsx
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.tsx
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/index.ts
  • apps/meteor/server/api/index.ts
  • apps/meteor/server/api/v1/saml.ts
  • apps/meteor/server/lib/saml/lib/Utils.ts
  • apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
  • apps/meteor/tests/end-to-end/api/SAML.ts
  • apps/meteor/tests/unit/server/lib/saml/idpMetadata.spec.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/rest-typings/src/index.ts
  • packages/rest-typings/src/v1/saml.ts
🚧 Files skipped from review as they are similar to previous changes (14)
  • apps/meteor/client/views/admin/settings/SettingsGroupSelector/SettingsGroupSelector.tsx
  • .changeset/fruity-views-begin.md
  • apps/meteor/tests/end-to-end/api/SAML.ts
  • apps/meteor/server/api/index.ts
  • packages/rest-typings/src/index.ts
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/index.ts
  • apps/meteor/tests/unit/server/lib/saml/idpMetadata.spec.ts
  • packages/rest-typings/src/v1/saml.ts
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SAMLGroupPage.tsx
  • packages/i18n/src/locales/en.i18n.json
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.spec.tsx
  • apps/meteor/server/api/v1/saml.ts
  • apps/meteor/server/lib/saml/lib/Utils.ts
  • apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (5)

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**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

View job details

**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

View job details

**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

View job details

**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

View job details

**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/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.tsx
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/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.tsx
🧠 Learnings (3)
📚 Learning: 2026-08-12T20:25:04.260Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41481
File: apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts:65-67
Timestamp: 2026-08-12T20:25:04.260Z
Learning: In `apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts`, multiple DS_NS `X509Certificate` elements within one `X509Data` represent a certificate chain, where the first certificate is the leaf certificate and later certificates can be CA certificates. Alternative signing certificates are represented by separate `KeyDescriptor` elements. Do not flatten certificates within a `KeyDescriptor`, because doing so can select a CA certificate and produce a false multiple-certificate warning.

Applied to files:

  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.tsx
📚 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:

  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.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:

  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.tsx
🔇 Additional comments (1)
apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SamlMetadataModal.tsx (1)

106-115: 🎯 Functional Correctness



Walkthrough

Adds SAML IdP metadata parsing, a protected saml.parseMetadata endpoint, and an administrator UI that reviews and applies parsed settings.

Changes

SAML metadata import

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
Loading
🚥 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 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.

❤️ Share

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

@coderabbitai coderabbitai Bot added area: authentication type: feature Pull requests that introduces new feature labels Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.14851% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.03%. Comparing base (742009a) to head (4c12045).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 58.78% <4.05%> (-0.15%) ⬇️
e2e-api 45.68% <20.68%> (-0.37%) ⬇️
unit 71.00% <97.64%> (+0.06%) ⬆️

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.

@ricardogarim
ricardogarim marked this pull request as ready for review July 20, 2026 19:26
@ricardogarim
ricardogarim requested review from a team as code owners July 20, 2026 19:26

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

All reported issues were addressed across 15 files

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

Re-trigger cubic

Comment thread packages/rest-typings/src/v1/saml.ts
Comment thread apps/meteor/server/api/v1/saml.ts
Comment thread apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts Outdated
Comment thread apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts Outdated

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

All reported issues were addressed across 3 files (changes from recent commits).

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

Re-trigger cubic

Comment thread apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts Outdated
@ricardogarim
ricardogarim force-pushed the feat/saml-metadata-import branch from 931c617 to d1c3a27 Compare August 10, 2026 19:05
cardoso
cardoso previously approved these changes Aug 12, 2026
return idpDescriptor;
};

const extractSigningCert = (idp: Element, warnings: string[]): string | undefined => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not a fan of mutable params. what about returning a tuple?

Suggested change
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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),
    //...
];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed in 4e32f3aadd 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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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')?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

right on both counts. addressed in 4e32f3a and also merged warning, error and fatalError since they are running same code.

Comment on lines +93 to +96
const location = services
.filter((s) => s.getAttribute('Binding') === REDIRECT_BINDING)
.map((s) => s.getAttribute('Location'))
.find((location): location is string => !!location && isHttpUrl(location));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this block is the same as the previous one on line 77, maybe extract to another helper function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed in 4e32f3a.

return !use || use === 'signing';
});
if (signingKeys.length > 1) {
warnings.push('SAML_Metadata_warning_multiple_certs');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed in 4e32f3a.

url,
{
ignoreSsrfValidation: false,
allowList: settings.get<string>('SSRF_Allowlist'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed in 4e32f3a.

return lines.join('\n');
}

public static isValidCertificate(cert: string): boolean {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: is an expired certificate also "valid"? maybe renaming to isParsableCertificate would be more "honest"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

renamed for the sake of clarity 😄 addressed in 4e32f3a.

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between d1c3a27 and 4e32f3a.

📒 Files selected for processing (6)
  • apps/meteor/client/views/admin/settings/groups/SAMLGroupPage/SAMLGroupPage.tsx
  • apps/meteor/server/api/v1/saml.ts
  • apps/meteor/server/lib/saml/lib/Utils.ts
  • apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
  • apps/meteor/tests/unit/server/lib/saml/idpMetadata.spec.ts
  • packages/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

View job details

**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

View job details

**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

View job details

**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

View job details

**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

View job details

**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.ts
  • apps/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.ts
  • apps/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.ts
  • apps/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.ts
  • apps/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.ts
  • apps/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.ts
  • apps/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

Comment thread apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts

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

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

Comment thread apps/meteor/server/lib/saml/lib/parsers/IdpMetadata.ts
@ricardogarim
ricardogarim force-pushed the feat/saml-metadata-import branch from 4e32f3a to 4c12045 Compare August 12, 2026 21:16
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants