Skip to content

Commit 9cbd448

Browse files
committed
refactoring of config documentation for clarity/accuracy
1 parent de9a5b9 commit 9cbd448

3 files changed

Lines changed: 170 additions & 52 deletions

File tree

docs/.vitepress/config.mts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ const guideSidebar = [
77
items: [
88
{ text: 'Introduction', link: '/guide/' },
99
{ text: 'Installation', link: '/guide/installation' },
10-
{ text: 'Authentication Setup', link: '/guide/authentication' },
1110
{ text: 'Configuration', link: '/guide/configuration' },
1211
{ text: 'Agent Skills & Plugins', link: '/guide/agent-skills' },
1312
],
1413
},
14+
{
15+
text: 'Guides',
16+
items: [
17+
{ text: 'Authentication Setup', link: '/guide/authentication' },
18+
{ text: 'Security', link: '/guide/security' },
19+
],
20+
},
1521
{
1622
text: 'Extending',
1723
items: [

docs/guide/configuration.md

Lines changed: 91 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,51 @@
11
# Configuration
22

3-
The B2C CLI supports multiple authentication methods and configuration options.
3+
The B2C CLI automatically detects and uses available credentials. You can provide credentials via CLI flags, environment variables, or configuration files.
44

55
::: tip
66
For detailed setup instructions including Account Manager API client creation and OCAPI configuration, see the [Authentication Setup](./authentication) guide.
77
:::
88

9-
## Authentication Methods
9+
## CLI Flags
1010

11-
The CLI supports multiple auth methods that can be specified via the `--auth-methods` flag:
11+
### OAuth (SCAPI/OCAPI)
1212

13-
- `client-credentials` - OAuth 2.0 client credentials flow (requires client ID and secret)
14-
- `implicit` - OAuth 2.0 implicit flow (requires client ID only, opens browser for login)
15-
- `basic` - Basic authentication (for WebDAV operations)
16-
- `api-key` - API key authentication
13+
OAuth is required for SCAPI and OCAPI operations (jobs, sites, SLAS, etc.) and can also be used for WebDAV operations when basic auth credentials are not provided.
1714

18-
### Specifying Auth Methods
19-
20-
You can specify allowed auth methods in priority order using comma-separated values or multiple flags:
21-
22-
```bash
23-
# Comma-separated (preferred)
24-
b2c code deploy --auth-methods client-credentials,implicit
25-
26-
# Multiple flags (also supported)
27-
b2c code deploy --auth-methods client-credentials --auth-methods implicit
28-
29-
# Via environment variable
30-
SFCC_AUTH_METHODS=client-credentials,implicit b2c code deploy
31-
```
32-
33-
The CLI will try each method in order until one succeeds. If no methods are specified, the default is `client-credentials,implicit`.
15+
#### Client Credentials (Recommended)
3416

35-
### OAuth Client Credentials (Recommended)
36-
37-
OAuth authentication using client credentials is the recommended method for production and CI/CD use.
17+
OAuth client credentials is the recommended method for production and CI/CD use:
3818

3919
```bash
4020
b2c code deploy \
41-
--server your-instance.demandware.net \
21+
--server abcd-123.dx.commercecloud.salesforce.com \
4222
--client-id your-client-id \
4323
--client-secret your-client-secret
4424
```
4525

46-
### OAuth Implicit Flow
26+
#### Implicit Flow
4727

4828
For development without a client secret, use implicit flow which opens a browser for authentication:
4929

5030
```bash
5131
b2c code deploy \
52-
--server your-instance.demandware.net \
32+
--server abcd-123.dx.commercecloud.salesforce.com \
5333
--client-id your-client-id \
5434
--auth-methods implicit
5535
```
5636

57-
### Basic Authentication
37+
### Basic Authentication (WebDAV)
5838

59-
For development and testing, you can use basic authentication with Business Manager credentials:
39+
Basic authentication uses your B2C instance username and access key. This method is only used for WebDAV operations (code deployment, file uploads, log access).
6040

6141
```bash
6242
b2c code deploy \
63-
--server your-instance.demandware.net \
43+
--server abcd-123.dx.commercecloud.salesforce.com \
6444
--username your-username \
65-
--password your-password
45+
--password your-access-key
6646
```
6747

68-
### API Key
69-
70-
For certain operations, you may use an API key.
48+
See [Configure WebDAV File Access](https://help.salesforce.com/s/articleView?id=cc.b2c_account_manager_sso_use_webdav_file_access.htm&type=5) for instructions on setting up your access key.
7149

7250
## Environment Variables
7351

@@ -92,10 +70,12 @@ You can create a `dw.json` file to store instance settings. The CLI searches for
9270

9371
```json
9472
{
95-
"hostname": "your-instance.demandware.net",
73+
"hostname": "abcd-123.dx.commercecloud.salesforce.com",
9674
"code-version": "version1",
9775
"client-id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
98-
"client-secret": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
76+
"client-secret": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
77+
"username": "your-username",
78+
"password": "your-access-key"
9979
}
10080
```
10181

@@ -109,24 +89,28 @@ For projects that work with multiple instances, use the `configs` array:
10989
{
11090
"name": "dev",
11191
"active": true,
112-
"hostname": "dev-instance.demandware.net",
92+
"hostname": "abcd-001.dx.commercecloud.salesforce.com",
11393
"code-version": "version1",
114-
"client-id": "dev-client-id"
94+
"client-id": "dev-client-id",
95+
"username": "dev-username",
96+
"password": "dev-access-key"
11597
},
11698
{
11799
"name": "staging",
118-
"hostname": "staging-instance.demandware.net",
100+
"hostname": "abcd-002.dx.commercecloud.salesforce.com",
119101
"code-version": "version1",
120-
"client-id": "staging-client-id"
102+
"client-id": "staging-client-id",
103+
"username": "staging-username",
104+
"password": "staging-access-key"
121105
}
122106
]
123107
}
124108
```
125109

126-
Use the `--instance` flag to select a specific configuration:
110+
Use the `-i` or `--instance` flag to select a specific configuration:
127111

128112
```bash
129-
b2c code deploy --instance staging
113+
b2c code deploy -i staging
130114
```
131115

132116
If no instance is specified, the config with `"active": true` is used.
@@ -136,16 +120,26 @@ If no instance is specified, the config with `"active": true` is used.
136120
| Field | Description |
137121
|-------|-------------|
138122
| `hostname` | B2C instance hostname |
139-
| `webdav-hostname` | Separate hostname for WebDAV (if different) |
123+
| `webdav-hostname` | Separate hostname for WebDAV (if different from main hostname). Also accepts `secureHostname` or `secure-server`. |
140124
| `code-version` | Code version for deployments |
141125
| `client-id` | OAuth client ID |
142126
| `client-secret` | OAuth client secret |
143-
| `username` | Basic auth username |
144-
| `password` | Basic auth password/access-key |
145-
| `scopes` | OAuth scopes (array or comma-separated string) |
146-
| `auth-methods` | Authentication methods in priority order |
147-
| `account-manager-host` | Custom Account Manager hostname |
148-
| `shortCode` | SCAPI short code |
127+
| `username` | Basic auth username (WebDAV) |
128+
| `password` | Basic auth access key (WebDAV) |
129+
| `oauth-scopes` | OAuth scopes (array of strings) |
130+
| `auth-methods` | Authentication methods in priority order (array of strings) |
131+
| `shortCode` | SCAPI short code. Also accepts `short-code` or `scapi-shortcode`. |
132+
133+
::: tip MRT Configuration
134+
Managed Runtime API key is not stored in `dw.json`. It is loaded from `~/.mobify`. You can specify `mrtProject` and `mrtEnvironment` in `dw.json` for project/environment selection.
135+
:::
136+
137+
For multi-instance configurations, each config object also supports:
138+
139+
| Field | Description |
140+
|-------|-------------|
141+
| `name` | Instance name for selection with `-i`/`--instance` |
142+
| `active` | Set to `true` to use this config by default |
149143

150144
### Resolution Priority
151145

@@ -179,6 +173,52 @@ If any field in a group is set by a higher-priority source, all fields in that g
179173
When you explicitly specify a hostname that differs from the `dw.json` hostname, the CLI ignores all other values from `dw.json` and only uses your explicit overrides. This prevents accidentally using credentials from one instance with a different server.
180174
:::
181175

176+
## MRT API Key
177+
178+
Managed Runtime (MRT) commands use an API key for authentication. The API key is resolved in this order:
179+
180+
1. `--api-key` flag
181+
2. `SFCC_MRT_API_KEY` environment variable
182+
3. `~/.mobify` config file
183+
184+
The `~/.mobify` file format:
185+
186+
```json
187+
{
188+
"api_key": "your-mrt-api-key"
189+
}
190+
```
191+
192+
When using the `--cloud-origin` flag to specify a different MRT endpoint, the CLI looks for `~/.mobify--{hostname}` instead. For example, `--cloud-origin https://custom.example.com` loads from `~/.mobify--custom.example.com`.
193+
194+
## Overriding Authentication Behavior
195+
196+
By default, the CLI automatically detects available credentials and tries authentication methods in this order: `client-credentials`, then `implicit`. You can override this behavior to control which methods are used.
197+
198+
### Available Auth Methods
199+
200+
- `client-credentials` - OAuth 2.0 client credentials flow (requires client ID and secret). Used for SCAPI/OCAPI and WebDAV.
201+
- `implicit` - OAuth 2.0 implicit flow (requires client ID only, opens browser for login). Used for SCAPI/OCAPI and WebDAV.
202+
- `basic` - Basic authentication with username and access key. Used for WebDAV operations only.
203+
- `api-key` - API key authentication. Used for MRT commands only.
204+
205+
### Specifying Auth Methods
206+
207+
You can specify allowed auth methods in priority order using comma-separated values or multiple flags:
208+
209+
```bash
210+
# Comma-separated (preferred)
211+
b2c code deploy --auth-methods client-credentials,implicit
212+
213+
# Multiple flags (also supported)
214+
b2c code deploy --auth-methods client-credentials --auth-methods implicit
215+
216+
# Via environment variable
217+
SFCC_AUTH_METHODS=client-credentials,implicit b2c code deploy
218+
```
219+
220+
The CLI will try each method in order until one succeeds.
221+
182222
## Next Steps
183223

184224
- [CLI Reference](/cli/) - Browse available commands

docs/guide/security.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Security
2+
3+
This page covers security practices used in the B2C Developer Tooling project, with a focus on supply chain security.
4+
5+
## Supply Chain Security
6+
7+
The JavaScript/Node.js ecosystem is particularly vulnerable to supply chain attacks due to the large number of transitive dependencies in typical projects. This project uses several pnpm features to mitigate these risks.
8+
9+
### Minimum Release Age
10+
11+
New package versions are quarantined for 48 hours before they can be installed:
12+
13+
```yaml
14+
# pnpm-workspace.yaml
15+
minimumReleaseAge: 2880 # minutes (48 hours)
16+
```
17+
18+
This provides a buffer period during which:
19+
- Malicious packages can be detected and removed from npm
20+
- Security researchers can identify and report compromised packages
21+
- The community can flag suspicious updates
22+
23+
If a package update is urgent, it can be added to the exclusion list:
24+
25+
```yaml
26+
minimumReleaseAgeExclude:
27+
- some-urgent-package
28+
```
29+
30+
### Trust Policy
31+
32+
Dependency downgrades are prevented to protect against downgrade attacks:
33+
34+
```yaml
35+
# pnpm-workspace.yaml
36+
trustPolicy: no-downgrade
37+
```
38+
39+
This ensures that once a package version is installed, it cannot be replaced with an older (potentially vulnerable) version without explicit action.
40+
41+
### Restricting Build Scripts
42+
43+
Only explicitly allowed packages can run build scripts (install/postinstall hooks):
44+
45+
```yaml
46+
# pnpm-workspace.yaml
47+
onlyBuiltDependencies:
48+
- unrs-resolver
49+
- yarn
50+
```
51+
52+
Build scripts are a common attack vector because they execute arbitrary code during installation. By default, pnpm blocks all build scripts except for packages in this allowlist.
53+
54+
When adding a new dependency that requires build scripts:
55+
1. Verify the package is legitimate and actively maintained
56+
2. Review what the build script does
57+
3. Add it to `onlyBuiltDependencies` if necessary
58+
59+
## Best Practices
60+
61+
### For Contributors
62+
63+
- Review dependency updates carefully, especially for packages with build scripts
64+
- Be cautious when adding new dependencies
65+
- Prefer packages with minimal transitive dependencies
66+
- Check package health on npm before adding (download counts, maintenance activity, known vulnerabilities)
67+
68+
### For Users
69+
70+
- Keep the CLI updated to receive security patches
71+
- Review the `pnpm-workspace.yaml` settings if you fork or modify this project
72+
- Consider using similar protections in your own projects

0 commit comments

Comments
 (0)