/salesforce-commerce:sf-securityfrom salesforce-commerce
Implements Salesforce Commerce security including SLAS OAuth 2.1, session management, CSRF tokens, XSS prevention via isprint encoding in ISML, PCI compliance, RBAC in Business Manager, OWASP Top 10 protections, and Salesforce Shield for B2B.
Ships in salesforce-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Implement Salesforce Commerce security across B2C and B2B platforms.
Always fetch the latest official documentation BEFORE implementing security controls:
Why: OAuth flows, CSRF protection patterns, encoding modes, and PCI requirements evolve. Live docs ensure correct implementation of current security standards.
SLAS (B2C Commerce) -- OAuth 2.1 with PKCE:
| Client Type | Flow | Use Case |
|---|---|---|
| Public (browser/PWA Kit) | authorization_code_pkce | Guest and registered users |
| Private (server-side) | client_credentials | Guest sessions |
| Private (server-side) | authorization_code | Registered users |
| Any | Refresh token | Session extension |
PKCE (Proof Key for Code Exchange) is required for all public client flows. Guest tokens enable anonymous shopping before login.
Salesforce OAuth (B2B Commerce):
| Flow | Use Case |
|---|---|
| Connected Apps | OAuth application registration |
| JWT Bearer | Server-to-server authentication |
| Web Server Flow | User authorization with redirect |
Session Management:
Token Lifecycle:
| Token | Typical TTL | Storage |
|---|---|---|
| Access Token | 30 minutes | Memory or httpOnly cookie |
| Refresh Token | 30 days | httpOnly cookie (never localStorage) |
| CSRF Token | Per request | Hidden form field or custom header |
B2C Commerce (ISML):
| Encoding Mode | Context |
|---|---|
htmlcontent | HTML body text |
htmlsinglequote / htmldoublequote | HTML attributes |
jshtml | JavaScript strings in HTML |
jsonvalue | JSON data |
uricomponent | URL parameters |
Always use <isprint> with explicit encoding. Never use raw ${variable} for user-controlled data. Set Content Security Policy headers to restrict script sources.
B2B Commerce (LWC):
textContent instead of innerHTML in JavaScriptlightning-formatted-* components for safe rendering| Directive | Purpose |
|---|---|
default-src | Fallback for all resource types |
script-src | Allowed script sources (restrict to self and trusted CDNs) |
style-src | Allowed stylesheet sources |
img-src | Allowed image sources |
connect-src | Allowed API/fetch targets |
frame-ancestors | Clickjacking protection |
Configure CSP headers in Business Manager or via server configuration. Use nonce or hash for inline scripts rather than unsafe-inline.
B2C Commerce: Validate tokens with CSRFProtection.validateRequest() in controllers. Generate tokens with CSRFProtection.generateToken(). Include hidden token fields in all state-changing forms. Use double-submit cookie pattern for AJAX.
B2B Commerce: Built-in Salesforce CSRF protection. <lightning-input> includes tokens automatically. @AuraEnabled Apex methods have CSRF protection.
| Layer | Technique |
|---|---|
| Client-side | HTML5 validation, JavaScript checks (UX only, not security) |
| Server-side | Whitelist validation, type checking, length limits |
| Form definitions | SFCC XML form definitions with validation rules |
| Query API | Parameterized queries -- never string concatenation |
Always validate on the server. Client-side validation is a convenience, not a security measure.
| Requirement | Implementation |
|---|---|
| Tokenization | Never store raw card numbers; use tokenized payment methods |
| SAQ-A Scope | Use hosted payment fields to minimize PCI scope |
| TLS 1.2+ | Enforce for all API communication and payment processing |
| Log Masking | No card data in application logs |
| Gateway | Use Salesforce Commerce Payments or validated third-party processors |
B2C Commerce: Business Manager roles (Admin, Merchant, Content) with granular, site-specific permissions. Custom roles for organization-specific needs.
B2B Commerce: Salesforce profiles and permission sets. Buyer permissions control ordering (browse, cart, checkout, approve). Account hierarchy restricts visibility based on relationships.
B2B Sharing Rules:
| Threat | Mitigation |
|---|---|
| Injection | Parameterized queries via Query API; input whitelisting |
| Broken Auth | SLAS/OAuth best practices; MFA where available; strong password policies |
| Sensitive Data Exposure | Salesforce Shield encryption at rest (B2B); TLS in transit; log masking |
| Security Misconfiguration | Disable dev features in production; change default credentials; suppress stack traces |
| Access Control | Authorization checks on every request; least privilege principle |
| Monitoring | Log authentication events, failed logins, suspicious activity |
Fetch the SLAS OAuth 2.1 guide, B2C Commerce security reference, and Salesforce OWASP documentation for exact token flows, encoding specifications, and compliance requirements before implementing.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
salesforce-commerce, slas-oauth, csrf, xss-prevention, pci-compliance, rbac
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin salesforce-commerce24 skills in this plugin
/js-modernWrite modern JavaScript and TypeScript — ES6+ features, async/await, modules, destructuring, optional chaining, TypeScript types. Covers SFCC server-side JS (CommonJS, limited ES6), PWA Kit (full modern JS/TS), and LWC JavaScript (Lightning Locker constraints). Use when writing JavaScript for Salesforce Commerce./node-backendBuild Node.js backends for Salesforce Commerce — SFCC server-side JavaScript (not actual Node.js runtime), PWA Kit backend (Express-like SSR server), Commerce SDK for server-side SCAPI access, and async patterns for external service integration. Use when building server-side commerce logic./react-patternsBuild React applications for PWA Kit — hooks, composition, SSR, Commerce SDK integration, Chakra UI components, getProps data fetching, and client-side state management. PWA Kit uses React (NOT Remix/Next.js). Use when building PWA Kit storefronts./sf-b2b-apexBuild B2B Commerce Apex extensions using the CartExtension namespace — PricingCartCalculator, ShippingCartCalculator, TaxCartCalculator, InventoryCartCalculator implementations, governor limits, bulkification, test coverage (75% minimum), and checkout flow customization. Use when implementing server-side B2B commerce logic./sf-b2b-experienceBuild B2B Commerce storefronts with Experience Builder — LWR templates, page types (Home, Product, Category, Cart, Checkout), standard and custom components, theme layouts, navigation, SEO configuration, and site publishing. Use when assembling B2B/D2C storefronts./sf-b2b-lwcBuild B2B Commerce LWC components — Lightning Web Components with @api/@track/@wire decorators, commerce-specific wire adapters, custom events, Lightning Web Security, Jest unit testing, and component lifecycle. Use when building B2B storefront UI components.Other plugins' skills for the same job