Repository navigation
feat(oidc-client): add RAR support [SDKS-5435] #871
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@forgerock/oidc-client': minor | ||
| '@forgerock/sdk-oidc': minor | ||
| '@forgerock/sdk-types': minor | ||
| --- | ||
|
|
||
| Added RAR support through `authorizationDetails` parameter in OIDC config. Works with or without PAR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>E2E Test | Ping Identity JavaScript SDK</title> | ||
|
|
||
| <style> | ||
| #logout { | ||
| display: none; | ||
| } | ||
| #user-info-btn { | ||
| display: none; | ||
| } | ||
| fieldset { | ||
| display: inline-flex; | ||
| flex-direction: column; | ||
| gap: 0.4rem; | ||
| margin-bottom: 1rem; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div id="app"> | ||
| <a href="/">Home</a> | ||
| <h1>OIDC App | RAR (Rich Authorization Request) + PAR Login</h1> | ||
| <p> | ||
| Client: <code>rar</code> — RAR enabled. <code>authorization_details</code> are | ||
| serialized and sent in the authorize url or PAR POST body. | ||
| </p> | ||
|
|
||
| <h2>Step 1: Establish AM Session (Journey: Login)</h2> | ||
| <p> | ||
| Background PAR + RAR auth requires an existing AM session. Log in via the Login journey | ||
| first. | ||
| </p> | ||
| <form id="journey-form"> | ||
| <fieldset> | ||
| <label for="username">User Name</label> | ||
| <input id="username" type="text" autocomplete="username" /> | ||
| <label for="password">Password</label> | ||
| <input id="password" type="password" autocomplete="current-password" /> | ||
| <button type="submit">Login (Journey)</button> | ||
| </fieldset> | ||
| </form> | ||
| <p id="journey-status"></p> | ||
|
|
||
| <h2>Step 2: RAR OAuth</h2> | ||
| <button id="login-background" disabled>Login (Background — PAR + RAR)</button> | ||
| <button id="login-redirect">Login (Redirect — PAR + RAR)</button> | ||
| <button id="get-tokens">Get Tokens (Local)</button> | ||
| <button id="get-tokens-background">Get Tokens (Background)</button> | ||
| <button id="renew-tokens">Renew Tokens</button> | ||
| <button id="logout">Logout</button> | ||
| <button id="user-info-btn">User Info</button> | ||
| <button id="revoke">Revoke Token</button> | ||
| <a href="/rar-par/">Start Over</a> | ||
| </div> | ||
| <script type="module" src="./main.ts"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2026 Ping Identity Corporation. All right reserved. | ||
| * | ||
| * This software may be modified and distributed under the terms | ||
| * of the MIT license. See the LICENSE file for details. | ||
| * | ||
| */ | ||
| import { runLoginJourney } from '../utils/journey-login.js'; | ||
| import { oidcApp } from '../utils/oidc-app.js'; | ||
|
|
||
| const urlParams = new URLSearchParams(window.location.search); | ||
| const AM_BASE = 'https://openam-stoyan.forgeblocks.com/am'; | ||
|
|
||
| const config = { | ||
| clientId: 'rar', | ||
| redirectUri: 'http://localhost:8443/rar-par/', | ||
| scope: 'openid profile email', | ||
| serverConfig: { | ||
| wellknown: `${AM_BASE}/oauth2/alpha/.well-known/openid-configuration`, | ||
| }, | ||
| par: true, | ||
| authorizationDetails: [ | ||
| { | ||
| type: 'account_information', | ||
| actions: ['list_accounts', 'read_balances'], | ||
| locations: ['https://example.com/accounts'], | ||
| datatypes: ['balances'], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const journeyForm = document.getElementById('journey-form') as HTMLFormElement; | ||
| const journeyStatus = document.getElementById('journey-status') as HTMLParagraphElement; | ||
| const backgroundBtn = document.getElementById('login-background') as HTMLButtonElement; | ||
|
|
||
| // Run journey Login to establish an AM session before background auth | ||
| journeyForm.addEventListener('submit', async (e) => { | ||
| e.preventDefault(); | ||
| const username = (document.getElementById('username') as HTMLInputElement).value; | ||
| const password = (document.getElementById('password') as HTMLInputElement).value; | ||
| journeyStatus.textContent = 'Logging in…'; | ||
| try { | ||
| await runLoginJourney(username, password, AM_BASE); | ||
| journeyStatus.textContent = '✓ Session established — background login now available.'; | ||
| backgroundBtn.disabled = false; | ||
| } catch (err) { | ||
| journeyStatus.textContent = `✗ ${err instanceof Error ? err.message : 'Login failed'}`; | ||
| } | ||
| }); | ||
|
|
||
| oidcApp({ config, urlParams }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <title>E2E Test | Ping Identity JavaScript SDK</title> | ||
|
|
||
| <style> | ||
| #logout { | ||
| display: none; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div id="app"> | ||
| <a href="/">Home</a> | ||
| <h1>OIDC App | RAR Login</h1> | ||
| <button id="login-background">Login (Background)</button> | ||
| <button id="login-redirect">Login (Redirect)</button> | ||
| <button id="get-tokens">Get Tokens (Local)</button> | ||
| <button id="get-tokens-background">Get Tokens (Background)</button> | ||
| <button id="renew-tokens">Renew Tokens</button> | ||
| <button id="logout">Logout</button> | ||
| <button id="user-info-btn">User Info</button> | ||
| <button id="revoke">Revoke Token</button> | ||
| <a href="/rar/">Start Over</a> | ||
| </div> | ||
| <script type="module" src="./main.ts"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2026 Ping Identity Corporation. All right reserved. | ||
| * | ||
| * This software may be modified and distributed under the terms | ||
| * of the MIT license. See the LICENSE file for details. | ||
| * | ||
| */ | ||
| import { oidcApp } from '../utils/oidc-app.js'; | ||
|
|
||
| const urlParams = new URLSearchParams(window.location.search); | ||
|
|
||
| const config = { | ||
| clientId: 'rar', | ||
| redirectUri: 'http://localhost:8443/rar/', | ||
| scope: 'openid profile email', | ||
| serverConfig: { | ||
| wellknown: | ||
| 'https://openam-stoyan.forgeblocks.com/am/oauth2/alpha/.well-known/openid-configuration', | ||
| }, | ||
| authorizationDetails: [ | ||
| { | ||
| type: 'account_information', | ||
| actions: ['list_accounts', 'read_balances'], | ||
| locations: ['https://example.com/accounts'], | ||
| datatypes: ['balances'], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| oidcApp({ config, urlParams }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2026 Ping Identity Corporation. All right reserved. | ||
| * | ||
| * This software may be modified and distributed under the terms | ||
| * of the MIT license. See the LICENSE file for details. | ||
| * | ||
| */ | ||
| const urlParams = new URLSearchParams(window.location.search); | ||
| const journeyParam = urlParams.get('journey'); | ||
|
|
||
| const AM_BASE = 'https://openam-sdks.forgeblocks.com/am'; | ||
| const REALM = 'alpha'; | ||
| const JOURNEY = journeyParam || 'Login'; | ||
|
|
||
| // Run journey Login to establish an AM session before background auth | ||
| export async function runLoginJourney( | ||
| username: string, | ||
| password: string, | ||
| amBase?: string, | ||
| ): Promise<void> { | ||
| const authenticateUrl = `${amBase || AM_BASE}/json/realms/root/realms/${REALM}/authenticate?authIndexType=service&authIndexValue=${JOURNEY}`; | ||
|
|
||
| // Step 1: start the journey | ||
| const initRes = await fetch(authenticateUrl, { | ||
| method: 'POST', | ||
| credentials: 'include', | ||
| headers: { 'Content-Type': 'application/json', 'Accept-API-Version': 'resource=2.1' }, | ||
| body: '{}', | ||
| }); | ||
| const initJson = await initRes.json(); | ||
|
|
||
| if (initJson.successUrl) return; // already authenticated | ||
|
|
||
| // Fill NameCallback + PasswordCallback | ||
| for (const cb of initJson.callbacks ?? []) { | ||
| if (cb.type === 'NameCallback') cb.input[0].value = username; | ||
| if (cb.type === 'PasswordCallback') cb.input[0].value = password; | ||
| } | ||
|
|
||
| // Step 2: submit credentials | ||
| const submitRes = await fetch(authenticateUrl, { | ||
| method: 'POST', | ||
| credentials: 'include', | ||
| headers: { 'Content-Type': 'application/json', 'Accept-API-Version': 'resource=2.1' }, | ||
| body: JSON.stringify(initJson), | ||
| }); | ||
| const submitJson = await submitRes.json(); | ||
|
|
||
| if (!submitJson.tokenId && !submitJson.successUrl) { | ||
| throw new Error(submitJson.message || 'Login failed'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any consequences to hardcoding the AM URL here? Does it reduce configurability of running tests in CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The oidc-app is not set up like some of our other apps where there are
server-configobjects that make for easy configuration. Each test path is tied to a hardcoded configuration which is often necessary to complete the e2e redirect-based token exchange flow. After the user is redirected back to the application, it is redirected without any query params. Therefore we cannot set things likeclientId,authorizationDetails,par,wellknown, etc through query params because they will be dropped after redirect and token exchange will fail with a different configuration than what initiated the OAuth flow.