@bostonuniversity/buwp-local 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ROADMAP.md +2 -1
- package/docs/ARCHITECTURE.md +691 -0
- package/docs/CHANGELOG.md +149 -0
- package/docs/COMMANDS.md +462 -0
- package/docs/CREDENTIALS.md +484 -0
- package/docs/GETTING_STARTED.md +234 -0
- package/docs/MULTI_PROJECT.md +513 -0
- package/docs/ROADMAP.md +247 -0
- package/lib/commands/init.js +2 -1
- package/lib/commands/keychain.js +1 -1
- package/lib/commands/start.js +193 -8
- package/package.json +1 -1
- package/readme.md +13 -4
- /package/{IMPLEMENTATION_NOTES_V0.5.0_PHASE3.md → docs/archive/IMPLEMENTATION_NOTES_V0.5.0_PHASE3.md} +0 -0
- /package/{IMPLEMENTATION_SUMMARY.md → docs/archive/IMPLEMENTATION_SUMMARY.md} +0 -0
- /package/{KEYCHAIN_IMPLEMENTATION.md → docs/archive/KEYCHAIN_IMPLEMENTATION.md} +0 -0
- /package/{macos-keychain-notes.md → docs/archive/macos-keychain-notes.md} +0 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# Credential Management
|
|
2
|
+
|
|
3
|
+
This guide explains how to securely manage credentials for your buwp-local projects.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
buwp-local requires various credentials to function:
|
|
8
|
+
- Database passwords
|
|
9
|
+
- Shibboleth certificates and keys
|
|
10
|
+
- AWS S3 access keys
|
|
11
|
+
- OLAP credentials
|
|
12
|
+
|
|
13
|
+
You have two options for managing these credentials:
|
|
14
|
+
|
|
15
|
+
1. **macOS Keychain** (Recommended) - Secure, global, encrypted storage
|
|
16
|
+
2. **`.env.local` file** - Per-project, manual configuration
|
|
17
|
+
|
|
18
|
+
## Credential Types
|
|
19
|
+
|
|
20
|
+
buwp-local uses 15 different credential types:
|
|
21
|
+
|
|
22
|
+
### Database Credentials
|
|
23
|
+
- `WORDPRESS_DB_PASSWORD` - WordPress database user password
|
|
24
|
+
- `DB_ROOT_PASSWORD` - MySQL root password
|
|
25
|
+
|
|
26
|
+
### Shibboleth Credentials
|
|
27
|
+
- `SP_ENTITY_ID` - Service Provider entity ID
|
|
28
|
+
- `IDP_ENTITY_ID` - Identity Provider entity ID (default: `https://shib-test.bu.edu/idp/shibboleth`)
|
|
29
|
+
- `SHIB_IDP_LOGOUT` - IDP logout URL (default: `https://shib-test.bu.edu/idp/logout.jsp`)
|
|
30
|
+
- `SHIB_SP_KEY` - Service Provider private key (multiline PEM format)
|
|
31
|
+
- `SHIB_SP_CERT` - Service Provider certificate (multiline PEM format)
|
|
32
|
+
|
|
33
|
+
### S3 Credentials
|
|
34
|
+
- `S3_UPLOADS_BUCKET` - S3 bucket name for WordPress uploads
|
|
35
|
+
- `S3_UPLOADS_REGION` - AWS region (e.g., `us-east-1`)
|
|
36
|
+
- `S3_UPLOADS_ACCESS_KEY_ID` - AWS access key ID
|
|
37
|
+
- `S3_UPLOADS_SECRET_ACCESS_KEY` - AWS secret access key
|
|
38
|
+
- `S3_ACCESS_RULES_TABLE` - DynamoDB table for access rules
|
|
39
|
+
|
|
40
|
+
### OLAP Credentials
|
|
41
|
+
- `OLAP` - OLAP environment name
|
|
42
|
+
- `OLAP_ACCT_NBR` - OLAP account number
|
|
43
|
+
- `OLAP_REGION` - OLAP AWS region
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Option 1: macOS Keychain (Recommended)
|
|
48
|
+
|
|
49
|
+
### Why Use Keychain?
|
|
50
|
+
|
|
51
|
+
✅ **Secure** - Encrypted storage built into macOS
|
|
52
|
+
✅ **Global** - Credentials available to all buwp-local projects
|
|
53
|
+
✅ **Convenient** - Set up once, use everywhere
|
|
54
|
+
✅ **Protected** - Requires authentication to access
|
|
55
|
+
✅ **No files** - No plaintext credential files to accidentally commit
|
|
56
|
+
|
|
57
|
+
### Setup Process
|
|
58
|
+
|
|
59
|
+
#### Step 1: Get Credentials File
|
|
60
|
+
|
|
61
|
+
Download credentials from the dev server:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
scp user@devserver:/path/to/buwp-local-credentials.json ~/Downloads/
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Step 2: Import to Keychain
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx buwp-local keychain setup --file ~/Downloads/buwp-local-credentials.json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This will:
|
|
74
|
+
- Read all credentials from the JSON file
|
|
75
|
+
- Store each one securely in your Keychain
|
|
76
|
+
- Validate the format of each credential
|
|
77
|
+
- Prompt to delete the source file (recommended for security)
|
|
78
|
+
|
|
79
|
+
#### Step 3: Verify Import
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npx buwp-local keychain list
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
You should see all 15 credential types listed.
|
|
86
|
+
|
|
87
|
+
#### Step 4: Test Access
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx buwp-local keychain test
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This verifies Keychain access is working properly.
|
|
94
|
+
|
|
95
|
+
### Managing Keychain Credentials
|
|
96
|
+
|
|
97
|
+
**View a credential:**
|
|
98
|
+
```bash
|
|
99
|
+
npx buwp-local keychain get WORDPRESS_DB_PASSWORD
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Update a credential:**
|
|
103
|
+
```bash
|
|
104
|
+
npx buwp-local keychain set WORDPRESS_DB_PASSWORD "new-password"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Delete a credential:**
|
|
108
|
+
```bash
|
|
109
|
+
npx buwp-local keychain delete WORDPRESS_DB_PASSWORD
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**List all credentials:**
|
|
113
|
+
```bash
|
|
114
|
+
npx buwp-local keychain list
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Keychain Security
|
|
118
|
+
|
|
119
|
+
- Credentials are stored in your **login keychain**
|
|
120
|
+
- Service name: `buwp-local`
|
|
121
|
+
- Account name: `<credential-name>`
|
|
122
|
+
- Access is protected by macOS security
|
|
123
|
+
- First access may prompt for keychain password
|
|
124
|
+
|
|
125
|
+
You can view/edit credentials in **Keychain Access.app**:
|
|
126
|
+
1. Open **Keychain Access** (Applications → Utilities)
|
|
127
|
+
2. Search for `buwp-local`
|
|
128
|
+
3. Double-click any entry to view/edit
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Option 2: `.env.local` File
|
|
133
|
+
|
|
134
|
+
### When to Use `.env.local`
|
|
135
|
+
|
|
136
|
+
Use this method if you:
|
|
137
|
+
- Need per-project credentials (different credentials per project)
|
|
138
|
+
- Are not on macOS
|
|
139
|
+
- Prefer manual configuration
|
|
140
|
+
- Want to override specific Keychain credentials for testing
|
|
141
|
+
|
|
142
|
+
### Setup Process
|
|
143
|
+
|
|
144
|
+
#### Step 1: Create File
|
|
145
|
+
|
|
146
|
+
Copy the example file:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
cp .env.local.example .env.local
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Step 2: Add Credentials
|
|
153
|
+
|
|
154
|
+
Edit `.env.local` with your actual values:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Database
|
|
158
|
+
WORDPRESS_DB_PASSWORD=your-password-here
|
|
159
|
+
DB_ROOT_PASSWORD=your-root-password-here
|
|
160
|
+
|
|
161
|
+
# Shibboleth
|
|
162
|
+
SP_ENTITY_ID=https://your-sp-entity-id
|
|
163
|
+
IDP_ENTITY_ID=https://shib-test.bu.edu/idp/shibboleth
|
|
164
|
+
SHIB_IDP_LOGOUT=https://shib-test.bu.edu/idp/logout.jsp
|
|
165
|
+
SHIB_SP_KEY="-----BEGIN PRIVATE KEY-----
|
|
166
|
+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC...
|
|
167
|
+
-----END PRIVATE KEY-----"
|
|
168
|
+
SHIB_SP_CERT="-----BEGIN CERTIFICATE-----
|
|
169
|
+
MIIDXTCCAkWgAwIBAgIJAKJ5CqJ5CqJ5MA0GCSqGSIb3DQEBBQUA...
|
|
170
|
+
-----END CERTIFICATE-----"
|
|
171
|
+
|
|
172
|
+
# S3
|
|
173
|
+
S3_UPLOADS_BUCKET=your-bucket-name
|
|
174
|
+
S3_UPLOADS_REGION=us-east-1
|
|
175
|
+
S3_UPLOADS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
|
|
176
|
+
S3_UPLOADS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
|
177
|
+
S3_ACCESS_RULES_TABLE=your-access-rules-table
|
|
178
|
+
|
|
179
|
+
# OLAP
|
|
180
|
+
OLAP=your-olap-name
|
|
181
|
+
OLAP_ACCT_NBR=123456789
|
|
182
|
+
OLAP_REGION=us-east-1
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Step 3: Multiline Values
|
|
186
|
+
|
|
187
|
+
For multiline credentials (like `SHIB_SP_KEY` and `SHIB_SP_CERT`), use quotes:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
SHIB_SP_KEY="-----BEGIN PRIVATE KEY-----
|
|
191
|
+
Line 1 of key
|
|
192
|
+
Line 2 of key
|
|
193
|
+
Line 3 of key
|
|
194
|
+
-----END PRIVATE KEY-----"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Or use `\n` for newlines:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
SHIB_SP_KEY="-----BEGIN PRIVATE KEY-----\nLine 1\nLine 2\n-----END PRIVATE KEY-----"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### `.env.local` Security
|
|
204
|
+
|
|
205
|
+
**⚠️ Critical Security Rules:**
|
|
206
|
+
|
|
207
|
+
1. **NEVER commit `.env.local` to git**
|
|
208
|
+
2. Add it to `.gitignore` immediately
|
|
209
|
+
3. Don't share it via Slack, email, or other channels
|
|
210
|
+
4. Store securely if backing up
|
|
211
|
+
5. Delete from Downloads after importing to Keychain
|
|
212
|
+
|
|
213
|
+
**Add to `.gitignore`:**
|
|
214
|
+
```bash
|
|
215
|
+
echo ".env.local" >> .gitignore
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Credential Loading Priority
|
|
221
|
+
|
|
222
|
+
buwp-local checks for credentials in this order:
|
|
223
|
+
|
|
224
|
+
1. **`.env.local` file** (highest priority - overrides Keychain)
|
|
225
|
+
2. **macOS Keychain** (fallback if not in `.env.local`)
|
|
226
|
+
3. **Error** if not found in either location
|
|
227
|
+
|
|
228
|
+
This means:
|
|
229
|
+
- `.env.local` can override specific Keychain credentials for testing
|
|
230
|
+
- Projects without `.env.local` automatically use Keychain
|
|
231
|
+
- Mix and match: some credentials from Keychain, some from `.env.local`
|
|
232
|
+
|
|
233
|
+
### Example: Mixed Credentials
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# .env.local (only override database password for testing)
|
|
237
|
+
WORDPRESS_DB_PASSWORD=test-password
|
|
238
|
+
|
|
239
|
+
# All other credentials loaded from Keychain automatically
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Credential Validation
|
|
245
|
+
|
|
246
|
+
### Automatic Validation
|
|
247
|
+
|
|
248
|
+
When you run `start`, buwp-local automatically validates that all required credentials are available:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
npx buwp-local start
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
If credentials are missing, you'll see:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
⚠️ Missing required credentials:
|
|
258
|
+
- WORDPRESS_DB_PASSWORD
|
|
259
|
+
- S3_UPLOADS_ACCESS_KEY_ID
|
|
260
|
+
|
|
261
|
+
Would you like to set up credentials now? (y/n)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Choose:
|
|
265
|
+
- **Yes** - Opens interactive Keychain setup
|
|
266
|
+
- **No** - Exit and set up credentials manually
|
|
267
|
+
|
|
268
|
+
### Manual Validation
|
|
269
|
+
|
|
270
|
+
Check your configuration anytime:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npx buwp-local keychain status
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
This displays an inventory of your current credentials.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Troubleshooting
|
|
281
|
+
|
|
282
|
+
### "Credential not found" Error
|
|
283
|
+
|
|
284
|
+
**Problem:** `npx buwp-local start` fails with missing credential error
|
|
285
|
+
|
|
286
|
+
**Solutions:**
|
|
287
|
+
|
|
288
|
+
1. Check Keychain:
|
|
289
|
+
```bash
|
|
290
|
+
npx buwp-local keychain list
|
|
291
|
+
npx buwp-local keychain get WORDPRESS_DB_PASSWORD
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
2. Check `.env.local`:
|
|
295
|
+
```bash
|
|
296
|
+
cat .env.local | grep WORDPRESS_DB_PASSWORD
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
3. Re-import to Keychain:
|
|
300
|
+
```bash
|
|
301
|
+
npx buwp-local keychain setup --file ~/Downloads/credentials.json
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Keychain Access Denied
|
|
305
|
+
|
|
306
|
+
**Problem:** Problems when accessing Keychain
|
|
307
|
+
|
|
308
|
+
**Solutions:**
|
|
309
|
+
|
|
310
|
+
1. Open **Keychain Access.app**
|
|
311
|
+
2. Find `buwp-local` entries
|
|
312
|
+
3. Confirm contents by double-clicking an entry or right-click → "Copy Password to Clipboard"
|
|
313
|
+
|
|
314
|
+
### Multiline Credentials Not Working
|
|
315
|
+
|
|
316
|
+
**Problem:** `SHIB_SP_KEY` appears garbled or doesn't work
|
|
317
|
+
|
|
318
|
+
**Cause:** Improper formatting in `.env.local`
|
|
319
|
+
|
|
320
|
+
**Solution:** Ensure proper quoting:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
# ✅ Correct
|
|
324
|
+
SHIB_SP_KEY="-----BEGIN PRIVATE KEY-----
|
|
325
|
+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcw...
|
|
326
|
+
-----END PRIVATE KEY-----"
|
|
327
|
+
|
|
328
|
+
# ❌ Wrong - no quotes
|
|
329
|
+
SHIB_SP_KEY=-----BEGIN PRIVATE KEY-----
|
|
330
|
+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcw...
|
|
331
|
+
-----END PRIVATE KEY-----
|
|
332
|
+
|
|
333
|
+
# ❌ Wrong - single quotes don't work
|
|
334
|
+
SHIB_SP_KEY='-----BEGIN PRIVATE KEY-----...'
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Docker Can't See Credentials
|
|
338
|
+
|
|
339
|
+
**Problem:** Docker fails with "environment variable not set" errors
|
|
340
|
+
|
|
341
|
+
**Cause:** Credentials not loaded properly
|
|
342
|
+
|
|
343
|
+
**Solution:**
|
|
344
|
+
|
|
345
|
+
1. Verify credentials exist:
|
|
346
|
+
```bash
|
|
347
|
+
npx buwp-local keychain status
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
2. Check generated env file (for debugging only):
|
|
351
|
+
```bash
|
|
352
|
+
ls -la .buwp-local/.env.*
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
3. Restart with verbose logging:
|
|
356
|
+
```bash
|
|
357
|
+
DEBUG=* npx buwp-local start
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Wrong Credentials
|
|
361
|
+
|
|
362
|
+
**Problem:** Can't login to WordPress or S3 uploads fail
|
|
363
|
+
|
|
364
|
+
**Solutions:**
|
|
365
|
+
|
|
366
|
+
1. Update the credential:
|
|
367
|
+
```bash
|
|
368
|
+
npx buwp-local keychain set WORDPRESS_DB_PASSWORD "correct-password"
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
2. Or update `.env.local`:
|
|
372
|
+
```bash
|
|
373
|
+
# Edit .env.local with correct values
|
|
374
|
+
nano .env.local
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
3. Restart containers:
|
|
378
|
+
```bash
|
|
379
|
+
npx buwp-local restart
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Best Practices
|
|
385
|
+
|
|
386
|
+
### ✅ Do
|
|
387
|
+
|
|
388
|
+
- **Use Keychain for primary credentials** - Set up once globally
|
|
389
|
+
- **Delete credential files** after importing to Keychain
|
|
390
|
+
- **Add `.env.local` to `.gitignore`** immediately
|
|
391
|
+
- **Use `.env.local` for testing overrides** - Test different credentials without changing Keychain
|
|
392
|
+
- **Rotate credentials regularly** - Update old passwords/keys
|
|
393
|
+
- **Document credential sources** - Note where team members get credentials
|
|
394
|
+
|
|
395
|
+
### ❌ Don't
|
|
396
|
+
|
|
397
|
+
- **Never commit `.env.local`** to version control
|
|
398
|
+
- **Don't share credentials via chat/email** - Use secure transfer methods
|
|
399
|
+
- **Don't store plaintext backups** - Use encrypted storage
|
|
400
|
+
|
|
401
|
+
### Team Workflow
|
|
402
|
+
|
|
403
|
+
**Recommended approach for teams:**
|
|
404
|
+
|
|
405
|
+
1. **IT provides** encrypted credential file to developers
|
|
406
|
+
2. **Developer imports** to Keychain once:
|
|
407
|
+
```bash
|
|
408
|
+
npx buwp-local keychain setup --file ~/Downloads/credentials.json
|
|
409
|
+
```
|
|
410
|
+
3. **Developer deletes** source file
|
|
411
|
+
4. **All projects** automatically use Keychain credentials
|
|
412
|
+
5. **Per-project overrides** use `.env.local` as needed (not committed)
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Credential File Format
|
|
417
|
+
|
|
418
|
+
If creating your own credentials JSON file for import:
|
|
419
|
+
|
|
420
|
+
```json
|
|
421
|
+
{
|
|
422
|
+
"WORDPRESS_DB_PASSWORD": "password123",
|
|
423
|
+
"DB_ROOT_PASSWORD": "rootpass123",
|
|
424
|
+
"SP_ENTITY_ID": "https://your-sp-entity-id",
|
|
425
|
+
"IDP_ENTITY_ID": "https://shib-test.bu.edu/idp/shibboleth",
|
|
426
|
+
"SHIB_IDP_LOGOUT": "https://shib-test.bu.edu/idp/logout.jsp",
|
|
427
|
+
"SHIB_SP_KEY": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEF...\n-----END PRIVATE KEY-----",
|
|
428
|
+
"SHIB_SP_CERT": "-----BEGIN CERTIFICATE-----\nMIIDXTCCAkWgAwIBAgIJAKJ5...\n-----END CERTIFICATE-----",
|
|
429
|
+
"S3_UPLOADS_BUCKET": "bu-wordpress-uploads",
|
|
430
|
+
"S3_UPLOADS_REGION": "us-east-1",
|
|
431
|
+
"S3_UPLOADS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
|
|
432
|
+
"S3_UPLOADS_SECRET_ACCESS_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
|
|
433
|
+
"S3_ACCESS_RULES_TABLE": "bu-access-rules",
|
|
434
|
+
"OLAP": "protected-s3-production-olap",
|
|
435
|
+
"OLAP_ACCT_NBR": "123456789",
|
|
436
|
+
"OLAP_REGION": "us-east-1"
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Notes:**
|
|
441
|
+
- Use `\n` for newlines in multiline values (JSON format)
|
|
442
|
+
- All values must be strings
|
|
443
|
+
- Validate JSON syntax before importing
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Security Architecture
|
|
448
|
+
|
|
449
|
+
### How Credentials Flow
|
|
450
|
+
|
|
451
|
+
1. **Storage** - Credentials stored in Keychain or `.env.local`
|
|
452
|
+
2. **Load** - buwp-local reads credentials at runtime
|
|
453
|
+
3. **Temp file** - Creates secure temp file (0600 permissions) with credentials
|
|
454
|
+
4. **Docker** - Docker Compose reads temp file via `env_file` directive
|
|
455
|
+
5. **Cleanup** - Temp file deleted when containers stop
|
|
456
|
+
|
|
457
|
+
### Why Temp Files?
|
|
458
|
+
|
|
459
|
+
buwp-local uses temporary environment files instead of passing credentials via command-line arguments because:
|
|
460
|
+
|
|
461
|
+
✅ **More secure** - Not visible in process list
|
|
462
|
+
✅ **Handles multiline** - Supports certificates and keys
|
|
463
|
+
✅ **Docker native** - Standard Docker Compose pattern
|
|
464
|
+
✅ **Auto cleanup** - Files deleted automatically
|
|
465
|
+
|
|
466
|
+
### Temp File Location
|
|
467
|
+
|
|
468
|
+
```
|
|
469
|
+
.buwp-local/.env.XXXXXX (random suffix)
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**Permissions:** `0600` (owner read/write only)
|
|
473
|
+
**Lifetime:** Exists only while containers are running
|
|
474
|
+
**Cleanup:** Automatically deleted by `stop`, `destroy`, or process exit
|
|
475
|
+
|
|
476
|
+
TODO: double-check cleanup code
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## See Also
|
|
481
|
+
|
|
482
|
+
- [Getting Started](GETTING_STARTED.md) - Initial setup guide
|
|
483
|
+
- [Commands Reference](COMMANDS.md) - All credential commands
|
|
484
|
+
- [Architecture](ARCHITECTURE.md) - Technical implementation details
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Getting Started with buwp-local
|
|
2
|
+
|
|
3
|
+
This guide will help you quickly set up a local WordPress development environment for Boston University web projects.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Before you begin, make sure you have:
|
|
8
|
+
|
|
9
|
+
1. **Docker Desktop** installed and running ([Download](https://www.docker.com/products/docker-desktop))
|
|
10
|
+
2. **Node.js 18+** installed ([Download](https://nodejs.org/))
|
|
11
|
+
3. **GitHub access token** with `read:packages` scope ([Create token](https://github.com/settings/tokens))
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### 1. Login to GitHub Packages
|
|
16
|
+
|
|
17
|
+
Authenticate with GitHub Packages to access the BU WordPress Docker image:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
echo YOUR_GITHUB_TOKEN | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or just login interactively:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
docker login ghcr.io
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Install buwp-local CLI
|
|
30
|
+
|
|
31
|
+
Navigate to your project directory and install the CLI tool:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @bostonuniversity/buwp-local --save-dev
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 3. Set Up Credentials (Recommended)
|
|
38
|
+
|
|
39
|
+
This is a one-time setup to securely store your database passwords, S3 keys, and other secrets in your macOS Keychain. Once stored in the keychain, buwp-local will automatically retrieve them for any project.
|
|
40
|
+
|
|
41
|
+
**Option A: Keychain (Secure, macOS only)**
|
|
42
|
+
|
|
43
|
+
Download credentials from the dev server:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
scp user@devserver:/path/to/buwp-local-credentials.json ~/Downloads/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Import the credentials from this downloaded file into your macOS Keychain:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx buwp-local keychain setup --file ~/Downloads/buwp-local-credentials.json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This stores credentials securely in your Keychain for all buwp-local projects.
|
|
56
|
+
|
|
57
|
+
**Option B: Environment File (Manual)**
|
|
58
|
+
|
|
59
|
+
Copy the example file and add your credentials:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cp .env.local.example .env.local
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Edit `.env.local` with your database passwords, S3 keys, etc. **Never commit this file!**
|
|
66
|
+
|
|
67
|
+
> 💡 **Tip:** Keychain is more secure and convenient since credentials are shared across all projects. You can always override with `.env.local` for specific projects.
|
|
68
|
+
|
|
69
|
+
### 4. Initialize Your Project
|
|
70
|
+
|
|
71
|
+
Run the interactive setup assistant to create your `.buwp-local.json` configuration file:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx buwp-local init
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This will guide you through:
|
|
78
|
+
- **Project type** (plugin, theme, mu-plugin, or sandbox)
|
|
79
|
+
- **Hostname** (e.g., `username-myproject.local`)
|
|
80
|
+
- **Ports** (HTTP, HTTPS, database)
|
|
81
|
+
- **Services** (Redis, S3, Shibboleth)
|
|
82
|
+
- **Volume mappings** (automatically configured for plugin/theme/mu-plugin types)
|
|
83
|
+
|
|
84
|
+
The `init` command creates `.buwp-local.json` with your configuration; the `start` command uses this file to launch your environment.
|
|
85
|
+
|
|
86
|
+
### 5. Add Hostname to /etc/hosts
|
|
87
|
+
|
|
88
|
+
Add your local hostname so your browser can find it:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
sudo bash -c 'echo "127.0.0.1 username-myproject.local" >> /etc/hosts'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Replace `username-myproject.local` with the hostname you chose in step 4.
|
|
95
|
+
|
|
96
|
+
### 6. Start Your Environment
|
|
97
|
+
|
|
98
|
+
Start the Docker containers:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx buwp-local start
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The first run will pull Docker images and initialize your WordPress database. This may take a few minutes.
|
|
105
|
+
|
|
106
|
+
### 7. Access Your Site
|
|
107
|
+
|
|
108
|
+
Open your browser and navigate to:
|
|
109
|
+
- **HTTPS:** `https://username-myproject.local`
|
|
110
|
+
|
|
111
|
+
🎉 **Success!** Your local WordPress environment is running.
|
|
112
|
+
|
|
113
|
+
You can now develop your plugin/theme with live code sync via volume mapping, and the container can also be opened in vscode.
|
|
114
|
+
|
|
115
|
+
## Initial WordPress Setup
|
|
116
|
+
|
|
117
|
+
### Create a Local User
|
|
118
|
+
|
|
119
|
+
If running with Shibboleth enabled, create a local WordPress user with super admin privileges:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Create the user
|
|
123
|
+
npx buwp-local wp user create username username@bu.edu --role=administrator
|
|
124
|
+
|
|
125
|
+
# Promote to super admin
|
|
126
|
+
npx buwp-local wp super-admin add username@bu.edu
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Import Site Content (Optional)
|
|
130
|
+
|
|
131
|
+
Pull a snapshot from production or staging:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npx buwp-local wp site-manager snapshot-pull \
|
|
135
|
+
--source=https://www.bu.edu/admissions/ \
|
|
136
|
+
--destination=http://username-myproject.local/admissions
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This imports the database and copies media files to the s3 bucket from the specified site.
|
|
140
|
+
|
|
141
|
+
## Common Tasks
|
|
142
|
+
|
|
143
|
+
### Start/Stop
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npx buwp-local start # Start containers
|
|
147
|
+
npx buwp-local stop # Stop containers
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### View Logs
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npx buwp-local logs # Show recent logs
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Run WP-CLI Commands
|
|
158
|
+
|
|
159
|
+
The `wp` command can be used to run any WP-CLI commands inside the WordPress container:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npx buwp-local wp plugin list
|
|
163
|
+
npx buwp-local wp post list --format=json
|
|
164
|
+
npx buwp-local wp cache flush
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Enable Xdebug
|
|
168
|
+
|
|
169
|
+
Xdebug can be enabled at startup:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npx buwp-local start --xdebug
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Destroy Environment
|
|
176
|
+
|
|
177
|
+
Remove all containers and volumes (fresh start):
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npx buwp-local destroy
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Next Steps
|
|
184
|
+
|
|
185
|
+
- **[Commands Reference](COMMANDS.md)** - Full list of available commands
|
|
186
|
+
- **[Credential Management](CREDENTIALS.md)** - Detailed guide to managing secrets
|
|
187
|
+
- **[Multi-Project Setup](MULTI_PROJECT.md)** - Run multiple projects simultaneously
|
|
188
|
+
- **[Architecture](ARCHITECTURE.md)** - Understand how buwp-local works
|
|
189
|
+
|
|
190
|
+
## Troubleshooting
|
|
191
|
+
|
|
192
|
+
### Docker Not Running
|
|
193
|
+
|
|
194
|
+
Verify Docker Desktop is running:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
docker info
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Credential Issues
|
|
201
|
+
|
|
202
|
+
Validate your configuration:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npx buwp-local keychain status
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
This displays an inventory of stored credentials.
|
|
209
|
+
|
|
210
|
+
### Need Help?
|
|
211
|
+
|
|
212
|
+
Run any command with `--help`:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npx buwp-local --help
|
|
216
|
+
npx buwp-local start --help
|
|
217
|
+
npx buwp-local keychain --help
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## File Structure
|
|
221
|
+
|
|
222
|
+
After setup, your project will have:
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
your-project/
|
|
226
|
+
├── .buwp-local.json # Configuration (this is okay to commit)
|
|
227
|
+
├── .env.local # Secrets (NEVER commit)
|
|
228
|
+
├── .buwp-local/ # Generated files (don't commit)
|
|
229
|
+
│ └── docker-compose.yml # Generated at runtime
|
|
230
|
+
├── node_modules/
|
|
231
|
+
└── package.json
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Important:** Add `.env.local` and `.buwp-local/` to your `.gitignore`!
|