Skip to content

CEXT-6151: Add ACL admin UI schema and helper to check permissions#426

Open
oshmyheliuk wants to merge 18 commits into
mainfrom
CEXT-6151
Open

CEXT-6151: Add ACL admin UI schema and helper to check permissions#426
oshmyheliuk wants to merge 18 commits into
mainfrom
CEXT-6151

Conversation

@oshmyheliuk
Copy link
Copy Markdown
Collaborator

Description

https://jira.corp.adobe.com/browse/CEXT-6151

  • Update adminUISdk schema to support ACL fields for menu items
  •  Add a public helper that extensions can call from the SPA and from runtime actions to check whether the current user is allowed to use a given ACL resource.

Related Issue

https://github.com/magento-commerce/adobe-commerce-backend-uix/pull/352

Motivation and Context

How Has This Been Tested?

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 read the DEVELOPMENT document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

🦋 Changeset detected

Latest commit: 8142c69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@adobe/aio-commerce-lib-admin-ui-sdk Minor
@adobe/aio-commerce-sdk Minor
@adobe/aio-commerce-lib-app Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added with-changeset The PR contains a Changeset file. pkg: aio-commerce-lib-app Includes changes in `packages/aio-commerce-lib-app` labels May 5, 2026
@obarcelonap
Copy link
Copy Markdown
Member

Lib-api is designed as generic Commerce API utility library, this PR adds Admin UI SDK code.

The precedent is Commerce Events: eventing is wired up during installation (lib-app), the actual API client lives in its own dedicated lib-events package. Admin UI SDK is the same pattern, lib-app owns the config schema and the installation step, but the permission client is a standalone API concern.

I'd spawn a new package dedicated for Admin UI SDK.

The cost is another package to maintain, but given that Admin UI SDK is still growing and under refinement, doing the split now is lower effort than after more surface has accumulated across lib-app and lib-api.

}

/** Client for checking the current user's Admin UI SDK resource permissions. */
export interface AdminUiSdkPermissionClient {
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.

Wouldn't be better to do not limit the scope to just permissions? What if we need to add in the future an operation for AdminUiSdk but not related to permissions? We will create a new client?

I'd propose to open the scope of the client, so other concepts fit in:

interface AdminUiSdkClient {
  checkPermission()
  invalidatePermission()
  requirePermission()
}

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.

We already have an admin ui sdk related operation, but they are using the Commerce Client directly.
https://github.com/adobe/aio-commerce-sdk/blob/main/packages/aio-commerce-lib-app/source/management/installation/admin-ui-sdk/helpers.ts#L36
Probably can be moved to the "new Client" as well.

} as const;

/** Wraps an App Builder action handler with an Admin UI SDK permission check. */
export function withAdminUiSdkPermission<
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.

I like this idea but not sure if we have this kind of wrappers anywhere else

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.

Yeah, I wasn't too sure whether I should add this. This wrapper is optional, I can remove it.

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.

Maybe we could just create a require helper function instead of wrapping.

requireAdminUiSdkPermission("Acme_Promotions::edit", client)

Does it make sense change resource as array? In case of multiple permissions are allowed? Or even multiple permissions could be required?

Comment thread packages/aio-commerce-lib-app/source/config/schema/admin-ui-sdk.ts
Copy link
Copy Markdown
Member

@obarcelonap obarcelonap left a comment

Choose a reason for hiding this comment

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

LGTM but I'd like to hear your opinion about spawning a new package before approving.

@oshmyheliuk
Copy link
Copy Markdown
Collaborator Author

Creating a new package sounds like a logical step to me, to align with what we already have for eventing/webhooks.
I can update this PR with related changes.

return { statusCode: 200, body: { updated: true } };
}

export const main = async (params) => {
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.

I overlooked the wrapper I thought it was meant to be used wrapping the whole function so you don't need to create the clients.

export const main = withAdminUiSdkPermission(
    "Acme_Promotions::edit", 
    (params) => {
        // protected handler here
    },
)

@github-actions github-actions Bot added the pkg: aio-commerce-sdk Includes changes in `packages/aio-commerce-sdk` label May 18, 2026
@@ -0,0 +1,111 @@
# `@adobe/aio-commerce-lib-admin-ui-sdk` Documentation
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.

should we add experimental warning

});
```

In install/uninstall actions where only a subset of operations is needed, prefer `createCustomAdminUiSdkApiClient` to keep the bundle lean:
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.

While I understand this is to be more performant I don't think it is an issue in the app-management endpoints since they're not in the critical path of the applications. Therefore I'd remove it for the sake of simplicity.

"CHANGELOG.md",
"README.md"
],
"scripts": {
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.

Missing docs script and @aio-commerce-sdk/config-typedoc devDependency

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.

review this docs because claude is flagging some ids may not work with the new validations

docs/usage.md in lib-app still has "my-app::menu" — which now fails the new regex
  packages/aio-commerce-lib-app/docs/usage.md:476 still shows a hyphenated ID. The new id regex /^[A-Za-z0-9/:_]+$/ disallows hyphens, so any user copying from the docs
  would get an unexpected parse failure. The example needs updating (e.g. "my_app::menu"). If real apps use hyphenated IDs this is potentially a major bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: aio-commerce-lib-app Includes changes in `packages/aio-commerce-lib-app` pkg: aio-commerce-sdk Includes changes in `packages/aio-commerce-sdk` with-changeset The PR contains a Changeset file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants