Skip to content

feat: add preLoadedConnections array option to Jackson options - #4074

Open
Vansh98789 wants to merge 1 commit into
ory:mainfrom
Vansh98789:fix/preloaded-connections
Open

feat: add preLoadedConnections array option to Jackson options#4074
Vansh98789 wants to merge 1 commit into
ory:mainfrom
Vansh98789:fix/preloaded-connections

Conversation

@Vansh98789

@Vansh98789 Vansh98789 commented Aug 8, 2026

Copy link
Copy Markdown

What does this PR do?

Adds a new preLoadedConnections option to JacksonOption that accepts an in-memory array of SAML/OIDC connections, as an alternative to the existing path-based preLoadedConnection option.

The current preLoadedConnection option loads a directory path and uses dynamic import() (in loadConnection.ts) to read .js connection files. This breaks in Next.js 15 + Turbopack environments where dynamic imports from runtime paths are not supported.

This PR:

  • Adds a Connection type union in typings.ts
  • Adds preLoadedConnections?: Connection[] to JacksonOption
  • Creates connections directly from the array via the ConnectionAPIController — no dynamic imports or file system access
  • Keeps the existing path-based preLoadedConnection flow untouched for backward compatibility
  • Shares the existing writeConnection helper between both paths

Fixes #3644

Type of Change

  • Updated dependencies
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Should This Be Tested?

  1. Set up the Jackson controllers with preLoadedConnections containing a SAML connection (with rawMetadata) and/or an OIDC connection (with oidcDiscoveryUrl.
  2. Confirm the connections are created on initialization and are accessible via connectionAPIController.getConnections({ tenant, product }).
  3. Confirm the existing path-based preLoadedConnection option still works.

Example

const jackson = await controllers({
  externalUrl: 'https://example.com',
  samlPath: '/sso/oauth/saml',
  preLoadedConnections: [
    {
      tenant: 'acme',
      product: 'saml',
      rawMetadata: '<EntityDescriptor>...</EntityDescriptor>',
      defaultRedirectUrl: 'https://app.example.com',
      redirectUrl: ['https://app.example.com'],
    },
  ],
  db: { engine: 'mem' },
});

Tests

  • Existing unit tests

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code and corrected any misspellings
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Added support for preloading multiple SAML and OIDC connections through in-memory configuration.
    • Added type definitions for supported preloaded connection formats.
  • Enhancements
    • Existing path-based connection loading remains supported.
    • Preloaded connections are routed automatically based on their connection type.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Jackson now accepts typed in-memory SAML and OIDC connections. Initialization routes these connections through shared creation logic and retains support for path-based preloaded connections.

Changes

Preloaded connection support

Layer / File(s) Summary
Connection input contract
npm/src/typings.ts
Adds the exported Connection union and the optional JacksonOption.preLoadedConnections array.
Shared connection loading
npm/src/index.ts
Loads in-memory connections through OIDC or SAML creation methods, logs each connection, and reuses the shared writer for path-based loading.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: deepakprabhakara, pi1814

Sequence Diagram(s)

sequenceDiagram
  participant Jackson
  participant ConnectionWriter
  participant OIDCorSAMLCreation
  Jackson->>ConnectionWriter: passes each preLoadedConnections item
  ConnectionWriter->>OIDCorSAMLCreation: selects OIDC or SAML creation
  OIDCorSAMLCreation-->>ConnectionWriter: creates the connection
  ConnectionWriter-->>Jackson: logs the loaded connection
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding the preLoadedConnections array option to Jackson options.
Description check ✅ Passed The description covers the change, motivation, issue, testing steps, change type, and checklist with sufficient detail.
Linked Issues check ✅ Passed The implementation satisfies issue #3644 by adding in-memory SAML/OIDC connections without dynamic imports while preserving the existing path-based flow.
Out of Scope Changes check ✅ Passed The changes are limited to the requested option, connection typing, initialization logic, and shared connection writing behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

🧹 Nitpick comments (1)
npm/src/typings.ts (1)

69-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the exported Connection type in the path loader.

npm/src/loadConnection.ts still declares the same four-member union as a private connection type. npm/src/index.ts now uses the exported Connection type. Keep one union definition so path-based and in-memory loading cannot drift when a connection variant changes.

🤖 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 `@npm/src/typings.ts` around lines 69 - 73, Update the path loader in
loadConnection.ts to import and reuse the exported Connection type from
typings.ts instead of declaring its own private four-member union. Remove the
duplicate connection type definition while preserving the existing path-based
loading behavior.
🤖 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.

Nitpick comments:
In `@npm/src/typings.ts`:
- Around line 69-73: Update the path loader in loadConnection.ts to import and
reuse the exported Connection type from typings.ts instead of declaring its own
private four-member union. Remove the duplicate connection type definition while
preserving the existing path-based loading behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a0266d3-59de-45a1-b81e-ff2239c10d7b

📥 Commits

Reviewing files that changed from the base of the PR and between e13ed65 and e373fc0.

📒 Files selected for processing (2)
  • npm/src/index.ts
  • npm/src/typings.ts

@deepakprabhakara

Copy link
Copy Markdown
Collaborator

Thanks @Vansh98789, the team will review your PR soon.

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.

preLoadedConnection throws error in next 15 app

2 participants