Skip to content

refactor(reactjs-todo-login-widget): update configure to accommodate features like logger, middleware, storage from login widget in the sample app - #127

Merged
vatsalparikh merged 1 commit into
mainfrom
migrate-login-widget-2.0
Sep 14, 2026
Merged

vatsalparikh merged 1 commit into
mainfrom
migrate-login-widget-2.0

Conversation

@vatsalparikh

@vatsalparikh vatsalparikh commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added session-based OAuth token storage.
    • Added advanced sign-in options, including login hints, localization, authentication context, renewal thresholds, PAR, and query parameters.
    • Added configurable debug logging and request session identification.
    • Improved sign-out with session termination, OIDC logout, and token revocation.
    • Added independent processing for Journey and OIDC authentication requests.
  • Bug Fixes

    • Login protection now activates during application startup.
    • Improved authentication handling and protected Todo operations.
    • Missing tokens are treated as unauthenticated without unnecessary error logging.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b5a54064-1dca-432a-8ad2-7b7165c6ef12

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The React login widget now uses expanded SDK configuration, request middleware, session storage, and environment-provided logging. Playwright coverage validates authentication options, logout, protection, token storage, middleware behavior, and protected todo operations.

Changes

Login Widget integration

Layer / File(s) Summary
Widget bootstrap and SDK configuration
javascript/reactjs-todo-login-widget/client/index.js, javascript/reactjs-todo-login-widget/client/hooks/useLoginWidget.js, javascript/reactjs-todo-login-widget/package.json, javascript/reactjs-todo-login-widget/playwright.config.ts, javascript/reactjs-todo-login-widget/webpack.config.js
The widget uses expanded OIDC settings, session storage, shared middleware, explicit token handling, and a fixed SDK prerelease. Webpack exposes LOG_LEVEL to the client.
Authentication and session validation
javascript/reactjs-todo-login-widget/e2e/config-*.spec.js, javascript/reactjs-todo-login-widget/e2e/logout.spec.js, javascript/reactjs-todo-login-widget/e2e/protect.spec.js, javascript/reactjs-todo-login-widget/e2e/storage-session.spec.js
End-to-end tests validate debug logging, middleware classification, OIDC parameters, logout requests, protection initialization, and session-only token storage.
Protected todo flows
javascript/reactjs-todo-login-widget/e2e/todos-crud.spec.js, javascript/reactjs-todo-login-widget/e2e/todos-navigation.spec.js
Tests validate authenticated todo CRUD operations and token persistence across repeated navigation.

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

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant LoginWidget
  participant JourneyMiddleware
  participant OIDCMiddleware
  participant Journey
  participant OIDC
  Browser->>LoginWidget: Start authentication
  LoginWidget->>JourneyMiddleware: Send Journey action
  JourneyMiddleware->>Journey: Add X-Session-ID and continue request
  LoginWidget->>OIDCMiddleware: Send OIDC action
  OIDCMiddleware->>OIDC: Classify and continue request
Loading

Possibly related PRs

Suggested reviewers: cerebrl

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly identifies the ReactJS todo login widget configuration changes for logger, middleware, and storage features.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate-login-widget-2.0

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

A rabbit checks the login gate,
Session tokens wait in state.
Middleware marks each call,
OIDC guards the welcome hall.
Todos change from new to done—
Debug logs confirm each run.

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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
javascript/reactjs-todo-login-widget/playwright.config.ts (1)

47-53: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Pass REST_OAUTH_SECRET to the AIC todo API or use a public token source.

AIC token validation sends Basic Authorization: CONFIDENTIAL_CLIENT, whose value is REST_OAUTH_CLIENT:REST_OAUTH_SECRET, but the Playwright todo-api web server only sets REST_OAUTH_CLIENT. Protected /users and /todos requests will have invalid Basic auth and fail validation.

🤖 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/playwright.config.ts` around lines 47 -
53, Update the Playwright `env` configuration used by the AIC todo API to
provide `REST_OAUTH_SECRET` alongside `REST_OAUTH_CLIENT`, using the matching
configured secret so Basic authorization validation succeeds for protected
`/users` and `/todos` requests; alternatively configure a public token source if
that is the established setup.
🤖 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`:
- Line 59: Update the oidcClient.oauthThreshold configuration to use the value
60, representing a 60-second renewal window, and revise its JSDoc description to
specify seconds rather than milliseconds.

