Skip to content

[USER-2344] add /oauth/authorize-with-immediate-redirect endpoint to the frontendApiRedirectPathsNoUserInput list #6292

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 1 commit into
base: main
Choose a base branch
from

Conversation

Ben2W
Copy link

@Ben2W Ben2W commented Jul 12, 2025

Currently, to complete an oauth flow, the sign in page is usually hit. This is because the FAPI endpoint /oauth/authorize needs to get the user's session to complete the flow.

However, there are cases where FAPI's /oauth/authorize endpoint needs to know if the user is not logged into clerk. For example when handling prompt=none for OIDC.

This PR adds /oauth/authorize-with-immediate-redirect to frontendApiRedirectPathsNoUserInput. This makes it so we can immediately redirect back to the oauth flow, but attach the client cookie or dev browser to the flow without requiring user interaction

Summary by CodeRabbit

  • New Features
    • Added support for recognizing immediate OAuth redirect URLs as valid for FAPI-initiated flows.
  • Tests
    • Expanded test coverage to include cases for immediate OAuth redirect URLs, ensuring correct behavior for user input requirements and redirect recognition.

Copy link

changeset-bot bot commented Jul 12, 2025

⚠️ No Changeset found

Latest commit: 602efda

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

This PR includes no changesets

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

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

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

Copy link

vercel bot commented Jul 12, 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 Jul 12, 2025 1:57am

Copy link
Contributor

coderabbitai bot commented Jul 12, 2025

📝 Walkthrough

Walkthrough

A new path string, /oauth/authorize-with-immediate-redirect, was added to the frontendApiRedirectPathsNoUserInput array in the codebase. This change ensures that the application recognizes this path as one that should not require user input and should trigger an immediate redirect. Corresponding test cases were added to verify that both the isRedirectForFAPIInitiatedFlow and requiresUserInput functions handle this new path as expected. No changes were made to public interfaces or logic outside of this addition and its associated tests.

Assessment against linked issues

Objective Addressed Explanation
Add /oauth/authorize-with-immediate-redirect to list of immediate redirect endpoints (USER-2344)
Ensure clerk-js recognizes /oauth/authorize-with-immediate-redirect as not requiring user input (USER-2344)
Add/extend tests to verify new endpoint behavior (USER-2344)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.


🪧 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)
packages/clerk-js/src/utils/url.ts (1)

338-341: Fix typo in inline comment and consider marking array as const

The new entry is fine, but:

  1. “Similiar” → “Similar”.
  2. Since this array is meant to be a fixed whitelist, declaring it as const would give stronger type-safety and prevent accidental mutations.
-const frontendApiRedirectPathsNoUserInput: string[] = [
+const frontendApiRedirectPathsNoUserInput = [
   '/v1/verify', // magic links
   '/v1/tickets/accept', // ticket flow
-  '/oauth/authorize-with-immediate-redirect', // Similiar to OAuth Authorize, but even if a user is signed out - we immediately redirect
+  '/oauth/authorize-with-immediate-redirect', // Similar to OAuth Authorize, but even if a user is signed out we immediately redirect
-];
+] as const;

This is a minor polish, but worth doing while the code is fresh.
@clerk/security – heads-up: list of OAuth redirect endpoints changed.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ab31ae8 and 602efda.

📒 Files selected for processing (2)
  • packages/clerk-js/src/utils/__tests__/url.spec.ts (2 hunks)
  • packages/clerk-js/src/utils/url.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
packages/**/*.ts

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
packages/**/*.{ts,tsx,d.ts}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
  • .cursor/rules/typescript.mdc
packages/{clerk-js,elements,themes}/**/*

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/monorepo.mdc
**/*.ts

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

**/*

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

**/{__tests__,**/__tests__}/**/*.{js,jsx,ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/development.mdc
**/*.{test,spec}.{js,ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/monorepo.mdc
**/__tests__/**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .cursor/rules/typescript.mdc
🧠 Learnings (3)
📓 Common learnings
Learnt from: wobsoriano
PR: clerk/javascript#6099
File: packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts:7-14
Timestamp: 2025-06-10T20:38:08.982Z
Learning: Methods in `packages/backend/src/api/endpoints` (e.g., `IdPOAuthAccessTokenApi.verifySecret`) are currently not exposed publicly, so renaming them does not constitute a breaking change.
packages/clerk-js/src/utils/url.ts (2)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/*.tsx : Use redirect function for server-side redirects in Server Components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to tsconfig.json : Set up path aliases in tsconfig.json for cleaner imports
packages/clerk-js/src/utils/__tests__/url.spec.ts (7)
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/{clerk-js,elements,themes}/**/* : Visual regression testing should be performed for UI components.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/clerk-react/**/*.{test,spec}.{js,ts,tsx} : Component testing should use React Testing Library.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-06-30T10:30:56.197Z
Learning: Applies to packages/@clerk/*/jest.config.{js,ts} : Each framework integration package must have its own test configuration.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/nextjs.mdc:0-0
Timestamp: 2025-06-30T10:31:43.578Z
Learning: Applies to app/**/*.tsx : Use redirect function for server-side redirects in Server Components
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-06-30T10:33:45.961Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Use branded types for test isolation
Learnt from: LauraBeatris
PR: clerk/javascript#6273
File: packages/testing/src/playwright/unstable/page-objects/sessionTask.ts:22-27
Timestamp: 2025-07-11T17:12:28.461Z
Learning: In Clerk's test utilities, particularly for page objects like sessionTask.ts, when handling task type enums, prefer graceful handling of unknown/unsupported task types rather than throwing errors. This prevents breaking existing tests when new task types are introduced to the SessionTask['key'] union type.
Learnt from: CR
PR: clerk/javascript#0
File: .cursor/rules/development.mdc:0-0
Timestamp: 2025-06-30T10:29:42.997Z
Learning: Include tests for all new features
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/clerk-js/src/utils/__tests__/url.spec.ts (2)

425-426: New path added to isRedirectForFAPIInitiatedFlow tests – 👍

The extra case ensures the helper recognises the immediate-redirect variant; assertion is correct.


445-446: requiresUserInput test updated – 👍

Confirms that the immediate-redirect path is treated as no-input; reads clearly and passes.

Copy link

pkg-pr-new bot commented Jul 12, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6292

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6292

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6292

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6292

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6292

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6292

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6292

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6292

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6292

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6292

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6292

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6292

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6292

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6292

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6292

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6292

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6292

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6292

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6292

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6292

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6292

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6292

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6292

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6292

commit: 602efda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants