-
Notifications
You must be signed in to change notification settings - Fork 16
SDKS-5067: Standardize SDK Configuration #118
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| WELLKNOWN_URL= | ||
| WEB_OAUTH_CLIENT= | ||
| API_URL=http://localhost:9443 | ||
| DEBUGGER_OFF=true | ||
| DEVELOPMENT=true | ||
| PORT=8443 | ||
| SCOPE="openid profile email phone name revoke" | ||
|
|
||
| # INIT_PROTECT (optional) - bootstrap | flow | ||
| # 'bootstrap' will initialize protect at app bootstrap time | ||
| # 'flow' relies on the PingOne Protect collector for initialization | ||
| INIT_PROTECT= | ||
| # PINGONE_ENV_ID - required when ProtectCollector is present | ||
| PINGONE_ENV_ID= | ||
|
|
||
| # SDK configuration (clientId, discoveryEndpoint, scopes, redirectUri) is no | ||
| # longer sourced from environment variables. Copy config.example.json to | ||
| # config.json and fill in your values. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| node_modules/ | ||
| config.json | ||
| /test-results/ | ||
| /playwright-report/ | ||
| /blob-report/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,32 +8,30 @@ | |
| * of the MIT license. See the LICENSE file for details. | ||
| */ | ||
|
|
||
| /** *************************************************************************** | ||
| * SDK INTEGRATION POINT | ||
| * Summary: Configure the DaVinci client | ||
| * ---------------------------------------------------------------------------- | ||
| * Details: CONFIG uses the unified SDK configuration schema. Pass it to | ||
| * `makeDavinciConfig(CONFIG)` from `@forgerock/sdk-utilities` before calling | ||
| * the factory — e.g. `davinci({ config: makeDavinciConfig(CONFIG) })`. | ||
| * | ||
| * Local dev: copy config.example.json → config.json and fill in your values. | ||
| * E2e / CI: set SDK_CONFIG to a JSON string (e.g. from config.test.json). | ||
| *************************************************************************** */ | ||
| import sdkConfigJson from '../config.json'; | ||
| export const API_URL = process.env.API_URL; | ||
| // Yes, the debugger boolean is intentionally reversed | ||
| export const DEBUGGER = process.env.DEBUGGER_OFF === 'false'; | ||
| export const WEB_OAUTH_CLIENT = process.env.WEB_OAUTH_CLIENT; | ||
| export const SCOPE = process.env.SCOPE; | ||
| export const WELLKNOWN_URL = process.env.WELLKNOWN_URL; | ||
| export const INIT_PROTECT = process.env.INIT_PROTECT; | ||
| export const PINGONE_ENV_ID = process.env.PINGONE_ENV_ID; | ||
| /** *************************************************************************** | ||
| * SDK INTEGRATION POINT | ||
| * Summary: Configure the OIDC client | ||
| * ---------------------------------------------------------------------------- | ||
| * Details: The config object below is passed to the `oidc()` initializer in | ||
| * `oidc.context.js` to configure the OIDC client: | ||
| * - clientId: the OAuth 2.0 client ID registered in PingOne | ||
| * - redirectUri: the URI of this app to which the OAuth 2.0 flow redirects | ||
| * after authentication (points to callback.html for the redirect handler) | ||
| * - scope: the OAuth 2.0 scopes requested from PingOne | ||
| * - serverConfig.wellknown: the OpenID Connect discovery URL for your | ||
| * PingOne environment, used to resolve authorization/token endpoints | ||
| *************************************************************************** */ | ||
|
|
||
| const rawConfig = process.env.SDK_CONFIG ? JSON.parse(process.env.SDK_CONFIG) : sdkConfigJson; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard Line 29 parses Proposed fix-import sdkConfigJson from '../config.json';
+import sdkConfigJson from '../config.json';
@@
-const rawConfig = process.env.SDK_CONFIG ? JSON.parse(process.env.SDK_CONFIG) : sdkConfigJson;
+const rawConfig = (() => {
+ if (!process.env.SDK_CONFIG) return sdkConfigJson;
+ try {
+ return JSON.parse(process.env.SDK_CONFIG);
+ } catch (error) {
+ throw new Error(`Invalid SDK_CONFIG JSON: ${error.message}`);
+ }
+})();🤖 Prompt for AI Agents |
||
|
|
||
| export const CONFIG = { | ||
| clientId: WEB_OAUTH_CLIENT, | ||
| redirectUri: `${window.location.origin}/callback.html`, | ||
| scope: SCOPE, | ||
| serverConfig: { | ||
| wellknown: WELLKNOWN_URL, | ||
| ...rawConfig, | ||
| oidc: { | ||
| ...rawConfig.oidc, | ||
| redirectUri: `${window.location.origin}/callback.html`, | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "oidc": { | ||
| "clientId": "<your-oauth-client-id>", | ||
| "discoveryEndpoint": "https://<your-domain>/.well-known/openid-configuration", | ||
| "scopes": ["openid", "profile", "email"] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "oidc": { | ||
| "clientId": "20dd0ed0-bb9b-4c8f-9a60-9ebeb4b348e0", | ||
| "discoveryEndpoint": "https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration", | ||
| "scopes": ["openid", "profile", "email", "phone", "name", "revoke"], | ||
| "redirectUri": "http://localhost:5829/callback.html" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "oidc": { | ||
| "clientId": "724ec718-c41c-4d51-98b0-84a583f450f9", | ||
| "discoveryEndpoint": "https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration", | ||
| "scopes": ["openid", "profile", "email", "phone", "name", "revoke"], | ||
| "redirectUri": "http://localhost:8443/callback.html" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,6 @@ | ||||||||
| import { defineConfig, devices } from '@playwright/test'; | ||||||||
| import testConfig from './config.test.json'; | ||||||||
| import testFidoConfig from './config.test.fido.json'; | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove or use
💡 Suggested fix import { defineConfig, devices } from '`@playwright/test`';
import testConfig from './config.test.json';
-import testFidoConfig from './config.test.fido.json';📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 3-3: 'testFidoConfig' is defined but never used. (no-unused-vars) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||
|
|
||||||||
| const url = process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:8443'; | ||||||||
|
|
||||||||
|
|
@@ -27,11 +29,8 @@ export default defineConfig({ | |||||||
| DEBUGGER_OFF: 'true', | ||||||||
| DEVELOPMENT: 'false', | ||||||||
| PORT: '8443', | ||||||||
| WEB_OAUTH_CLIENT: '724ec718-c41c-4d51-98b0-84a583f450f9', | ||||||||
| SCOPE: 'openid profile email phone name revoke', | ||||||||
| WELLKNOWN_URL: | ||||||||
| 'https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration', | ||||||||
| PINGONE_ENV_ID: '02fb4743-189a-4bc7-9d6c-a919edfe6447', | ||||||||
| SDK_CONFIG: JSON.stringify(testConfig), | ||||||||
| }, | ||||||||
| ignoreHTTPSErrors: true, | ||||||||
| }, | ||||||||
|
|
@@ -61,10 +60,7 @@ export default defineConfig({ | |||||||
| // DEBUGGER_OFF: 'true', | ||||||||
| // DEVELOPMENT: 'false', | ||||||||
| // PORT: '5829', | ||||||||
| // WEB_OAUTH_CLIENT: '20dd0ed0-bb9b-4c8f-9a60-9ebeb4b348e0', | ||||||||
| // SCOPE: 'openid profile email phone name revoke', | ||||||||
| // WELLKNOWN_URL: | ||||||||
| // 'https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration', | ||||||||
| // SDK_CONFIG: JSON.stringify(testFidoConfig), | ||||||||
| // }, | ||||||||
| // ignoreHTTPSErrors: true, | ||||||||
| // }, | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,18 @@ | ||
| VITE_WELLKNOWN_URL= | ||
| VITE_WEB_OAUTH_CLIENT= | ||
| VITE_API_URL=http://localhost:9443 | ||
| VITE_PORT=8443 | ||
| VITE_DEBUGGER_OFF=true | ||
| VITE_DEVELOPMENT=true | ||
| VITE_SCOPE='openid profile email' | ||
| VITE_JOURNEY_LOGIN=Login | ||
| VITE_JOURNEY_REGISTER=Registration | ||
|
|
||
| # VITE_INIT_PROTECT (optional) - bootstrap | journey | ||
| # 'bootstrap' will initialize protect at app bootstrap time | ||
| # 'journey' relies on the PingOneProtectEvaluationCallback for initialization | ||
| VITE_INIT_PROTECT= | ||
| VITE_INIT_PROTECT= | ||
|
|
||
| # VITE_PINGONE_ENV_ID - required if VITE_INIT_PROTECT is set | ||
| VITE_PINGONE_ENV_ID= | ||
| VITE_PINGONE_ENV_ID= | ||
|
|
||
| # SDK configuration (clientId, discoveryEndpoint, scopes, redirectUri) is no | ||
| # longer sourced from environment variables. Copy config.example.json to | ||
| # config.json and fill in your values. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| node_modules/ | ||
| config.json | ||
| build/ | ||
| /test-results/ | ||
| /playwright-report/ | ||
|
|
||
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.
Fix redirect URI protocol mismatch in setup instructions.
Line 69 shows
https://localhost:8443/callback.html, but the same README config/setup path useshttp://localhost:8443/callback.html(Line 41). Align these to one value to avoid misconfiguration during onboarding.🤖 Prompt for AI Agents