spryker-feature / agentic-commerce
AgenticCommerce module
Package info
github.com/spryker-feature/agentic-commerce
pkg:composer/spryker-feature/agentic-commerce
Requires
- php: >=8.3
- lcobucci/clock: ^2.0.0 || ^3.0.0
- lcobucci/jwt: ^4.0.0
- spryker-shop/shop-ui: ^1.3.0 || ^2.0.0
- spryker/application: ^3.0.0
- spryker/customer: ^7.0.0
- spryker/kernel: ^3.52.0
- spryker/log: ^3.0.0
- spryker/money: ^2.0.0
- spryker/oauth: ^2.4.0
- spryker/oauth-extension: ^1.9.0
- spryker/permission: ^1.0.0
- spryker/permission-extension: ^1.0.0
- spryker/propel-orm: ^1.0.0
- spryker/redis: ^2.13.0
- spryker/sales: ^11.0.0
- spryker/security-blocker: ^1.3.0
- spryker/security-blocker-extension: ^1.0.0
- spryker/store: ^1.19.0
- spryker/symfony: ^3.1.0
- spryker/transfer: ^3.27.0
- spryker/uuid-behavior: ^1.0.0
- spryker/zed-request: ^3.0.0
- spryker/zed-request-extension: ^1.1.0
Requires (Dev)
Suggests
- spryker-shop/company-page: Required to render the company connected apps page in the company account layout and its entry in the company account navigation.
- spryker/api-platform: Required to expose the OAuth and principal Storefront API resources; without it the resources are never discovered.
- spryker/event-dispatcher: Use this module when using plugins that need EventDispatcher dependencies.
- spryker/merchant: Required by the merchant allowlist constraint plugins, which a marketplace wires to limit delegated orders to listed merchants.
- spryker/router: Use this module when using plugins that need Router dependencies.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-13 14:13:14 UTC
README
Lets a storefront customer give a registered third-party client delegated access to the shop. The customer approves the client on a consent page, and the client then receives short-lived access tokens that only work on the delegated access resources and only carry the scopes the customer allowed.
Installation
composer require spryker-feature/agentic-commerce
Terms
- OAuth (Open Authorization) 2.0 is the protocol the client uses to get a token. The authorization code flow is described in RFC 6749.
- PKCE (Proof Key for Code Exchange, RFC 7636) binds an authorization code to the client that asked for it. Only the
S256method is accepted. - A client is a third-party application registered with the shop. A consent is the customer's approval of one client for a set of scopes, one principal and one store.
- A scope is one permission a client may ask for, written as
area:action, for exampleagentic-commerce:principal-read. Every client has a scope ceiling, the scopes it may ever ask for. The customer can untick scopes on the consent page. - A principal is the account the client acts for: the customer, or one of the customer's company users. The client never gets more rights than the principal has.
- The issuer is the base URL of the Glue storefront. Authorization server metadata (RFC 8414) and protected resource metadata (RFC 9728) are published under it. Resource indicators (RFC 8707) tie a token to the delegated access resource, and token revocation follows RFC 7009.
- Glue is the Spryker REST API layer. Yves is the storefront. Zed is the back end.
What the feature provides
- Zed client status:
AgenticCommerceFacade::updateAgenticCommerceClientCollection()blocks and unblocks registered clients. Blocking a client revokes its active consents. - Zed consents:
AgenticCommerceFacade::getAgenticCommerceConsentCollection()reads consents with their effective status, principal, client and store.updateAgenticCommerceConsentCollection()revokes consents on behalf of the customer who gave them, andrevokeAgenticCommerceConsentsBySystem()revokes them on behalf of the system. Every revocation writes a consent event (revoked,reuse_detectedorcode_replayed), so the history of a consent is kept. - Zed plugin interface in
Dependency/Plugin:AgenticCommerceConsentPostRevokePluginInterface, executed once with all consents a revocation revoked. - Service:
AgenticCommerceServicebuilds the authorization server metadata (RFC 8414) and the protected resource metadata (RFC 9728) documents.
Quick start
1. Configure
Set these AgenticCommerceConstants in config/Shared/config_default.php:
| Constant | Meaning |
|---|---|
ISSUER |
Base URL of the Glue storefront. The token endpoint <issuer>/oauth/token, the revocation endpoint <issuer>/oauth/revoke and the resource URI <issuer>/agentic-commerce in the metadata follow from it. |
AUTHORIZATION_ENDPOINT |
Absolute URL of the authorization endpoint published in the authorization server metadata. |
SUPPORTED_SCOPES |
Scopes a client can be registered for, published in the metadata. |
Delegated access is switched on once ISSUER, AUTHORIZATION_ENDPOINT and PUBLIC_KEY are all set (AgenticCommerceConfig::isConfigured()). Until then the Yves pages and the Glue protocol endpoints answer 404, so ISSUER and PUBLIC_KEY are the two switches to watch: one without the other leaves the feature off.
The Glue storefront host (SPRYKER_GLUE_STOREFRONT_HOST) must be available to every application, so the issuer is the same everywhere. The issuer must be written identically in the metadata, the iss response parameter and the token iss claim.
3. Wire the project
composer require nelmio/cors-bundle: the feature does not require it, but the CORS (cross-origin resource sharing) rule below needs it.config/GlueStorefront/bundles.php: addSprykerFeature\Glue\AgenticCommerce\AgenticCommerceBundle::class => ['all' => true]andNelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true].config/GlueStorefront/packages/security.php: add theagentic_commercefirewall before themainfirewall, withAgenticCommerceAuthenticator,AgenticCommerceAuthenticationEntryPointandAgenticCommerceAccessDeniedHandler. Give it the patternAgenticCommerceServiceInterface::getDelegatedAccessPathPattern(). Add the access control rulesAgenticCommerceConfig::PUBLIC_PROTOCOL_PATH_PATTERN(public) and, after it,AgenticCommerceServiceInterface::getDelegatedAccessPathPattern()(authenticated).config/GlueStorefront/packages/nelmio_cors.php: add one path rule,AgenticCommerceServiceInterface::getDelegatedAccessPathPattern(), which covers/oauth/token,/oauth/revoke,/oauth/register,/.well-known/oauth-*and the path prefix of every declared protected resource. It allows theAuthorizationandContent-Typeheaders and exposesWWW-Authenticate. Other paths keep their current CORS behaviour.Pyz\Glue\OauthApi\OauthApiConfig::getAccessTokenValidationExcludedPathPatterns(): returnAgenticCommerceServiceInterface::getDelegatedAccessPathPattern(). This is required. Without it the storefront token check runs on delegated access calls and every one of them answers401with error code001.Pyz\Glue\GlueStorefrontApiApplication\GlueStorefrontApiApplicationDependencyProvider: addAgenticCommerceStoreApplicationPlugin, which resolves the store of a call from the token.Pyz\Client\Oauth\OauthDependencyProvider::getAccessTokenValidatorPlugins(): addAgenticCommerceTokenRejectingAccessTokenValidatorPlugin.Pyz\Zed\Oauth\OauthDependencyProvider: addAgenticCommerceAuthorizationCodeOauthRequestGrantTypeConfigurationProviderPluginandAgenticCommerceRefreshTokenOauthRequestGrantTypeConfigurationProviderPlugin.Pyz\Zed\Console\ConsoleDependencyProvider: add the three client console commands.Pyz\Zed\AgenticCommerce\AgenticCommerceDependencyProvider: return the principal resolver plugins (AgenticCommerceCustomerPrincipalResolverPlugin, and for B2BAgenticCommerceCompanyUserPrincipalResolverPlugin) and the scope filter plugins (for B2BAgenticCommerceCompanyRolePermissionScopeFilterPlugin).Pyz\Zed\Customer\CustomerDependencyProvider: addAgenticCommerceCustomerAnonymizerPluginto the customer anonymizer plugins.Pyz\Zed\CompanyUser\CompanyUserDependencyProvider(B2B): addAgenticCommerceCompanyUserPreDeletePluginandAgenticCommerceCompanyUserPostUpdatePlugin.Pyz\Yves\Router\RouterDependencyProvider: addAgenticCommerceRouteProviderPlugin.Pyz\Yves\CustomerPage\CustomerPageDependencyProvider: addAgenticCommerceAuthorizationCustomerRedirectStrategyPlugin, which sends the customer back to the authorization request after login, andAgenticCommerceAuthenticationTimeAfterCustomerAuthenticationSuccessPlugin, which records the login time.Pyz\Yves\EventDispatcher\EventDispatcherDependencyProvider: addAgenticCommerceFramingProtectionEventDispatcherPlugin.Pyz\Yves\ShopApplication\ShopApplicationDependencyProvider: addAgenticCommerceMenuItemWidget. The "Connected apps" entry in the customer menu needs aspryker-shop/customer-pagerelease whosecustomer-navigation.twigrenders this widget; with an older release the widget is registered but nothing shows it.- Import the glossary keys
agentic_commerce.*.
The feature's GlueRestPluginStackSubscriber opt-out for GlueApplication is automatic: the feature's own subscriber keeps the Glue REST plugin stacks away from delegated access paths, so nothing needs to be wired for it.
4. Resources are found on install
The Glue storefront resources (oauth-token, oauth-revoke, the two metadata documents and agentic-commerce-principals) are in resources/api/storefront/ and API Platform finds them as soon as the feature is installed. The Glue storefront container builds without the wiring of step 3, and other storefront endpoints keep working. The protocol endpoints answer 404 until delegated access is configured (see step 2). The principal resource answers 401 or 403 instead, because only a delegated access token that passed the agentic_commerce firewall can reach it. To drop them, add the feature's resource directory to excludedPathFragments in config/GlueStorefront/packages/spryker_api_platform.php:
- in a project:
vendor/spryker-feature/agentic-commerce/resources/api/; - in the suite:
src/SprykerFeature/AgenticCommerce/resources/api/.
The fragment is matched as a substring of the resource file path, so it must include the vendor or source directory. A project adds its own delegated resources under /agentic-commerce/ and guards them with ROLE_SCOPE_<SCOPE> roles, for example ROLE_SCOPE_AGENTIC__COMMERCE_PRINCIPAL__READ for the scope agentic-commerce:principal-read (: becomes _, - becomes __).
5. Deploy
vendor/bin/console transfer:generate
vendor/bin/console propel:install