fix(reactjs-todo-login-widget): add the required journey client wellknown configuration to login widget sample app#115
fix(reactjs-todo-login-widget): add the required journey client wellknown configuration to login widget sample app#115vatsalparikh wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughAdds a realm-specific OIDC well-known discovery URL to the widget configuration, updates ChangesLogin Widget Journey & OIDC
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
javascript/reactjs-todo-login-widget/client/index.js
| // 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`, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
🧩 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' javascriptRepository: 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 || trueRepository: 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 80Repository: 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 120Repository: 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.
…nd journey name URL param support
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:
?journey=URL query parameter was not being passed to the login widget.openModalnow reads thejourneysearch param and forwards it tojourneyEvents.start(), allowing callers to specify a journey via URL (e.g./?journey=MyJourney).Summary by CodeRabbit