Skip to content

fix(reactjs-todo-login-widget): add the required journey client wellknown configuration to login widget sample app#115

Open
vatsalparikh wants to merge 2 commits into
mainfrom
sdks-4796
Open

fix(reactjs-todo-login-widget): add the required journey client wellknown configuration to login widget sample app#115
vatsalparikh wants to merge 2 commits into
mainfrom
sdks-4796

Conversation

@vatsalparikh

@vatsalparikh vatsalparikh commented May 25, 2026

Copy link
Copy Markdown
Contributor

JIRA Ticket

https://pingidentity.atlassian.net/browse/SDKS-4796

Explanation

While doing QA for https://pingidentity.atlassian.net/browse/SDKS-4703, I found two issues in the sample app:

  1. Journey client wellknown config — The sample app was not providing the required journey client config, causing a regression when the login framework was migrated to journey client.
  2. Journey name URL param — The ?journey= URL query parameter was not being passed to the login widget. openModal now reads the journey search param and forwards it to journeyEvents.start(), allowing callers to specify a journey via URL (e.g. /?journey=MyJourney).

Summary by CodeRabbit

  • Chores

    • Added WELLKNOWN_URL environment variable to development, testing, and build configuration systems for OpenID Connect well-known endpoint support.
    • Environment variable is now available to the Login Widget application during initialization.
  • Refactor

    • Enhanced Login Widget bootstrap configuration with new journeyClient settings block to support well-known configuration endpoints.

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ee44216-3caf-4c93-8482-fe5b6abb1aec

📥 Commits

Reviewing files that changed from the base of the PR and between b4557a9 and b494ab4.

📒 Files selected for processing (1)
  • javascript/reactjs-todo-login-widget/client/index.js

📝 Walkthrough

Walkthrough

This pull request adds WELLKNOWN_URL environment configuration to the React login widget. The URL is documented in environment examples, threaded through the Webpack build system via DefinePlugin, exported as a constant, imported into the widget, and configured as the journeyClient OIDC discovery endpoint. Test environments receive the same configuration.

Changes

WELLKNOWN_URL Environment and Widget Integration

Layer / File(s) Summary
Environment and build pipeline for WELLKNOWN_URL
`.env.example`, `webpack.config.js`, `client/constants.js`
WELLKNOWN_URL is documented as an environment variable, read by webpack with fallback to local .env, injected into the client bundle via webpack.DefinePlugin, and exported as a constant from constants.js.
Widget journeyClient OIDC discovery configuration
`client/index.js`, `playwright.config.ts`
WELLKNOWN_URL is imported and wired into journeyClient.serverConfig.wellknown in the widget configuration, and the URL is provided to the Playwright test server environment.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Suggested reviewers

  • cerebrl
  • ryanbas21

🐰 A well-known path to journeys bright,
Configuration whispers in the night,
Environment threads through build and test—
OIDC discovery, simply expressed!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 pull request title accurately summarizes the main change: adding the required journey client wellknown configuration to the login widget sample app, which aligns with all file modifications across configuration, constants, and build files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sdks-4796

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 and usage tips.

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

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 `@javascript/reactjs-todo-login-widget/client/index.js`:
- Around line 70-75: The wellknown OIDC discovery URL in
journeyClient.serverConfig currently always appends "/realms/${REALM_PATH}",
producing a duplicated segment when REALM_PATH === "root"; update the URL
construction in journeyClient.serverConfig.wellknown so that if REALM_PATH is
"root" you omit the "/realms/${REALM_PATH}" segment (i.e., use
`${SERVER_URL}oauth2/.well-known/openid-configuration` for root, otherwise
`${SERVER_URL}oauth2/realms/${REALM_PATH}/.well-known/openid-configuration`),
locate this change at the journeyClient.serverConfig.wellknown assignment in
client/index.js and implement the conditional string construction accordingly.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34319d26-a606-4d22-ad5a-331ca0001769

📥 Commits

Reviewing files that changed from the base of the PR and between f4b87ce and 71df158.

📒 Files selected for processing (1)
  • javascript/reactjs-todo-login-widget/client/index.js

Comment thread javascript/reactjs-todo-login-widget/client/index.js Outdated

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

Thanks for doing this. Left some suggestions. How did we get e2e passing before if journey wasn't being picked up? Do we need to add another test?

theme.mode === 'dark' ? 'cstm_login-link_dark' : ''
}`}
onClick={openModal}
onClick={() => openModal(searchParams.get('journey'))}

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.

Could we pass all the params here and extract them in openModal so that if we add more params later we don't have to update this? Something like this:
https://github.com/ForgeRock/sdk-sample-apps/blob/main/javascript/reactjs-todo-journey/client/components/layout/header.jsx#L36-L41

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done, makes sense!

// Required by Journey Client v2: OIDC discovery URL for the realm
journeyClient: {
serverConfig: {
wellknown: `${SERVER_URL}oauth2/realms/root/realms/${REALM_PATH}/.well-known/openid-configuration`,

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.

In the other sample apps we have a WELLKNOWN_URL variable and the sdk derives the server url and realm path from this automatically. Let's keep parity here and remove any env variables that aren't needed anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, moved the wellknown url derivation from index.js to .env. Now, index.js only reads the variable defined in .env file.

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

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 `@javascript/reactjs-todo-login-widget/client/index.js`:
- Around line 56-75: The comment claiming "NO journeyClient — never set, ever"
is contradictory because the config object sets
journeyClient.serverConfig.wellknown; remove or update the misleading comment
and ensure it accurately reflects the configuration in configuration().set —
specifically edit the comment above the configuration block (near
configuration()) to either delete the "NO journeyClient" remark or replace it
with a correct note that journeyClient.serverConfig.wellknown is intentionally
set, so future readers understand that journeyClient is configured.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 68a8570c-737f-4647-99a0-add6b6717f29

📥 Commits

Reviewing files that changed from the base of the PR and between b39fed4 and b4557a9.

📒 Files selected for processing (8)
  • javascript/reactjs-todo-login-widget/.env.example
  • javascript/reactjs-todo-login-widget/client/components/layout/header.js
  • javascript/reactjs-todo-login-widget/client/constants.js
  • javascript/reactjs-todo-login-widget/client/hooks/useLoginWidget.js
  • javascript/reactjs-todo-login-widget/client/index.js
  • javascript/reactjs-todo-login-widget/e2e/journey-url-param.spec.js
  • javascript/reactjs-todo-login-widget/playwright.config.ts
  • javascript/reactjs-todo-login-widget/webpack.config.js
✅ Files skipped from review due to trivial changes (1)
  • javascript/reactjs-todo-login-widget/.env.example

Comment thread javascript/reactjs-todo-login-widget/client/index.js Outdated
SteinGabriel
SteinGabriel previously approved these changes Jun 3, 2026

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

Other than the leftover comment pointed out by CodeRabbit (would be better to remove it, but not a blocker), this seems ready to be merged.
Thanks!

@vatsalparikh

vatsalparikh commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for doing this. Left some suggestions. How did we get e2e passing before if journey wasn't being picked up? Do we need to add another test?

Your point is valid, however, I am now realizing that we never intended to support multiple journeys in login widget. SIgn Up field was disabled and mentioned in the ticket when creating this sample app: https://pingidentity.atlassian.net/browse/SDKS-4765

So I am thinking supporting multiple journeys is not expected, nor desired in this sample app. It's probably a feature to add later on, so while I had added tests and the ability to specify multiple journeys in a commit, I pushed another commit that does not have those things.

I think right now, we only need wellknown configuration for this sample app, as it only supports the login journey and nothing else.

Oh, and we already support custom journeys through the .env variable JOURNEY_LOGIN. We can specify custom journeys through that variable, even though it's not possible with the query params, so it really is unnecessary, I just realized.

Anyway, I think wellknown changes are good enough for this PR so that this app continues to work when we move to the new version of login widget.

…ort custom journeys through JOURNEY_LOGIN env variable

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

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 `@javascript/reactjs-todo-login-widget/client/index.js`:
- Around line 53-55: Remove the URL query-param override by deleting the
URLSearchParams/window.location.search usage and the journeyParam variable; set
tree directly to JOURNEY_LOGIN instead of using journeyParam or any conditional
based on it. Specifically, remove the const urlParams = new
URLSearchParams(...), const journeyParam = urlParams.get('journey'), and any
code that assigns or overrides tree from journeyParam, and replace that logic so
tree = JOURNEY_LOGIN is assigned unconditionally (review occurrences around the
symbols URLSearchParams, journeyParam, tree, and JOURNEY_LOGIN).
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ee44216-3caf-4c93-8482-fe5b6abb1aec

📥 Commits

Reviewing files that changed from the base of the PR and between b4557a9 and b494ab4.

📒 Files selected for processing (1)
  • javascript/reactjs-todo-login-widget/client/index.js

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

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 `@javascript/reactjs-todo-login-widget/client/index.js`:
- Around line 53-55: Remove the URL query-param override by deleting the
URLSearchParams/window.location.search usage and the journeyParam variable; set
tree directly to JOURNEY_LOGIN instead of using journeyParam or any conditional
based on it. Specifically, remove the const urlParams = new
URLSearchParams(...), const journeyParam = urlParams.get('journey'), and any
code that assigns or overrides tree from journeyParam, and replace that logic so
tree = JOURNEY_LOGIN is assigned unconditionally (review occurrences around the
symbols URLSearchParams, journeyParam, tree, and JOURNEY_LOGIN).
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ee44216-3caf-4c93-8482-fe5b6abb1aec

📥 Commits

Reviewing files that changed from the base of the PR and between b4557a9 and b494ab4.

📒 Files selected for processing (1)
  • javascript/reactjs-todo-login-widget/client/index.js
🛑 Comments failed to post (1)
javascript/reactjs-todo-login-widget/client/index.js (1)

53-55: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove URL query-param journey override to match agreed PR scope.

journey is still read from window.location.search and used to override tree. This keeps query-param journey selection enabled, but the PR scope/comments explicitly narrowed behavior to use JOURNEY_LOGIN only. Please remove journeyParam usage and set tree directly from JOURNEY_LOGIN.

Also applies to: 73-73

🤖 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 `@javascript/reactjs-todo-login-widget/client/index.js` around lines 53 - 55,
Remove the URL query-param override by deleting the
URLSearchParams/window.location.search usage and the journeyParam variable; set
tree directly to JOURNEY_LOGIN instead of using journeyParam or any conditional
based on it. Specifically, remove the const urlParams = new
URLSearchParams(...), const journeyParam = urlParams.get('journey'), and any
code that assigns or overrides tree from journeyParam, and replace that logic so
tree = JOURNEY_LOGIN is assigned unconditionally (review occurrences around the
symbols URLSearchParams, journeyParam, tree, and JOURNEY_LOGIN).

Comment thread javascript/reactjs-todo-login-widget/client/index.js
@vatsalparikh vatsalparikh added the do not merge Do not merge label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Do not merge

Development

Successfully merging this pull request may close these issues.

3 participants