Skip to content

feat(backend): Deprecate domain field in favor of domains on SAML connections/account #6186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NicolasLopes7
Copy link
Contributor

@NicolasLopes7 NicolasLopes7 commented Jun 24, 2025

Description

This commit deprecates the existing domain field, and introduces a new domains field on both models:

  • SAML connection
  • SAML account

It also updates the create and update params to support the new fields

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added support for specifying multiple domains in SAML connections via a new domains field.
  • Deprecation Notice

    • The existing domain field is now deprecated and will be removed in a future release; users are encouraged to transition to the new domains field.
  • Documentation

    • Updated documentation to reflect the deprecation and provide guidance on using the new domains field.

Copy link

changeset-bot bot commented Jun 24, 2025

🦋 Changeset detected

Latest commit: b0f8cc3

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

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Minor
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing 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

Copy link

vercel bot commented Jun 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2025 1:22pm

… connection and account

This commit deprecates the existing `domain` field, and introduces a new field on both models:
- SAML connection
- SAML account

It also updates the create and update params to support the new fields
@NicolasLopes7 NicolasLopes7 force-pushed the nicolas/saml-connections-domains-field branch from 97982f0 to 653e04d Compare June 24, 2025 13:19
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

📝 Walkthrough

Walkthrough

This change introduces support for multiple domains in SAML connections within the @clerk/backend package. A new domains array property is added to relevant type definitions, interfaces, and classes, allowing multiple domains to be specified. The existing domain string property is now marked as deprecated across types, interfaces, and classes, with documentation and comments indicating its planned removal in a future API version. Constructors and static methods are updated to handle the new domains property, while maintaining backward compatibility with the deprecated domain field. No changes were made to logic or control flow.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/lucky-spoons-wonder.md (1)

5-5: Fix grammatical issues in the changeset description.

The static analysis tools have identified two grammatical issues that should be corrected for professional documentation:

  1. Add a comma before "but" when connecting two independent clauses
  2. Use "in" instead of "on" for the phrase "in a future API version"
-Deprecates `domain` field and introduce `domains`. Now, SAML connections support multiple domains, the `domain` field still supported but it's deprecated and will be removed on a future API version.
+Deprecates `domain` field and introduce `domains`. Now, SAML connections support multiple domains, the `domain` field still supported, but it's deprecated and will be removed in a future API version.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55e8fca and b0f8cc3.

📒 Files selected for processing (4)
  • .changeset/lucky-spoons-wonder.md (1 hunks)
  • packages/backend/src/api/endpoints/SamlConnectionApi.ts (2 hunks)
  • packages/backend/src/api/resources/JSON.ts (2 hunks)
  • packages/backend/src/api/resources/SamlConnection.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
`**/*.{js,ts,tsx,jsx}`: All code must pass ESLint checks with the project's configuration. Use Prettier for consistent code formatting.

**/*.{js,ts,tsx,jsx}: All code must pass ESLint checks with the project's configuration.
Use Prettier for consistent code formatting.

  • packages/backend/src/api/resources/SamlConnection.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/endpoints/SamlConnectionApi.ts
`**/*.{ts,tsx}`: Maintain comprehensive JSDoc comments for public APIs.

**/*.{ts,tsx}: Maintain comprehensive JSDoc comments for public APIs.

  • packages/backend/src/api/resources/SamlConnection.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/endpoints/SamlConnectionApi.ts
`packages/**`: All publishable packages under the @clerk namespace must be located in the packages/ directory.

packages/**: All publishable packages under the @clerk namespace must be located in the packages/ directory.

  • packages/backend/src/api/resources/SamlConnection.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/endpoints/SamlConnectionApi.ts
`**/*.ts`: Always define explicit return types for functions, especially public APIs. Use proper type annotations for variables and parameters where inference isn't clear. Avoid `a...

