@lifeaitools/clauth 1.30.24 → 1.30.26
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/.clauth-skill/SKILL.md +197 -166
- package/.clauth-skill/references/operator-guide.md +175 -148
- package/README.md +363 -340
- package/cli/commands/ops-install.js +211 -0
- package/cli/commands/ops.js +69 -0
- package/cli/commands/serve.js +399 -38
- package/cli/commands/watchdog.js +1 -1
- package/cli/index.js +20 -0
- package/cli/ops/coolify-adapter.js +80 -0
- package/cli/ops/deployment-adapter.js +63 -0
- package/cli/ops/job-store.js +116 -0
- package/cli/ops/operation-policy.js +51 -0
- package/cli/ops/pm2-adapter.js +128 -0
- package/cli/ops/serialized-executor.js +9 -0
- package/cli/watchdog-registry.js +30 -2
- package/cli/watchdog-registry.test.js +28 -5
- package/package.json +3 -1
|
@@ -1,148 +1,175 @@
|
|
|
1
|
-
# clauth Operator Guide
|
|
2
|
-
|
|
3
|
-
For teams deploying their own clauth instance from scratch.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## What "Operator" Means
|
|
8
|
-
|
|
9
|
-
When you clone the clauth repo and run `clauth setup`, you're connecting to an existing vault. If you want to run your **own** vault (different Supabase project, your own team), you're the operator. This guide covers that.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Step 1 — Supabase Project
|
|
14
|
-
|
|
15
|
-
You need a Supabase project. Create one at supabase.com if you don't have one.
|
|
16
|
-
|
|
17
|
-
Collect:
|
|
18
|
-
- Project URL: `https://<ref>.supabase.co`
|
|
19
|
-
- Anon key (public JWT)
|
|
20
|
-
- Service role key (admin JWT)
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Step 2 — Run Migrations
|
|
25
|
-
|
|
26
|
-
In Supabase SQL Editor (or via CLI), run both migration files in order:
|
|
27
|
-
|
|
28
|
-
1. `supabase/migrations/001_clauth_schema.sql`
|
|
29
|
-
2. `supabase/migrations/002_vault_helpers.sql`
|
|
30
|
-
|
|
31
|
-
Or via Supabase CLI:
|
|
32
|
-
```bash
|
|
33
|
-
supabase db push
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
This creates:
|
|
37
|
-
- `clauth_services` — service registry (12 services seeded)
|
|
38
|
-
- `clauth_machines` — machine fingerprint registry
|
|
39
|
-
- `clauth_audit` — all operations logged
|
|
40
|
-
- Vault helper RPCs (upsert/decrypt/delete/list)
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Step 3 — Deploy Edge Function
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
supabase functions deploy auth-vault --project-ref <your-ref>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Or deploy from the Supabase dashboard by uploading `supabase/functions/auth-vault/index.ts`.
|
|
51
|
-
|
|
52
|
-
The function automatically reads `CLAUTH_HMAC_SALT` and `CLAUTH_ADMIN_BOOTSTRAP_TOKEN` from Supabase Vault (or env vars if set).
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Step 4 — Generate and Store Secrets
|
|
57
|
-
|
|
58
|
-
Run this to generate a salt and bootstrap token:
|
|
59
|
-
```bash
|
|
60
|
-
node -e "const c=require('crypto'); console.log('SALT:', c.randomBytes(32).toString('hex')); console.log('BOOTSTRAP:', c.randomBytes(16).toString('hex'));"
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Store them in Supabase Vault via SQL Editor:
|
|
64
|
-
```sql
|
|
65
|
-
select vault.create_secret('<your-salt>', 'CLAUTH_HMAC_SALT', 'clauth HMAC salt');
|
|
66
|
-
select vault.create_secret('<your-bootstrap>', 'CLAUTH_ADMIN_BOOTSTRAP_TOKEN', 'clauth bootstrap token');
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Or via Supabase Dashboard → Vault → New Secret.
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Step 5 — Distribute to Team
|
|
74
|
-
|
|
75
|
-
Give team members:
|
|
76
|
-
1. Your Supabase project URL
|
|
77
|
-
2. Your Supabase anon key (public — safe to share)
|
|
78
|
-
3. The bootstrap token (treat as a shared secret — regenerate after everyone registers)
|
|
79
|
-
|
|
80
|
-
Each person runs:
|
|
81
|
-
```bash
|
|
82
|
-
git clone https://github.com/LIFEAI/clauth
|
|
83
|
-
cd clauth && .\install.ps1 # or bash install.sh
|
|
84
|
-
clauth setup
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Adding Team Members After Initial Setup
|
|
90
|
-
|
|
91
|
-
Once the bootstrap token has been used by the first person, you can either:
|
|
92
|
-
- Keep the same token for additional machines (it's reusable)
|
|
93
|
-
- Rotate it after everyone is registered:
|
|
94
|
-
|
|
95
|
-
```sql
|
|
96
|
-
-- Generate new one
|
|
97
|
-
select vault.create_secret('new-token-here', 'CLAUTH_ADMIN_BOOTSTRAP_TOKEN', 'rotated');
|
|
98
|
-
-- This overwrites the old one
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
##
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
select
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
1
|
+
# clauth Operator Guide
|
|
2
|
+
|
|
3
|
+
For teams deploying their own clauth instance from scratch.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What "Operator" Means
|
|
8
|
+
|
|
9
|
+
When you clone the clauth repo and run `clauth setup`, you're connecting to an existing vault. If you want to run your **own** vault (different Supabase project, your own team), you're the operator. This guide covers that.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Step 1 — Supabase Project
|
|
14
|
+
|
|
15
|
+
You need a Supabase project. Create one at supabase.com if you don't have one.
|
|
16
|
+
|
|
17
|
+
Collect:
|
|
18
|
+
- Project URL: `https://<ref>.supabase.co`
|
|
19
|
+
- Anon key (public JWT)
|
|
20
|
+
- Service role key (admin JWT)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Step 2 — Run Migrations
|
|
25
|
+
|
|
26
|
+
In Supabase SQL Editor (or via CLI), run both migration files in order:
|
|
27
|
+
|
|
28
|
+
1. `supabase/migrations/001_clauth_schema.sql`
|
|
29
|
+
2. `supabase/migrations/002_vault_helpers.sql`
|
|
30
|
+
|
|
31
|
+
Or via Supabase CLI:
|
|
32
|
+
```bash
|
|
33
|
+
supabase db push
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This creates:
|
|
37
|
+
- `clauth_services` — service registry (12 services seeded)
|
|
38
|
+
- `clauth_machines` — machine fingerprint registry
|
|
39
|
+
- `clauth_audit` — all operations logged
|
|
40
|
+
- Vault helper RPCs (upsert/decrypt/delete/list)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Step 3 — Deploy Edge Function
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
supabase functions deploy auth-vault --project-ref <your-ref>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or deploy from the Supabase dashboard by uploading `supabase/functions/auth-vault/index.ts`.
|
|
51
|
+
|
|
52
|
+
The function automatically reads `CLAUTH_HMAC_SALT` and `CLAUTH_ADMIN_BOOTSTRAP_TOKEN` from Supabase Vault (or env vars if set).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Step 4 — Generate and Store Secrets
|
|
57
|
+
|
|
58
|
+
Run this to generate a salt and bootstrap token:
|
|
59
|
+
```bash
|
|
60
|
+
node -e "const c=require('crypto'); console.log('SALT:', c.randomBytes(32).toString('hex')); console.log('BOOTSTRAP:', c.randomBytes(16).toString('hex'));"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Store them in Supabase Vault via SQL Editor:
|
|
64
|
+
```sql
|
|
65
|
+
select vault.create_secret('<your-salt>', 'CLAUTH_HMAC_SALT', 'clauth HMAC salt');
|
|
66
|
+
select vault.create_secret('<your-bootstrap>', 'CLAUTH_ADMIN_BOOTSTRAP_TOKEN', 'clauth bootstrap token');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or via Supabase Dashboard → Vault → New Secret.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Step 5 — Distribute to Team
|
|
74
|
+
|
|
75
|
+
Give team members:
|
|
76
|
+
1. Your Supabase project URL
|
|
77
|
+
2. Your Supabase anon key (public — safe to share)
|
|
78
|
+
3. The bootstrap token (treat as a shared secret — regenerate after everyone registers)
|
|
79
|
+
|
|
80
|
+
Each person runs:
|
|
81
|
+
```bash
|
|
82
|
+
git clone https://github.com/LIFEAI/clauth
|
|
83
|
+
cd clauth && .\install.ps1 # or bash install.sh
|
|
84
|
+
clauth setup
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Adding Team Members After Initial Setup
|
|
90
|
+
|
|
91
|
+
Once the bootstrap token has been used by the first person, you can either:
|
|
92
|
+
- Keep the same token for additional machines (it's reusable)
|
|
93
|
+
- Rotate it after everyone is registered:
|
|
94
|
+
|
|
95
|
+
```sql
|
|
96
|
+
-- Generate new one
|
|
97
|
+
select vault.create_secret('new-token-here', 'CLAUTH_ADMIN_BOOTSTRAP_TOKEN', 'rotated');
|
|
98
|
+
-- This overwrites the old one
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Managed PM2 Operations (LIFEAI development hosts)
|
|
104
|
+
|
|
105
|
+
Use the clauth operations controller for approved PM2 lifecycle and deployment
|
|
106
|
+
actions. Its policy JSON is the server-side allowlist; it must define only the
|
|
107
|
+
applications and operations this host is permitted to expose. Do not grant
|
|
108
|
+
host-wide PM2 actions unless there is an explicit operational requirement.
|
|
109
|
+
|
|
110
|
+
Validate before changing the process manager, then install:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Linux
|
|
114
|
+
clauth ops install --config /etc/clauth/ops-control-plane.json --dry-run
|
|
115
|
+
clauth ops install --config /etc/clauth/ops-control-plane.json
|
|
116
|
+
|
|
117
|
+
# Windows PowerShell
|
|
118
|
+
clauth ops install --config C:\ProgramData\clauth\ops-control-plane.json --dry-run
|
|
119
|
+
clauth ops install --config C:\ProgramData\clauth\ops-control-plane.json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The installer owns only the `clauth-deployment` process. It checks the local
|
|
123
|
+
health endpoint and verifies that the catalog remains bearer-gated. Keep the
|
|
124
|
+
controller bearer in clauth, not in a shell history, policy file, or PM2
|
|
125
|
+
environment dump. Use `clauth ops catalog` and scoped operations commands rather
|
|
126
|
+
than invoking PM2 directly.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Viewing the Audit Log
|
|
131
|
+
|
|
132
|
+
```sql
|
|
133
|
+
select machine_hash, service_name, action, result, detail, created_at
|
|
134
|
+
from clauth_audit
|
|
135
|
+
order by created_at desc
|
|
136
|
+
limit 50;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Disabling a Machine
|
|
142
|
+
|
|
143
|
+
If a machine is lost or stolen:
|
|
144
|
+
```sql
|
|
145
|
+
update clauth_machines set enabled = false where label = 'Dave-Desktop-Win11';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
That machine's HMAC tokens will be rejected immediately.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Rotating the HMAC Salt
|
|
153
|
+
|
|
154
|
+
If the salt is compromised, rotate it:
|
|
155
|
+
```sql
|
|
156
|
+
-- Find the existing secret ID
|
|
157
|
+
select id, name from vault.secrets where name = 'CLAUTH_HMAC_SALT';
|
|
158
|
+
|
|
159
|
+
-- Update it
|
|
160
|
+
select vault.update_secret('<id>', 'new-salt-here');
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Warning:** After rotating the salt, ALL existing machines will fail HMAC validation. Every machine needs to re-run `clauth setup` with the new bootstrap token.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Project Identifiers (LIFEAI canonical)
|
|
168
|
+
|
|
169
|
+
| Item | Value |
|
|
170
|
+
|------|-------|
|
|
171
|
+
| Supabase project | `uvojezuorjgqzmhhgluu` |
|
|
172
|
+
| Supabase URL | `https://uvojezuorjgqzmhhgluu.supabase.co` |
|
|
173
|
+
| Edge Function | `auth-vault` (deployed, ACTIVE) |
|
|
174
|
+
| GitHub org | LIFEAI |
|
|
175
|
+
| Repo | https://github.com/LIFEAI/clauth |
|