In `@javascript/reactjs-todo-login-widget/e2e/config-logger.spec.js`:
- Around line 19-23: Update the assertion after the authorizeRequest wait to use
Playwright’s expect.poll around the consoleLines debug check, allowing retries
until a line with type "debug" appears; keep the existing authorizeRequest
navigation flow unchanged.

In `@javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js`:
- Around line 54-58: Update the OIDC login test around the TOKEN_EXCHANGE and
AUTHORIZE assertions to capture the browser network request made during token
exchange or authorization, then assert its x-session-id header matches the
Journey request header. Retain the existing middleware log assertions while
using the captured request to validate correlation-header propagation.

---

Outside diff comments:
In `@javascript/reactjs-todo-login-widget/playwright.config.ts`:
- Around line 47-53: Update the Playwright `env` configuration used by the AIC
todo API to provide `REST_OAUTH_SECRET` alongside `REST_OAUTH_CLIENT`, using the
matching configured secret so Basic authorization validation succeeds for
protected `/users` and `/todos` requests; alternatively configure a public token
source if that is the established setup.
🪄 Autofix

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 Plus

Run ID: ed13795b-c551-403a-a800-dcd89279cb22

📥 Commits

Reviewing files that changed from the base of the PR and between c2223ee and 14b9db5.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • javascript/reactjs-todo-login-widget/client/index.js
  • javascript/reactjs-todo-login-widget/e2e/config-logger.spec.js
  • javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js
  • javascript/reactjs-todo-login-widget/e2e/config-oidc-options.spec.js
  • javascript/reactjs-todo-login-widget/e2e/logout.spec.js
  • javascript/reactjs-todo-login-widget/e2e/protect.spec.js
  • javascript/reactjs-todo-login-widget/e2e/storage-session.spec.js
  • javascript/reactjs-todo-login-widget/e2e/todos-crud.spec.js
  • javascript/reactjs-todo-login-widget/e2e/todos-navigation.spec.js
  • javascript/reactjs-todo-login-widget/package.json
  • javascript/reactjs-todo-login-widget/playwright.config.ts
  • javascript/reactjs-todo-login-widget/webpack.config.js

Comment thread javascript/reactjs-todo-login-widget/client/index.js
Comment on lines +19 to +23
const authorizeRequest = page.waitForRequest((request) => request.url().includes('/authorize?'));
await page.goto('https://localhost:8443/');
await authorizeRequest;

expect(consoleLines.some((line) => line.type === 'debug')).toBe(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the referenced test and nearby code.
file="javascript/reactjs-todo-login-widget/e2e/config-logger.spec.js"
if [ -f "$file" ]; then
  echo "== file exists =="
  wc -l "$file"
  echo "== relevant lines =="
  sed -n '1,120p' "$file" | cat -n
else
  echo "file missing: $file"
  echo "== find similar =="
  fd -a 'config-logger\.spec\.js|todo-login-widget|e2e' .
fi

echo "== Playwright dependency/version mentions =="
for f in package.json pnpm-lock.yaml package-lock.json yarn.lock poetry.lock; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    rg -n '"`@playwright/test`"|playwright' "$f" || true
  fi
done

echo "== e2e config/logger tests around consoleLines expectations =="
if [ -d javascript/reactjs-todo-login-widget/e2e ]; then
  rg -n "consoleLines|expect\.poll|waitForRequest|authorize\?" javascript/reactjs-todo-login-widget/e2e -S
fi

Repository: ForgeRock/sdk-sample-apps

Length of output: 4092


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Behavioral/source check for the relevant Playwright assertion semantics from installed package, if present.
if [ -d javascript/reactjs-todo-login-widget/node_modules/@playwright/test ]; then
  pkg="javascript/reactjs-todo-login-widget/node_modules/@playwright/test"
  echo "== playwright package present =="
  find "$pkg" -maxdepth 4 -name '*.d.ts' | head -50
  rg -n "not waiting for .*condition|non-retrying|expect\.poll|poll|expect:\s*class|toBe\(" "$pkg" -S | head -120 || true
else
  echo "== playwright test package not present in repo =="
fi

Repository: ForgeRock/sdk-sample-apps

Length of output: 213


🌐 Web query:

Playwright expect values are non retrying use expect poll asynchronous

💡 Result:

In Playwright, standard assertions (like expect(locator).toBeVisible) are auto-retrying and asynchronous, meaning they will automatically retry until they pass or reach the specified timeout [1][2]. However, some assertions do not auto-retry, and for these or other complex asynchronous conditions, you should use expect.poll to handle retries [1][3]. expect.poll is specifically designed to convert a synchronous or asynchronous function into an asynchronous polling assertion [1][4]. It repeatedly executes a provided function and evaluates the result against an expectation until it passes or times out [5][3]. Key characteristics of expect.poll: - Asynchronous: Because it is a polling mechanism, it must be awaited [1][4]. - Configurable: You can set custom timeout durations (defaulting to 5 seconds) and define custom polling intervals (the default intervals are milliseconds) [1][5][3]. - Flexibility: It can be combined with expect.soft to perform soft assertions within the polling logic, allowing the test to continue even if a specific poll iteration fails [1][3]. Example of using expect.poll: await expect.poll(async => { const response = await page.request.get('https://api.example.com'); return response.status; }, { message: 'ensure API request succeeds', timeout: 10000, }).toBe(200);

Citations:


🌐 Web query:

Playwright test assertions direct values non retrying expect values non-retrying

💡 Result:

In Playwright, non-retrying assertions are used to validate immediate, synchronous values where waiting for an asynchronous state change is unnecessary [1]. Unlike "web-first" assertions (which automatically retry until a condition is met or a timeout is reached), these non-retrying assertions evaluate the condition exactly once [2][1][3]. Key Characteristics and Usage: - No Auto-retry: Because they do not retry, these assertions are susceptible to flakiness if used against asynchronous web elements that are not yet ready [2][4]. They should generally be reserved for static values or variables that are already available in memory [1]. - Implementation: They are invoked using the standard expect(value) syntax [1]. - Examples of non-retrying matchers include expect(value).toBe, expect(value).toEqual, expect(value).toBeDefined, expect(value).toContain, and expect(value).toMatch [2][5]. - Best Practices: Playwright documentation strongly recommends using auto-retrying, web-first assertions whenever possible for testing web page elements [2][1][3]. If a complex asynchronous condition needs to be checked and standard web-first assertions are insufficient, use expect.poll or expect.toPass instead of relying on basic non-retrying matchers [2][4]. Distinction from Soft Assertions: It is important to distinguish between retrying behavior and assertion severity. A non-retrying assertion can still be used as a "soft" assertion by using expect.soft(value).toBe(...) [6]. While expect.soft will continue test execution upon failure rather than aborting immediately, it preserves the retrying behavior of the underlying matcher [6]. Therefore, a soft assertion applied to a web-first matcher (e.g., expect.soft(locator).toHaveText) will still retry, whereas a soft assertion applied to a generic value matcher (e.g., expect.soft(value).toBe) will remain non-retrying [6].

Citations:


Wait for the debug console event.

waitForRequest() completes when the browser issues the authorize request. The SDK debug message can arrive after the request event. Use await expect.poll(() => consoleLines.some((line) => line.type === 'debug')).toBe(true) so Playwright retries the asynchronous condition.

🤖 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/e2e/config-logger.spec.js` around lines
19 - 23, Update the assertion after the authorizeRequest wait to use
Playwright’s expect.poll around the consoleLines debug check, allowing retries
until a line with type "debug" appears; keep the existing authorizeRequest
navigation flow unchanged.

Comment on lines +54 to +58
// OIDC middleware saw the OIDC client's requests (token exchange after login).
await expect
.poll(() => logText().some((text) => text.includes('[oidc-middleware] TOKEN_EXCHANGE')))
.toBe(true);
expect(logText().some((text) => text.includes('[oidc-middleware] AUTHORIZE'))).toBe(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Candidate files:"
git ls-files | rg 'javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js|javascript/reactjs-todo-login-widget|oidc-middleware|x-session-id|X-Session-ID' || true

echo
echo "Target file outline and relevant lines:"
if [ -f javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js ]; then
  wc -l javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js
  sed -n '1,140p' javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js | cat -n
fi

echo
echo "Search for header/header setup and OIDC middleware logs:"
rg -n "X-Session-ID|x-session-id|TOKEN_EXCHANGE|AUTHORIZE|oidc-middleware|session-id|Journey" javascript/reactjs-todo-login-widget -S || true

echo
echo "Package/config references to middleware:"
fd -a 'package.json|middleware|oidc|config|src|app' javascript/reactjs-todo-login-widget -t f | sed 's#^\./##' | head -200

Repository: ForgeRock/sdk-sample-apps

Length of output: 11842


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read-only behavioral/source-shape verifier: determine whether the target test has any network-request-based
# assertions covering the OIDC token exchange request or X-Session-ID propagation.
python3 - <<'PY'
from pathlib import Path
import re

p = Path('javascript/reactjs-todo-login-widget/e2e/config-middleware.spec.js')
if not p.exists():
    print('missing target')
    raise SystemExit(0)
text = p.read_text()
checks = {
    'token_exchange_log_assertion': 'TOKEN_EXCHANGE' in text,
    'authorize_log_assertion': 'AUTHORIZE' in text,
    'journey_header_assertion': bool(re.search(r'Journey|X-Session-ID|x-session-id', text)),
    'network_request_capture_patterns': bool(re.search(r'\.intercept|waitForRequest|response\(req\)|\.headers|headers\(\)', text)),
    'x_session_id_assertion': bool(re.search(r'x-session-id|X-Session-ID', text)),
    'token_exchange_request_assertion': bool(re.search(r'TOKEN_EXCHANGE|token.*exchange|token-exchange', text)),
}
for k, v in checks.items():
    print(f'{k}={v}')

# Show all test step blocks with relevant matching lines.
for m in re.finditer(r'it\([^\)]*\)|test\([^\)]*\)', text):
    seg_start = m.start()
    seg = re.search(r'\n\}\n\}\)', text[seg_start:])
    end = (seg_start + seg.end()) if seg else min(seg_start + 6000, len(text))
    segment = text[seg_start:end]
    if any(term in segment for term in ['TOKEN_EXCHANGE', 'AUTHORIZE', 'token_exchange', 'headers(', 'intercept', 'waitForRequest']):
        print(f'\n--- block {seg_start} ---')
        print('\n'.join(f'{i+1:4}: {line}' for i,line in enumerate(segment.splitlines()) if any(q in line for q in ['TOKEN_EXCHANGE', 'AUTHORIZE', 'token_exchange', 'headers(', 'intercept', 'waitForRequest', 'expect', 'logText'])))
PY

Repository: ForgeRock/sdk-sample-apps

Length of output: 1400


Assert the OIDC correlation header on a network request.

The TOKEN_EXCHANGE log only shows that oidcMiddleware ran. Capture the browser request made during token exchange or authorization, then assert that x-session-id equals the Journey request header. This validates OIDC header propagation and the shared correlation ID.

🤖 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/e2e/config-middleware.spec.js` around
lines 54 - 58, Update the OIDC login test around the TOKEN_EXCHANGE and
AUTHORIZE assertions to capture the browser network request made during token
exchange or authorization, then assert its x-session-id header matches the
Journey request header. Retain the existing middleware log assertions while
using the captured request to validate correlation-header propagation.

@vatsalparikh
vatsalparikh force-pushed the migrate-login-widget-2.0 branch 6 times, most recently from 375ed27 to b69cea0 Compare August 14, 2026 00:06
@vatsalparikh vatsalparikh changed the title refactor(reactjs-todo-login-widget): update configure to accommodate … refactor(reactjs-todo-login-widget): update configure to accommodate features like logger, middleware, storage from login widget in the sample app Aug 14, 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.

Minor findings.

Comment thread javascript/reactjs-todo-login-widget/pnpm-lock.yaml Outdated
Comment thread javascript/reactjs-todo-login-widget/client/index.js Outdated
@vatsalparikh
vatsalparikh force-pushed the migrate-login-widget-2.0 branch 2 times, most recently from fbd116d to 36f1aab Compare September 2, 2026 23:43
Comment thread javascript/reactjs-todo-login-widget/playwright.config.ts
@vatsalparikh
vatsalparikh force-pushed the migrate-login-widget-2.0 branch 4 times, most recently from 192ef98 to 936288e Compare September 9, 2026 20:22
ryanbas21
ryanbas21 previously approved these changes Sep 14, 2026
SteinGabriel
SteinGabriel previously approved these changes Sep 14, 2026
@vatsalparikh
vatsalparikh dismissed stale reviews from SteinGabriel and ryanbas21 via 094f1ba September 14, 2026 16:53
@vatsalparikh
vatsalparikh force-pushed the migrate-login-widget-2.0 branch from 094f1ba to 26220ac Compare September 14, 2026 17:36
@vatsalparikh
vatsalparikh force-pushed the migrate-login-widget-2.0 branch from 26220ac to 2bba882 Compare September 14, 2026 17:45
@vatsalparikh
vatsalparikh merged commit 268c719 into main Sep 14, 2026
17 checks passed
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.

4 participants