**/*.ts: Always define explicit return types for functions, especially public APIs.
Use proper type annotations for variables and parameters where inference isn't clear.
Avoid any type; prefer unknown when type is uncertain, then narrow with type guards.
Use interface for object shapes that might be extended; use type for unions, primitives, and computed types.
Prefer readonly properties for immutable data structures.
Use private for internal implementation details, protected for inheritance, and public explicitly for clarity in public APIs.
Prefer composition and interfaces over deep inheritance chains; use mixins for shared behavior.
Use ES6 imports/exports consistently; avoid barrel files (index.ts re-exports) to prevent circular dependencies.
Use type-only imports (import type { ... }) where possible.
Use as const for literal types and the satisfies operator for type checking without widening.
Enable --incremental and --tsBuildInfoFile for faster builds.
Use ESLint with @typescript-eslint/recommended rules and Prettier for formatting.
Use lint-staged and Husky for pre-commit checks.
Use type-coverage to measure type safety.

  • packages/backend/src/api/resources/SamlConnection.ts
  • packages/backend/src/api/resources/JSON.ts
  • packages/backend/src/api/endpoints/SamlConnectionApi.ts
🪛 LanguageTool
.changeset/lucky-spoons-wonder.md

[uncategorized] ~5-~5: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...ains, the domain field still supported but it's deprecated and will be removed on ...

(COMMA_COMPOUND_SENTENCE)


[uncategorized] ~5-~5: The preposition “in” seems more likely in this position than the preposition “on”.
Context: ...but it's deprecated and will be removed on a future API version.

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION_ON_IN)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
packages/backend/src/api/resources/JSON.ts (2)

634-634: LGTM! Proper addition of domains array support.

The addition of the domains: string[] property to the SamlConnectionJSON interface correctly implements the new multiple domains feature while maintaining backward compatibility with the existing domain property.


692-692: LGTM! Consistent implementation across SAML account connection interface.

The addition of the domains: string[] property to the SamlAccountConnectionJSON interface is consistent with the changes made to SamlConnectionJSON and properly supports the new multiple domains functionality.

packages/backend/src/api/endpoints/SamlConnectionApi.ts (2)

16-18: LGTM! Proper deprecation and new functionality implementation.

The changes correctly implement the transition from single domain to multiple domains:

  • The deprecation comment follows JSDoc standards and clearly communicates the migration path
  • The new domains: string[] property supports the enhanced functionality
  • Backward compatibility is maintained by keeping the deprecated domain property

36-38: LGTM! Consistent implementation across update parameters.

The changes to UpdateSamlConnectionParams are consistent with the create parameters and properly implement the same deprecation pattern and new functionality. The optional nature of the properties is appropriate for update operations.

packages/backend/src/api/resources/SamlConnection.ts (4)

17-23: LGTM! Excellent implementation of deprecation and new functionality.

The changes to the SamlConnection class properly implement the migration from single domain to multiple domains:

  • The deprecation comment follows JSDoc standards and is informative
  • The new domains: string[] property is well-documented
  • Backward compatibility is maintained
  • The property ordering is logical and consistent

102-102: LGTM! Proper JSON deserialization support.

The fromJSON method correctly handles the new domains property from the JSON data, ensuring proper object construction with the updated interface.


129-133: LGTM! Consistent implementation across SAML account connection class.

The changes to SamlAccountConnection are consistent with the SamlConnection class changes and properly implement the same deprecation pattern and new functionality.


147-147: LGTM! Complete JSON deserialization support.

The fromJSON method for SamlAccountConnection correctly handles the new domains property, maintaining consistency with the SamlConnection implementation.

'@clerk/backend': minor
---

Deprecates `domain` field and introduce `domains`. Now, SAML connections support multiple domains, the `domain` field still supported but it's deprecated and will be removed on a future API version.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Deprecates `domain` field and introduce `domains`. Now, SAML connections support multiple domains, the `domain` field still supported but it's deprecated and will be removed on a future API version.
Introduces support for SAML connections with multiple domains, deprecating the `domain` field from `CreateSamlConnectionParams` and `UpdateSamlConnectionParams` in favor of `domains`.

@@ -13,7 +13,9 @@ type SamlConnectionListParams = {
type CreateSamlConnectionParams = {
name: string;
provider: SamlIdpSlug;
/** @deprecated Use `domains` array instead. This field will be removed in a future API version. */
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Multiple lines for JSDocs, but like a pattern than anything else.

Suggested change
/** @deprecated Use `domains` array instead. This field will be removed in a future API version. */
/**
* @deprecated Use `domains` array instead. This field will be removed in a future API version.
*/

Comment on lines 633 to +634
domain: string;
domains: string[];
Copy link
Member

Choose a reason for hiding this comment

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

We should add deprecation comments here as well.

@@ -14,9 +14,13 @@ export class SamlConnection {
*/
readonly name: string,
/**
* The domain of your organization. Sign in flows using an email with this domain will use the connection.
* @deprecated The domain of your organization. Sign in flows using an email with this domain will use the connection.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @deprecated The domain of your organization. Sign in flows using an email with this domain will use the connection.
* @deprecated Use `domains` instead.

Copy link
Member

@LauraBeatris LauraBeatris left a comment

Choose a reason for hiding this comment

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

Left some comments regarding styling and documentation, other than that, once those are pushed, then 🚢

@LauraBeatris LauraBeatris changed the title feat(backend): deprecate domain field in favor of domains on SAML connection and account feat(backend): Deprecate domain field in favor of domains on SAML connections/account Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants