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 1 commit 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 1 commit into
mainfrom
sdks-4796

Conversation

@vatsalparikh
Copy link
Copy Markdown
Contributor

@vatsalparikh vatsalparikh commented May 25, 2026

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

  • New Features
    • Login Widget configuration now supports OIDC discovery URL specification for realms through the new journeyClient override parameter, enabling enhanced realm discovery configuration alongside existing settings.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

📝 Walkthrough

Walkthrough

Adds a realm-specific OIDC well-known discovery URL to the widget configuration, updates useLoginWidget.openModal to accept an optional journeyName, and threads the URL journey query parameter from the header into the login modal start call.

Changes

Login Widget Journey & OIDC

Layer / File(s) Summary
Journey Client discovery config
javascript/reactjs-todo-login-widget/client/index.js
Adds journeyClient.serverConfig.wellknown constructed from SERVER_URL and REALM_PATH for realm OIDC discovery.
useLoginWidget: openModal(journeyName)
javascript/reactjs-todo-login-widget/client/hooks/useLoginWidget.js
openModal now accepts an optional journeyName, clears auth errors, and calls journeyEvents.start({ journey: journeyName }) or undefined.
Header: read search param and pass journey
javascript/reactjs-todo-login-widget/client/components/layout/header.js
Imports useSearchParams(), obtains searchParams, and passes searchParams.get('journey') into openModal from the Sign In click handler.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 I found a journey on the way,
A query tucked in light of day,
Configured well-known doors,
Modal hops and gentle roars,
Login hops onward—hip hooray! 🎉

🚥 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
Title check ✅ Passed The pull request title accurately describes the main change: adding journey client wellknown configuration to the login widget sample app, which aligns with all three modified files and the stated PR objectives.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

Copy link
Copy Markdown

@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: 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 on lines +70 to +75
// 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

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify realm/env formats and existing wellknown construction patterns

set -euo pipefail

echo "== REALM_PATH usage in login-widget sample =="
rg -n -C2 'REALM_PATH|realmPath|wellknown|oauth2/realms/root' javascript/reactjs-todo-login-widget/client

echo
echo "== Any sample .env templates that document REALM_PATH format =="
fd -HI '.env*' javascript | sed 's#^`#-` #'
rg -n -C1 'REALM_PATH|SERVER_URL' $(fd -HI '.env*' javascript) || true

echo
echo "== Compare journeyClient.wellknown patterns across JS samples =="
rg -n -C2 'journeyClient|wellknown|oauth2/realms/root' javascript

Repository: ForgeRock/sdk-sample-apps

Length of output: 22846


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== login-widget client README/.env.example for REALM_PATH format =="
sed -n '1,120p' javascript/reactjs-todo-login-widget/client/README.md
echo "----"
sed -n '1,120p' javascript/reactjs-todo-login-widget/.env.example
echo "----"
sed -n '1,120p' javascript/reactjs-todo-login-widget/client/constants.js

echo
echo "== todo-api middleware: how it builds realm paths for non-root =="
sed -n '1,120p' javascript/todo-api/src/app/middleware.js

echo
echo "== reactjs-todo-journey: how it sources wellknown URL =="
rg -n "WELLKNOWN|wellknown" javascript/reactjs-todo-journey/client -S
echo "----"
rg -n "WELLKNOWN|wellknown" javascript/reactjs-todo-oidc/client -S
echo "----"
ls -la javascript/reactjs-todo-journey/client/constants.js javascript/reactjs-todo-oidc/client/constants.js 2>/dev/null || true
sed -n '1,120p' javascript/reactjs-todo-journey/client/constants.js 2>/dev/null || true
sed -n '1,120p' javascript/reactjs-todo-oidc/client/constants.js 2>/dev/null || true

Repository: ForgeRock/sdk-sample-apps

Length of output: 12418


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== login-widget client index.js around realmPath docs and wellknown template =="
sed -n '1,120p' javascript/reactjs-todo-login-widget/client/index.js | nl -ba | sed -n '35,95p'

echo
echo "== Search repo for journey discovery pattern '/oauth2/realms/root/realms/' =="
rg -n "oauth2/realms/root/realms/" javascript | head -n 50

echo
echo "== Search repo for 'wellknown: .*openid-configuration' constructions =="
rg -n "wellknown:.*openid-configuration|openid-configuration" javascript/reactjs-todo-login-widget javascript/reactjs-todo-journey javascript/reactjs-todo-oidc javascript/todo-api | head -n 80

Repository: ForgeRock/sdk-sample-apps

Length of output: 210


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== login-widget client index.js around realmPath docs and wellknown template =="
sed -n '1,120p' javascript/reactjs-todo-login-widget/client/index.js | cat -n | sed -n '35,95p'

echo
echo "== Search repo for journey discovery pattern '/oauth2/realms/root/realms/' =="
rg -n "oauth2/realms/root/realms/" javascript | head -n 50

echo
echo "== Search repo for 'wellknown: .*openid-configuration' constructions =="
rg -n "wellknown:.*openid-configuration|openid-configuration" javascript/reactjs-todo-login-widget javascript/reactjs-todo-journey javascript/reactjs-todo-oidc javascript/todo-api | head -n 120

Repository: ForgeRock/sdk-sample-apps

Length of output: 4238


Fix OIDC discovery wellknown URL for REALM_PATH="root" in login-widget

javascript/reactjs-todo-login-widget/client/index.js line 73 always builds ${SERVER_URL}oauth2/realms/root/realms/${REALM_PATH}/.well-known/openid-configuration. With REALM_PATH="root" (documented as a supported value), this produces /oauth2/realms/root/realms/root/..., which is inconsistent with the repo’s AIC root handling elsewhere (e.g., todo-api/src/app/middleware.js omits the /realms/${REALM_PATH} segment when the realm is root).

Suggested fix
+const normalizedRealmPath = (REALM_PATH || '').replace(/^\/+|\/+$/g, '');
+const realmSuffix =
+  normalizedRealmPath && normalizedRealmPath !== 'root'
+    ? `/realms/${normalizedRealmPath.split('/').join('/realms/')}`
+    : '';
+const normalizedServerUrl = SERVER_URL.endsWith('/') ? SERVER_URL : `${SERVER_URL}/`;
+
 configuration().set({
   forgerock: {
@@
   journeyClient: {
     serverConfig: {
-      wellknown: `${SERVER_URL}oauth2/realms/root/realms/${REALM_PATH}/.well-known/openid-configuration`,
+      wellknown: `${normalizedServerUrl}oauth2/realms/root${realmSuffix}/.well-known/openid-configuration`,
     },
   },
 });
🤖 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 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.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant