feat: add strictImpersonationPermissions setting for checkUserPermission - #200
Open
wender wants to merge 1 commit into
Open
feat: add strictImpersonationPermissions setting for checkUserPermission#200wender wants to merge 1 commit into
wender wants to merge 1 commit into
Conversation
3.5.1 made checkUserPermission scope permissions to the impersonated profile unconditionally. That closes the permission leak reported for Call Center sessions, but it also removes permissions that the default B2B Suite configuration depends on: can-checkout is not granted to the customer-buyer role, so a sales representative impersonating an Organization Buyer could no longer complete checkout - a capability this app's own docs describe for sales roles. The same need was raised for approvers who must retain approval power while impersonating. Both impersonation flows are affected, not only telemarketing: the Organizations app switches the profile namespace through storefront-permissions.storeUserId, which vtex.profile-session consumes, so authentication.storeUserEmail and profile.email diverge in both. Put the behavior behind a new app setting instead of picking one side: - strictImpersonationPermissions=true returns only the impersonated profile's permissions (the 3.5.1 behavior). - strictImpersonationPermissions=false (default) aggregates the acting user's and impersonated profile's permissions, restoring the 3.5.0 behavior so existing stores keep working without any action. Settings are only read for impersonation sessions, through the existing 5 minute LRU cache, so regular sessions are unaffected. Also document the query's contract during impersonation, which was previously unspecified. Ref: B2BTEAM-3566
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
nicholas-maestrello
approved these changes
Aug 5, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem is this solving?
In version
3.5.1,checkUserPermissionstarted scoping permissions to the impersonated profile unconditionally. That prevents the acting user's permissions from reaching the storefront during impersonation, but it also removes permissions that the default B2B Suite configuration relies on:can-checkoutis granted tostore-admin,sales-admin,sales-manager,sales-representative,customer-adminandcustomer-approver, but not tocustomer-buyer.docs/README.md.Both behaviors are legitimate depending on the store: some need the storefront to render exactly what the impersonated user can do, others depend on the acting user's rights during impersonation (for example approval flows).
This also affects both impersonation flows, not only
vtex.telemarketing. The B2B Organizations app switches the profile namespace throughstorefront-permissions.storeUserId, whichvtex.profile-sessiontakes as an input, soauthentication.storeUserEmailandprofile.emaildiverge in both flows.What changed
The behavior is now controlled by a new app setting:
strictImpersonationPermissionstrue3.5.1behavior).false(default)roleprefers the acting user's, falling back to the impersonated profile's (the3.5.0behavior).Sessions outside impersonation are unchanged in both modes.
This restores the
3.5.0default on purpose. Apps auto-update within a major, so keeping strict scoping on by default would continue to removecan-checkoutin stores that did not opt into the change. Stores that want strict scoping enable the setting. Flipping the default to strict is a candidate for the next major, with a migration note.Notes for reviewers:
3.5.1semantics exactly, including therolefallback order.getCachedAppSettings), so regular sessions are not affected. A settings read failure logs a warning and falls back to the default (aggregated) mode.UserPermissions { role, permissions }is unchanged, so there is no GraphQL schema change.docs/README.md, which was previously unspecified.How should this be manually tested?
With the setting disabled (default):
sales-representative, impersonate acustomer-buyerthrough the B2B Organizations app.checkUserPermissionreturns the union of both sets, thatcan-checkoutis present, and that checkout completes.With
strictImpersonationPermissionsenabled in the app settings:checkUserPermissionreturns only the buyer's role and permissions, with no permission coming from the sales representative.vtex.telemarketingsession impersonating a customer.Screenshots or example usage:
N/A (backend resolver and app setting)
Ref: B2BTEAM-3566