-
Notifications
You must be signed in to change notification settings - Fork 30
Enhance key manager handling by fetching production and sandbox key managers in parallel #648
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 |
|---|---|---|
|
|
@@ -42,8 +42,9 @@ | |
| <div id="collapseProductionOauth2" class="accordion-collapse collapse show" | ||
| aria-labelledby="production-oauth2"> | ||
| <div class="accordion-body"> | ||
| {{#if keyManagersMetadata}} | ||
| {{#if hasProdKeyManagers}} | ||
| {{#each keyManagersMetadata}} | ||
| {{#if (eq devPortalAppEnv 'PROD')}} | ||
| {{#in name values="_internal_key_manager_,Resident Key Manager,_appdev_sts_key_manager_"}} | ||
| {{#if enabled}} | ||
| {{#let "keys" productionKeys}} | ||
|
|
@@ -259,6 +260,7 @@ | |
| <!-- Error message container for key generation and token generation --> | ||
| <div id="keyGenerationErrorContainer-PRODUCTION" class="mt-2 text-danger" | ||
| style="display: none; font-size: 0.75rem; word-wrap: break-word;"></div> | ||
| {{/if}} | ||
| {{/each}} | ||
|
Comment on lines
260
to
264
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. Verify error container placement relative to new conditionals. The error container at lines 261-262 is now inside the 🔧 Move error container inside the devPortalAppEnv check {{/in}}
<!-- Error message container for key generation and token generation -->
<div id="keyGenerationErrorContainer-PRODUCTION" class="mt-2 text-danger"
style="display: none; font-size: 0.75rem; word-wrap: break-word;"></div>
+ {{/if}}
- {{/if}}
{{/each}}The error container should be moved inside the 🤖 Prompt for AI Agents |
||
| {{else}} | ||
| <div style="margin-left: 1rem;"> | ||
|
|
@@ -607,8 +609,9 @@ | |
| <div id="collapseSandboxOAuth2" class="accordion-collapse collapse show" | ||
| aria-labelledby="sandbox-oauth2"> | ||
| <div class="accordion-body"> | ||
| {{#if keyManagersMetadata}} | ||
| {{#if hasSandboxKeyManagers}} | ||
| {{#each keyManagersMetadata}} | ||
| {{#if (eq devPortalAppEnv 'SANDBOX')}} | ||
| {{#in name values="_internal_key_manager_,Resident Key Manager,_appdev_sts_key_manager_"}} | ||
| {{#if enabled}} | ||
| {{#let "keys" sandboxKeys}} | ||
|
|
@@ -826,6 +829,7 @@ | |
| <!-- Error message container for key generation and token generation --> | ||
| <div id="keyGenerationErrorContainer-SANDBOX" class="mt-2 text-danger" | ||
| style="display: none; font-size: 0.75rem; word-wrap: break-word;"></div> | ||
| {{/if}} | ||
| {{/each}} | ||
| {{else}} | ||
| <div style="margin-left: 1rem;"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1597,16 +1597,19 @@ const createAppKeyMappingOnBehalfOfUser = async (cpAppID, keymanager, clientId, | |
| } | ||
|
|
||
| const getAPIMKeyManagersBehalfOfUser = async (cpOrgId, patToken) => { | ||
|
|
||
| let headers = { | ||
| const headers = { | ||
| 'Content-Type': 'application/json', | ||
| Authorization: `Bearer ${patToken}` | ||
| } | ||
| let url = `${controlPlaneGwUrl}/key-managers?devPortalAppEnv=prod`; | ||
| const keymanagersResponse = await util.apiRequest('GET', url, headers, null, cpOrgId); | ||
|
|
||
| return keymanagersResponse.data.list; | ||
| } | ||
| }; | ||
| const [prodResponse, sandboxResponse] = await Promise.all([ | ||
| util.apiRequest('GET', `${controlPlaneGwUrl}/key-managers?devPortalAppEnv=prod`, headers, null, cpOrgId), | ||
| util.apiRequest('GET', `${controlPlaneGwUrl}/key-managers?devPortalAppEnv=sandbox`, headers, null, cpOrgId) | ||
| ]); | ||
| return [ | ||
| ...(prodResponse.data.list || []), | ||
| ...(sandboxResponse.data.list || []) | ||
| ]; | ||
|
Comment on lines
+1604
to
+1611
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. Keep the environment on each returned key manager. This helper now flattens prod and sandbox into one anonymous list. Callers like Possible direction- return [
- ...(prodResponse.data.list || []),
- ...(sandboxResponse.data.list || [])
- ];
+ return [
+ ...((prodResponse.data.list || []).map(km => ({ ...km, devPortalAppEnv: 'PROD' }))),
+ ...((sandboxResponse.data.list || []).map(km => ({ ...km, devPortalAppEnv: 'SANDBOX' }))),
+ ];🤖 Prompt for AI Agents |
||
| }; | ||
|
|
||
| const createCPApplication = async (req, cpApplicationName) => { | ||
| logger.info('Creating control plane application', { | ||
|
|
||
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.
Hardcoded Choreo-specific URLs may break non-Choreo deployments.
The fallback URLs (
https://sts.choreo.dev/oauth2/...) are Choreo-specific. Ifconfig.controlPlane.residentKeyManageris not configured in a non-Choreo environment, users will see incorrect endpoint URLs.Consider either:
🔧 Suggested improvement
async function enrichKeyManager(keyManager) { if (keyManager.name === constants.KEY_MANAGERS.RESIDENT_KEY_MANAGER) { const residentKMConfig = config.controlPlane?.residentKeyManager || {}; - keyManager.tokenEndpoint = residentKMConfig.tokenEndpoint || 'https://sts.choreo.dev/oauth2/token'; - keyManager.authorizeEndpoint = residentKMConfig.authorizeEndpoint || 'https://sts.choreo.dev/oauth2/authorize'; - keyManager.revokeEndpoint = residentKMConfig.revokeEndpoint || 'https://sts.choreo.dev/oauth2/revoke'; + if (!residentKMConfig.tokenEndpoint) { + logger.warn('Resident Key Manager token endpoint not configured, using Choreo default'); + } + keyManager.tokenEndpoint = residentKMConfig.tokenEndpoint || 'https://sts.choreo.dev/oauth2/token'; + keyManager.authorizeEndpoint = residentKMConfig.authorizeEndpoint || 'https://sts.choreo.dev/oauth2/authorize'; + keyManager.revokeEndpoint = residentKMConfig.revokeEndpoint || 'https://sts.choreo.dev/oauth2/revoke'; }🤖 Prompt for AI Agents