Skip to content

feat: add Ims token for db commands - #36

Merged
pdohogne-magento merged 6 commits into
epic/abdb-implementationfrom
cext-5606/feat-add-Imstoken-auth
Mar 9, 2026
Merged

feat: add Ims token for db commands#36
pdohogne-magento merged 6 commits into
epic/abdb-implementationfrom
cext-5606/feat-add-Imstoken-auth

Conversation

@AjazSumaiya

Copy link
Copy Markdown
Collaborator

Description

This PR changes DBBase Command to rely on IMS-lib to fetch or reuse IMS tokens for Ims authentication for db service

Changes done -

  • DBBaseCommand calls authHelper.getAccessToken() which internally uses Ims lib
  • authHelper.getAccessToken() checks ims.contexts.<runtime_namespace> for an existing token
  • If the token is valid, it is reused; otherwise it calls ims.getAccessTokenByClientCredentials()
  • The generated token is stored back in local ims context config ims.contexts.<namespace>.token

Related Issue

Motivation and Context

How Has This Been Tested?

On local

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@nofuss nofuss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Question about token expiration.

Comment thread src/utils/authHelper.js Outdated
Comment thread src/utils/authHelper.js Outdated
Comment on lines +61 to +71
if (tokenResponse.payload?.access_token) {
return tokenResponse.payload.access_token
}

if (tokenResponse.access_token) {
return tokenResponse.access_token
}

if (typeof tokenResponse === 'string') {
return tokenResponse
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we not know the format of the response?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

checked response format and fixed

Comment thread src/utils/authHelper.js Outdated
const runtimeNamespace = config.get(CONFIG_RUNTIME_NAMESPACE)

if (!runtimeNamespace) {
throw new Error('Runtime namespace is required. Please set CONFIG_RUNTIME_NAMESPACE.')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is env AIO_RUNTIME_NAMESPACE

(this happens when the local project is not synced with console)

Comment thread src/utils/authHelper.js
@@ -0,0 +1,142 @@
/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Most of this logic is already handled by aio-lib-ims

please rewrite accordingly to https://github.com/adobe/aio-cli-plugin-app-storage/pull/36/changes#r2869855342

@moritzraho moritzraho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, few nits, tested it works fine, thanks!

Comment thread src/utils/authHelper.js Outdated
Comment thread src/utils/authHelper.js Outdated
Comment thread src/utils/authHelper.js Outdated

@nofuss nofuss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks like we're ready to give it a test!

@pdohogne-magento
pdohogne-magento merged commit 3e58924 into epic/abdb-implementation Mar 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants