@authrim/setup 0.1.61 → 0.1.63
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/README.md +51 -480
- package/dist/core/wrangler.d.ts.map +1 -1
- package/dist/core/wrangler.js +6 -3
- package/dist/core/wrangler.js.map +1 -1
- package/dist/web/api.d.ts.map +1 -1
- package/dist/web/api.js +42 -3
- package/dist/web/api.js.map +1 -1
- package/dist/web/ui.d.ts.map +1 -1
- package/dist/web/ui.js +411 -51
- package/dist/web/ui.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,592 +1,163 @@
|
|
|
1
1
|
# @authrim/setup
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> ⚠️ **WARNING: This project is still under active development and does not work correctly yet!**
|
|
6
|
-
>
|
|
7
|
-
> The Admin UI is incomplete and does not support login functionality. Please wait for a stable release before using in production.
|
|
3
|
+
CLI and Web UI for deploying Authrim OIDC Provider to Cloudflare Workers.
|
|
8
4
|
|
|
9
5
|
[](https://www.npmjs.com/package/@authrim/setup)
|
|
10
6
|
[](https://github.com/sgrastar/authrim/blob/main/LICENSE)
|
|
11
7
|
|
|
12
|
-
## Overview
|
|
13
|
-
|
|
14
|
-
`@authrim/setup` is the official setup tool for deploying [Authrim](https://github.com/sgrastar/authrim) to Cloudflare Workers. It provides both an interactive CLI and a Web UI to guide you through:
|
|
15
|
-
|
|
16
|
-
- Provisioning Cloudflare resources (D1 databases, KV namespaces, Queues)
|
|
17
|
-
- Generating cryptographic keys and secrets
|
|
18
|
-
- Configuring environment-specific settings
|
|
19
|
-
- Deploying all Authrim workers in the correct order
|
|
20
|
-
- Setting up the initial administrator account
|
|
21
|
-
- **Managing existing environments** (view, inspect, delete)
|
|
22
|
-
|
|
23
8
|
## Quick Start
|
|
24
9
|
|
|
25
10
|
```bash
|
|
26
|
-
#
|
|
27
|
-
npx @authrim/setup
|
|
28
|
-
|
|
29
|
-
# Manage existing environments (no source download needed)
|
|
30
|
-
npx @authrim/setup manage
|
|
31
|
-
|
|
32
|
-
# Or install globally
|
|
33
|
-
npm install -g @authrim/setup
|
|
34
|
-
authrim-setup
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Usage Modes
|
|
38
|
-
|
|
39
|
-
### 1. Web UI Mode (Default)
|
|
40
|
-
|
|
41
|
-
Run without arguments to launch the interactive Web UI:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
11
|
+
# Web UI (recommended)
|
|
44
12
|
npx @authrim/setup
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This opens a browser with a step-by-step wizard featuring:
|
|
48
|
-
- **New Setup**: Create a new Authrim deployment from scratch
|
|
49
|
-
- **Load Config**: Resume or redeploy using an existing configuration
|
|
50
|
-
- **Manage Environments**: View and delete existing environments
|
|
51
|
-
|
|
52
|
-
### 2. Environment Management Mode
|
|
53
13
|
|
|
54
|
-
|
|
14
|
+
# CLI mode
|
|
15
|
+
npx @authrim/setup --cli
|
|
55
16
|
|
|
56
|
-
|
|
17
|
+
# Manage existing environments only
|
|
57
18
|
npx @authrim/setup manage
|
|
58
19
|
```
|
|
59
20
|
|
|
60
|
-
|
|
61
|
-
- Auto-detect all Authrim environments in your Cloudflare account
|
|
62
|
-
- View resource counts (Workers, D1, KV, Queues, R2)
|
|
63
|
-
- View detailed resource information (D1 size/region, Worker deploy info)
|
|
64
|
-
- Delete environments with granular resource selection
|
|
65
|
-
- Real-time progress display
|
|
66
|
-
|
|
67
|
-
### 3. CLI Mode
|
|
68
|
-
|
|
69
|
-
For terminal-based setup or CI/CD integration:
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
npx @authrim/setup --cli
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### 4. Deploy Existing Configuration
|
|
76
|
-
|
|
77
|
-
If you already have an `authrim-config.json`:
|
|
21
|
+
## Requirements
|
|
78
22
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
23
|
+
- Node.js >= 20.0.0
|
|
24
|
+
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/) installed and authenticated
|
|
25
|
+
- Cloudflare Workers Paid plan
|
|
82
26
|
|
|
83
27
|
## Commands
|
|
84
28
|
|
|
85
29
|
### `init` (default)
|
|
86
30
|
|
|
87
|
-
Initialize a new Authrim project:
|
|
88
|
-
|
|
89
31
|
```bash
|
|
90
|
-
npx @authrim/setup
|
|
32
|
+
npx @authrim/setup [options]
|
|
91
33
|
|
|
92
34
|
Options:
|
|
93
|
-
--cli
|
|
94
|
-
--config <path> Load existing configuration
|
|
95
|
-
--keep <path> Keep source files at specified path
|
|
35
|
+
--cli CLI mode instead of Web UI
|
|
36
|
+
--config <path> Load existing configuration
|
|
96
37
|
--env <name> Environment name (prod, staging, dev)
|
|
97
38
|
```
|
|
98
39
|
|
|
99
40
|
### `manage`
|
|
100
41
|
|
|
101
|
-
Manage existing
|
|
42
|
+
Manage existing environments (no source code required):
|
|
102
43
|
|
|
103
44
|
```bash
|
|
104
|
-
npx @authrim/setup manage
|
|
105
|
-
|
|
106
|
-
Options:
|
|
107
|
-
--port <number> Web UI port (default: 3456)
|
|
108
|
-
--no-browser Do not open browser automatically
|
|
45
|
+
npx @authrim/setup manage
|
|
109
46
|
```
|
|
110
47
|
|
|
111
48
|
### `deploy`
|
|
112
49
|
|
|
113
|
-
Deploy Authrim to Cloudflare:
|
|
114
|
-
|
|
115
50
|
```bash
|
|
116
51
|
npx @authrim/setup deploy [options]
|
|
117
52
|
|
|
118
53
|
Options:
|
|
119
|
-
-c, --config <path> Config file path
|
|
54
|
+
-c, --config <path> Config file path
|
|
120
55
|
-e, --env <env> Environment name
|
|
121
56
|
--component <name> Deploy single component
|
|
122
57
|
--dry-run Preview without deploying
|
|
123
58
|
--skip-secrets Skip secrets upload
|
|
124
|
-
--
|
|
125
|
-
-y, --yes Skip confirmation prompts
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### `download`
|
|
129
|
-
|
|
130
|
-
Download Authrim source code only:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
npx @authrim/setup download [options]
|
|
134
|
-
|
|
135
|
-
Options:
|
|
136
|
-
-o, --output <path> Output directory (default: "./authrim")
|
|
137
|
-
--repo <repository> GitHub repository (default: "sgrastar/authrim")
|
|
138
|
-
--ref <gitRef> Git tag or branch (default: latest release)
|
|
139
|
-
--force Overwrite existing directory
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### `status`
|
|
143
|
-
|
|
144
|
-
Check deployment status:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
npx @authrim/setup status [options]
|
|
148
|
-
|
|
149
|
-
Options:
|
|
150
|
-
-c, --config <path> Config file path
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### `config`
|
|
154
|
-
|
|
155
|
-
Manage configuration:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
npx @authrim/setup config [options]
|
|
159
|
-
|
|
160
|
-
Options:
|
|
161
|
-
--show Show current configuration
|
|
162
|
-
--validate Validate configuration file
|
|
163
|
-
--json Output in JSON format
|
|
59
|
+
-y, --yes Skip confirmation (CI/CD)
|
|
164
60
|
```
|
|
165
61
|
|
|
166
62
|
### `delete`
|
|
167
63
|
|
|
168
|
-
Delete an Authrim environment and its resources:
|
|
169
|
-
|
|
170
64
|
```bash
|
|
171
65
|
npx @authrim/setup delete [options]
|
|
172
66
|
|
|
173
67
|
Options:
|
|
174
|
-
--env <name> Environment
|
|
175
|
-
-y, --yes Skip confirmation
|
|
68
|
+
--env <name> Environment to delete
|
|
69
|
+
-y, --yes Skip confirmation (CI/CD)
|
|
176
70
|
--no-workers Keep Workers
|
|
177
71
|
--no-d1 Keep D1 databases
|
|
178
72
|
--no-kv Keep KV namespaces
|
|
179
|
-
--no-queues Keep Queues
|
|
180
|
-
--no-r2 Keep R2 buckets
|
|
181
|
-
--all Delete all resource types (default)
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Examples:
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
# Interactive mode - prompts for environment selection
|
|
188
|
-
npx @authrim/setup delete
|
|
189
|
-
|
|
190
|
-
# CI/CD mode - no prompts
|
|
191
|
-
npx @authrim/setup delete --env staging --yes
|
|
192
|
-
|
|
193
|
-
# Partial deletion - keep D1 databases
|
|
194
|
-
npx @authrim/setup delete --env dev --no-d1 --yes
|
|
195
73
|
```
|
|
196
74
|
|
|
197
75
|
### `info`
|
|
198
76
|
|
|
199
|
-
Display detailed information about Authrim resources:
|
|
200
|
-
|
|
201
77
|
```bash
|
|
202
78
|
npx @authrim/setup info [options]
|
|
203
79
|
|
|
204
80
|
Options:
|
|
205
81
|
--env <name> Environment name
|
|
206
|
-
--json
|
|
207
|
-
--d1
|
|
208
|
-
--workers
|
|
82
|
+
--json JSON output (for scripting)
|
|
83
|
+
--d1 D1 info only
|
|
84
|
+
--workers Worker info only
|
|
209
85
|
```
|
|
210
86
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
# Interactive mode
|
|
215
|
-
npx @authrim/setup info
|
|
216
|
-
|
|
217
|
-
# Specific environment with JSON output (for CI/CD)
|
|
218
|
-
npx @authrim/setup info --env prod --json
|
|
219
|
-
|
|
220
|
-
# D1 database details only
|
|
221
|
-
npx @authrim/setup info --env prod --d1
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### `secrets`
|
|
225
|
-
|
|
226
|
-
Upload secrets to Cloudflare Workers:
|
|
87
|
+
### `config`
|
|
227
88
|
|
|
228
89
|
```bash
|
|
229
|
-
npx @authrim/setup
|
|
90
|
+
npx @authrim/setup config [options]
|
|
230
91
|
|
|
231
92
|
Options:
|
|
232
|
-
--
|
|
233
|
-
--
|
|
234
|
-
--
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
## Web UI Features
|
|
238
|
-
|
|
239
|
-
### Resource Provisioning
|
|
240
|
-
|
|
241
|
-
Before creating resources, the UI shows a preview of what will be created:
|
|
242
|
-
|
|
243
|
-
```
|
|
244
|
-
📋 Resource Names:
|
|
245
|
-
D1 Databases:
|
|
246
|
-
• prod-authrim-core-db
|
|
247
|
-
• prod-authrim-pii-db
|
|
248
|
-
|
|
249
|
-
KV Namespaces:
|
|
250
|
-
• prod-CLIENTS_CACHE
|
|
251
|
-
• prod-SETTINGS
|
|
252
|
-
• prod-AUTHRIM_CONFIG
|
|
253
|
-
...
|
|
254
|
-
|
|
255
|
-
Cryptographic Keys:
|
|
256
|
-
• .keys/private.pem (RSA Private Key)
|
|
257
|
-
• .keys/public.jwk.json (JWK Public Key)
|
|
258
|
-
...
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
### Real-time Progress
|
|
262
|
-
|
|
263
|
-
All operations show real-time progress:
|
|
264
|
-
|
|
265
|
-
```
|
|
266
|
-
📦 Provisioning 10 resources...
|
|
267
|
-
|
|
268
|
-
📊 D1 Databases (0/2)
|
|
269
|
-
⏳ Creating: prod-authrim-core-db...
|
|
270
|
-
✅ prod-authrim-core-db (ID: 12345678...)
|
|
271
|
-
⏳ Creating: prod-authrim-pii-db...
|
|
272
|
-
✅ prod-authrim-pii-db (ID: 87654321...)
|
|
273
|
-
📊 D1 Databases (2/2) ✓
|
|
274
|
-
|
|
275
|
-
🗄️ KV Namespaces (0/8)
|
|
276
|
-
⏳ Creating: prod-CLIENTS_CACHE...
|
|
277
|
-
...
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Environment Management
|
|
281
|
-
|
|
282
|
-
View detailed resource information before deletion:
|
|
283
|
-
|
|
284
|
-
```
|
|
285
|
-
📋 Environment Details: prod
|
|
286
|
-
|
|
287
|
-
Workers (6):
|
|
288
|
-
• prod-ar-auth
|
|
289
|
-
Last deployed: 2024-01-15 14:30 (JST)
|
|
290
|
-
Version: abc12345
|
|
291
|
-
• prod-ar-token
|
|
292
|
-
...
|
|
293
|
-
|
|
294
|
-
D1 Databases (2):
|
|
295
|
-
• prod-authrim-core-db
|
|
296
|
-
Created: 2024-01-10 10:00 (JST)
|
|
297
|
-
Size: 128.5 MB
|
|
298
|
-
Region: WNAM
|
|
299
|
-
...
|
|
300
|
-
|
|
301
|
-
[Back] [🗑️ Delete Environment]
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
Delete environments with granular control:
|
|
305
|
-
|
|
306
|
-
```
|
|
307
|
-
⚠️ Delete Environment: prod
|
|
308
|
-
|
|
309
|
-
Select resources to delete:
|
|
310
|
-
☑ Workers (6 workers)
|
|
311
|
-
☑ D1 Databases (2 databases)
|
|
312
|
-
☑ KV Namespaces (8 namespaces)
|
|
313
|
-
☐ Queues (0 queues)
|
|
314
|
-
☐ R2 Buckets (0 buckets)
|
|
315
|
-
|
|
316
|
-
[Cancel] [🗑️ Delete Selected]
|
|
93
|
+
--show Show configuration
|
|
94
|
+
--validate Validate configuration
|
|
95
|
+
--json JSON output
|
|
317
96
|
```
|
|
318
97
|
|
|
319
98
|
## Configuration Files
|
|
320
99
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
{
|
|
327
|
-
"version": "1.0.0",
|
|
328
|
-
"environment": {
|
|
329
|
-
"prefix": "prod"
|
|
330
|
-
},
|
|
331
|
-
"urls": {
|
|
332
|
-
"api": {
|
|
333
|
-
"custom": "https://auth.example.com",
|
|
334
|
-
"auto": "https://prod-ar-router.workers.dev"
|
|
335
|
-
},
|
|
336
|
-
"loginUi": {
|
|
337
|
-
"custom": "https://login.example.com",
|
|
338
|
-
"auto": "https://prod-ar-ui.pages.dev"
|
|
339
|
-
},
|
|
340
|
-
"adminUi": {
|
|
341
|
-
"custom": null,
|
|
342
|
-
"auto": "https://prod-ar-ui.pages.dev/admin"
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
"components": {
|
|
346
|
-
"api": true,
|
|
347
|
-
"loginUi": true,
|
|
348
|
-
"adminUi": true,
|
|
349
|
-
"saml": false,
|
|
350
|
-
"async": false,
|
|
351
|
-
"vc": false,
|
|
352
|
-
"bridge": false,
|
|
353
|
-
"policy": false
|
|
354
|
-
},
|
|
355
|
-
"keys": {
|
|
356
|
-
"keyId": "kid-xxxxxxxx",
|
|
357
|
-
"secretsPath": "./.keys/"
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
```
|
|
100
|
+
| File | Description |
|
|
101
|
+
|------|-------------|
|
|
102
|
+
| `authrim-config.json` | Environment settings |
|
|
103
|
+
| `authrim-lock.json` | Provisioned resource IDs |
|
|
104
|
+
| `.keys/{env}/` | Cryptographic keys (gitignored) |
|
|
361
105
|
|
|
362
|
-
|
|
363
|
-
- `custom`: Your custom domain (optional). Set to `null` to use the auto-generated URL.
|
|
364
|
-
- `auto`: Auto-generated Cloudflare URL (workers.dev / pages.dev).
|
|
106
|
+
### Components
|
|
365
107
|
|
|
366
|
-
**Components**:
|
|
367
108
|
| Component | Description |
|
|
368
109
|
|-----------|-------------|
|
|
369
110
|
| `api` | Core OIDC API (required) |
|
|
370
111
|
| `loginUi` | Login/consent UI |
|
|
371
112
|
| `adminUi` | Admin dashboard |
|
|
372
|
-
| `saml` | SAML 2.0 IdP
|
|
373
|
-
| `async` |
|
|
113
|
+
| `saml` | SAML 2.0 IdP |
|
|
114
|
+
| `async` | Email, webhooks |
|
|
374
115
|
| `vc` | Verifiable Credentials |
|
|
375
|
-
| `bridge` |
|
|
116
|
+
| `bridge` | Social login (Google, GitHub, etc.) |
|
|
376
117
|
| `policy` | ReBAC Policy Engine |
|
|
377
118
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
### authrim-lock.json
|
|
381
|
-
|
|
382
|
-
Records provisioned resource IDs for re-deployment:
|
|
383
|
-
|
|
384
|
-
```json
|
|
385
|
-
{
|
|
386
|
-
"version": "1.0.0",
|
|
387
|
-
"env": "prod",
|
|
388
|
-
"d1": {
|
|
389
|
-
"DB": { "name": "prod-authrim-core-db", "id": "..." },
|
|
390
|
-
"PII_DB": { "name": "prod-authrim-pii-db", "id": "..." }
|
|
391
|
-
},
|
|
392
|
-
"kv": {
|
|
393
|
-
"CLIENTS_CACHE": { "name": "prod-CLIENTS_CACHE", "id": "..." },
|
|
394
|
-
"SETTINGS": { "name": "prod-SETTINGS", "id": "..." }
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### .keys/ Directory
|
|
400
|
-
|
|
401
|
-
Contains sensitive cryptographic material (gitignored):
|
|
119
|
+
## Resource Naming
|
|
402
120
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
├── private.pem # RSA private key for JWT signing
|
|
406
|
-
├── public.jwk.json # Public key in JWK format
|
|
407
|
-
├── rp_token_encryption_key.txt
|
|
408
|
-
├── admin_api_secret.txt
|
|
409
|
-
├── key_manager_secret.txt
|
|
410
|
-
└── setup_token.txt # Initial admin setup token
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
## Resource Naming Convention
|
|
414
|
-
|
|
415
|
-
Resources are named using the environment prefix:
|
|
416
|
-
|
|
417
|
-
| Resource Type | Naming Pattern | Example (prod) |
|
|
418
|
-
|--------------|----------------|----------------|
|
|
121
|
+
| Type | Pattern | Example |
|
|
122
|
+
|------|---------|---------|
|
|
419
123
|
| Workers | `{env}-ar-{component}` | `prod-ar-auth` |
|
|
420
|
-
| D1
|
|
421
|
-
| KV
|
|
422
|
-
| Queue | `{env}-audit-queue` | `prod-audit-queue` |
|
|
423
|
-
| R2 Bucket | `{env}-authrim-avatars` | `prod-authrim-avatars` |
|
|
424
|
-
|
|
425
|
-
## Deployment Order
|
|
426
|
-
|
|
427
|
-
Authrim workers are deployed in a specific order to satisfy dependencies:
|
|
428
|
-
|
|
429
|
-
```
|
|
430
|
-
Level 0: ar-lib-core # Durable Objects definitions (always first)
|
|
431
|
-
Level 1: ar-discovery # Discovery endpoint
|
|
432
|
-
Level 2: ar-auth, ar-token, ar-userinfo, ar-management # Core services (parallel)
|
|
433
|
-
Level 3: ar-async, ar-saml, ar-vc, ar-bridge, ar-policy # Optional (parallel)
|
|
434
|
-
Level 4: ar-router # Service bindings (always last)
|
|
435
|
-
Level 5: ar-ui # Cloudflare Pages (optional)
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
**Note**: Only enabled components are deployed. Service bindings in ar-router are automatically configured based on your component selection.
|
|
439
|
-
|
|
440
|
-
## Initial Admin Setup
|
|
441
|
-
|
|
442
|
-
After deployment, the CLI displays a one-time setup URL:
|
|
443
|
-
|
|
444
|
-
```
|
|
445
|
-
━━━ Initial Admin Setup ━━━
|
|
446
|
-
|
|
447
|
-
To create the initial administrator account, visit:
|
|
448
|
-
|
|
449
|
-
https://auth.example.com/setup?token=abc123...
|
|
450
|
-
|
|
451
|
-
⚠️ Important:
|
|
452
|
-
• This link expires in 1 hour
|
|
453
|
-
• Setup can only be completed once
|
|
454
|
-
• You will need to register a Passkey (biometric/security key)
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
This URL allows you to:
|
|
458
|
-
1. Register a Passkey as the system administrator
|
|
459
|
-
2. Access the Admin Dashboard
|
|
460
|
-
3. Create OAuth clients and configure settings
|
|
461
|
-
|
|
462
|
-
## CI/CD Integration
|
|
124
|
+
| D1 | `{env}-authrim-{type}-db` | `prod-authrim-core-db` |
|
|
125
|
+
| KV | `{env}-{NAME}` | `prod-CLIENTS_CACHE` |
|
|
463
126
|
|
|
464
|
-
|
|
127
|
+
## CI/CD
|
|
465
128
|
|
|
466
129
|
```bash
|
|
467
130
|
# Deploy without prompts
|
|
468
131
|
npx @authrim/setup deploy --env prod --yes
|
|
469
132
|
|
|
470
|
-
# Delete environment
|
|
133
|
+
# Delete environment
|
|
471
134
|
npx @authrim/setup delete --env staging --yes
|
|
472
135
|
|
|
473
|
-
# Get
|
|
474
|
-
npx @authrim/setup info --env prod --json
|
|
475
|
-
|
|
476
|
-
# Example: Parse JSON output
|
|
136
|
+
# Get info as JSON
|
|
477
137
|
npx @authrim/setup info --env prod --json | jq '.d1[0].databaseSize'
|
|
478
138
|
```
|
|
479
139
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
- `CLOUDFLARE_API_TOKEN` - API token for authentication
|
|
484
|
-
- `CLOUDFLARE_ACCOUNT_ID` - Target account ID
|
|
485
|
-
|
|
486
|
-
## Security Features
|
|
487
|
-
|
|
488
|
-
- **Session Token Authentication**: API endpoints require session tokens to prevent unauthorized access
|
|
489
|
-
- **Path Traversal Prevention**: Key storage directory is validated to prevent directory traversal attacks
|
|
490
|
-
- **Command Injection Prevention**: Browser launch URLs are validated to prevent shell injection
|
|
491
|
-
- **XSS Prevention**: User-controlled content is rendered safely using textContent instead of innerHTML
|
|
492
|
-
- **Error Sanitization**: Error messages are sanitized to prevent information leakage
|
|
493
|
-
- **Operation Locking**: Concurrent operations are serialized to prevent race conditions
|
|
494
|
-
- **Localhost-Only Web UI**: Web UI only binds to localhost for security
|
|
495
|
-
- **Auto Port Selection**: If default port is in use, automatically finds an available port (3456-3465)
|
|
496
|
-
- **Selective Deployment**: Only explicitly enabled components are deployed, minimizing attack surface
|
|
497
|
-
|
|
498
|
-
## Requirements
|
|
499
|
-
|
|
500
|
-
- Node.js >= 20.0.0
|
|
501
|
-
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/) installed and authenticated
|
|
502
|
-
- Cloudflare account with Workers Paid plan (for D1, KV, Durable Objects)
|
|
503
|
-
|
|
504
|
-
## Development
|
|
505
|
-
|
|
506
|
-
### Local Testing
|
|
507
|
-
|
|
508
|
-
```bash
|
|
509
|
-
# From the authrim repository root
|
|
510
|
-
cd packages/setup
|
|
511
|
-
|
|
512
|
-
# Run in development mode
|
|
513
|
-
pnpm dev
|
|
514
|
-
|
|
515
|
-
# Build and run
|
|
516
|
-
pnpm build
|
|
517
|
-
pnpm start
|
|
518
|
-
|
|
519
|
-
# Run tests
|
|
520
|
-
pnpm test
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
### Using with pnpm link
|
|
524
|
-
|
|
525
|
-
```bash
|
|
526
|
-
# In packages/setup
|
|
527
|
-
pnpm build
|
|
528
|
-
pnpm link --global
|
|
529
|
-
|
|
530
|
-
# In another directory
|
|
531
|
-
authrim-setup --help
|
|
532
|
-
```
|
|
140
|
+
Environment variables:
|
|
141
|
+
- `CLOUDFLARE_API_TOKEN` - API token
|
|
142
|
+
- `CLOUDFLARE_ACCOUNT_ID` - Account ID
|
|
533
143
|
|
|
534
144
|
## Troubleshooting
|
|
535
145
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
Install wrangler globally:
|
|
539
|
-
|
|
146
|
+
**Wrangler not installed**
|
|
540
147
|
```bash
|
|
541
148
|
npm install -g wrangler
|
|
542
149
|
wrangler login
|
|
543
150
|
```
|
|
544
151
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
Authenticate with Cloudflare:
|
|
548
|
-
|
|
549
|
-
```bash
|
|
550
|
-
wrangler login
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
### "Lock file not found"
|
|
554
|
-
|
|
555
|
-
Run the init command first to provision resources:
|
|
556
|
-
|
|
152
|
+
**Lock file not found**
|
|
557
153
|
```bash
|
|
558
154
|
npx @authrim/setup init --env prod
|
|
559
155
|
```
|
|
560
156
|
|
|
561
|
-
|
|
157
|
+
**Service Bindings error**
|
|
562
158
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
```bash
|
|
566
|
-
# Find process using the port
|
|
567
|
-
lsof -i :3456
|
|
568
|
-
|
|
569
|
-
# Kill the process
|
|
570
|
-
kill <PID>
|
|
571
|
-
|
|
572
|
-
# Or specify a different port
|
|
573
|
-
npx @authrim/setup manage --port 4000
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
### Deployment fails with "Service Bindings"
|
|
577
|
-
|
|
578
|
-
Ensure all dependent workers are deployed. The ar-router must be deployed last as it references other workers via Service Bindings.
|
|
579
|
-
|
|
580
|
-
If you see an error like `Could not resolve service binding 'OP_ASYNC'`, it means you're trying to deploy ar-router with a component enabled that hasn't been deployed yet. Either:
|
|
581
|
-
1. Deploy the missing component first
|
|
582
|
-
2. Disable the component in your configuration
|
|
159
|
+
Deploy missing components first, or disable them in configuration. The ar-router must be deployed last.
|
|
583
160
|
|
|
584
161
|
## License
|
|
585
162
|
|
|
586
|
-
Apache License 2.0
|
|
587
|
-
|
|
588
|
-
## Related
|
|
589
|
-
|
|
590
|
-
- [Authrim Documentation](https://github.com/sgrastar/authrim/tree/main/docs)
|
|
591
|
-
- [Deployment Guide](https://github.com/sgrastar/authrim/blob/main/docs/getting-started/deployment.md)
|
|
592
|
-
- [Development Guide](https://github.com/sgrastar/authrim/blob/main/docs/getting-started/development.md)
|
|
163
|
+
Apache License 2.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/core/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,I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,WAAW,EAAE,WAAW,GACvB,cAAc,CAwIhB;AA8ID;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAsIrD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CA8C/C"}
|
package/dist/core/wrangler.js
CHANGED
|
@@ -240,11 +240,14 @@ export function generateWranglerConfig(component, config, resourceIds) {
|
|
|
240
240
|
{ binding: 'OP_TOKEN', service: `${env}-ar-token` },
|
|
241
241
|
{ binding: 'OP_USERINFO', service: `${env}-ar-userinfo` },
|
|
242
242
|
{ binding: 'OP_MANAGEMENT', service: `${env}-ar-management` },
|
|
243
|
-
// Standard components (always included)
|
|
244
|
-
{ binding: 'EXTERNAL_IDP', service: `${env}-ar-bridge` },
|
|
245
|
-
{ binding: 'POLICY_SERVICE', service: `${env}-ar-policy` },
|
|
246
243
|
];
|
|
247
244
|
// Optional services (only if enabled in config)
|
|
245
|
+
if (config.components.bridge) {
|
|
246
|
+
services.push({ binding: 'EXTERNAL_IDP', service: `${env}-ar-bridge` });
|
|
247
|
+
}
|
|
248
|
+
if (config.components.policy) {
|
|
249
|
+
services.push({ binding: 'POLICY_SERVICE', service: `${env}-ar-policy` });
|
|
250
|
+
}
|
|
248
251
|
if (config.components.async) {
|
|
249
252
|
services.push({ binding: 'OP_ASYNC', service: `${env}-ar-async` });
|
|
250
253
|
}
|