@knowcode/doc-builder 1.8.0 → 1.8.2
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/.claude/settings.local.json +4 -1
- package/CHANGELOG.md +24 -0
- package/assets/js/main.js +10 -6
- package/html/README.html +43 -5
- package/html/auth.js +61 -12
- package/html/documentation-index.html +43 -5
- package/html/guides/authentication-default-change.html +43 -5
- package/html/guides/authentication-guide.html +50 -9
- package/html/guides/claude-workflow-guide.html +43 -5
- package/html/guides/documentation-standards.html +43 -5
- package/html/guides/phosphor-icons-guide.html +43 -5
- package/html/guides/private-directory-authentication.html +246 -119
- package/html/guides/public-site-deployment.html +43 -5
- package/html/guides/search-engine-verification-guide.html +43 -5
- package/html/guides/seo-guide.html +43 -5
- package/html/guides/seo-optimization-guide.html +43 -5
- package/html/guides/troubleshooting-guide.html +43 -5
- package/html/guides/windows-setup-guide.html +43 -5
- package/html/index.html +43 -5
- package/html/js/auth.js +118 -39
- package/html/js/main.js +10 -6
- package/html/login.html +3 -3
- package/html/logout.html +2 -2
- package/html/private/cache-control-anti-pattern.html +67 -5
- package/html/private/launch/README.html +67 -5
- package/html/private/launch/auth-cleanup-summary.html +67 -5
- package/html/private/launch/bubble-plugin-specification.html +67 -5
- package/html/private/launch/go-to-market-strategy.html +67 -5
- package/html/private/launch/launch-announcements.html +67 -5
- package/html/private/launch/vercel-deployment-auth-setup.html +67 -5
- package/html/private/next-steps-walkthrough.html +67 -5
- package/html/private/supabase-auth-implementation-completed.html +67 -5
- package/html/private/supabase-auth-implementation-plan.html +67 -5
- package/html/private/supabase-auth-integration-plan.html +67 -5
- package/html/private/supabase-auth-setup-guide.html +67 -5
- package/html/private/test-private-doc.html +67 -5
- package/html/private/user-management-tooling.html +587 -0
- package/html/robots.txt +4 -0
- package/html/sitemap.xml +49 -43
- package/html/vercel-cli-setup-guide.html +43 -5
- package/html/vercel-first-time-setup-guide.html +43 -5
- package/lib/config.js +20 -27
- package/lib/core-builder.js +9 -1
- package/lib/shared-auth-config.js +21 -0
- package/lib/supabase-auth.js +20 -14
- package/package.json +1 -1
- package/user-management/README.md +280 -51
- package/user-management/add-users.sh +661 -262
- package/user-management/create-user.js +65 -0
package/lib/supabase-auth.js
CHANGED
|
@@ -320,21 +320,27 @@ class SupabaseAuth {
|
|
|
320
320
|
static validateConfig(config) {
|
|
321
321
|
const errors = [];
|
|
322
322
|
|
|
323
|
-
if
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (!config.auth.supabaseAnonKey) {
|
|
328
|
-
errors.push('auth.supabaseAnonKey is required');
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (!config.auth.siteId) {
|
|
332
|
-
errors.push('auth.siteId is required');
|
|
333
|
-
}
|
|
323
|
+
// Only validate if at least one credential is provided
|
|
324
|
+
// This allows the auth UI to show even without full configuration
|
|
325
|
+
const hasAnyCredential = config.auth.supabaseUrl || config.auth.supabaseAnonKey || config.auth.siteId;
|
|
334
326
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
327
|
+
if (hasAnyCredential) {
|
|
328
|
+
if (!config.auth.supabaseUrl) {
|
|
329
|
+
errors.push('auth.supabaseUrl is required');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!config.auth.supabaseAnonKey) {
|
|
333
|
+
errors.push('auth.supabaseAnonKey is required');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (!config.auth.siteId) {
|
|
337
|
+
errors.push('auth.siteId is required');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Validate URL format
|
|
341
|
+
if (config.auth.supabaseUrl && !config.auth.supabaseUrl.match(/^https:\/\/\w+\.supabase\.co$/)) {
|
|
342
|
+
errors.push('auth.supabaseUrl must be a valid Supabase URL (https://xxx.supabase.co)');
|
|
343
|
+
}
|
|
338
344
|
}
|
|
339
345
|
|
|
340
346
|
return errors;
|
package/package.json
CHANGED
|
@@ -1,81 +1,310 @@
|
|
|
1
|
-
# User Management
|
|
1
|
+
# Doc-Builder User Management System
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive user management solution for Supabase-authenticated documentation sites using the Supabase CLI.
|
|
4
4
|
|
|
5
|
-
## Quick Start
|
|
5
|
+
## 🚀 Quick Start
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
#
|
|
9
|
-
./add-users.sh
|
|
8
|
+
# Initial setup
|
|
9
|
+
./add-users.sh setup
|
|
10
|
+
|
|
11
|
+
# Add a user
|
|
12
|
+
./add-users.sh add wru-bid-analysis.vercel.app user@email.com
|
|
13
|
+
|
|
14
|
+
# List all users for a site
|
|
15
|
+
./add-users.sh list wru-bid-analysis.vercel.app
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 📋 Prerequisites
|
|
19
|
+
|
|
20
|
+
1. **Install Supabase CLI**:
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g supabase
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. **Login to Supabase**:
|
|
26
|
+
```bash
|
|
27
|
+
supabase login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
3. **Link your project** (or use the setup command):
|
|
31
|
+
```bash
|
|
32
|
+
./add-users.sh setup
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 🔧 Installation
|
|
36
|
+
|
|
37
|
+
The user management system is self-contained in this folder:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
user-management/
|
|
41
|
+
├── add-users.sh # Main script
|
|
42
|
+
├── users.txt # Example bulk user file
|
|
43
|
+
├── README.md # This documentation
|
|
44
|
+
└── .env.example # Environment variables template
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 📖 Commands
|
|
48
|
+
|
|
49
|
+
### Setup
|
|
50
|
+
|
|
51
|
+
Initialize and link your Supabase project:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
./add-users.sh setup
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This will:
|
|
58
|
+
- Check if Supabase CLI is installed
|
|
59
|
+
- Verify you're logged in
|
|
60
|
+
- Link your project (prompts for project ID)
|
|
61
|
+
- Test the database connection
|
|
62
|
+
- Save configuration for future use
|
|
63
|
+
|
|
64
|
+
### Add User
|
|
65
|
+
|
|
66
|
+
Create a user and grant them access to a specific site:
|
|
10
67
|
|
|
11
|
-
|
|
12
|
-
./add-users.sh add
|
|
68
|
+
```bash
|
|
69
|
+
./add-users.sh add <site-url> <email>
|
|
70
|
+
|
|
71
|
+
# Example
|
|
72
|
+
./add-users.sh add docs.example.com john@company.com
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This will:
|
|
76
|
+
- Create the user account if it doesn't exist
|
|
77
|
+
- Send them a password reset email
|
|
78
|
+
- Grant access to the specified site
|
|
79
|
+
- Show confirmation of access granted
|
|
13
80
|
|
|
14
|
-
|
|
15
|
-
./add-users.sh bulk wru-bid-analysis.vercel.app users.txt
|
|
81
|
+
### Bulk Add Users
|
|
16
82
|
|
|
17
|
-
|
|
83
|
+
Add multiple users from a file:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
./add-users.sh bulk <site-url> <file>
|
|
87
|
+
|
|
88
|
+
# Example
|
|
89
|
+
./add-users.sh bulk docs.example.com users.txt
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
File format (users.txt):
|
|
93
|
+
```
|
|
94
|
+
# Comments start with #
|
|
95
|
+
# One email per line
|
|
96
|
+
john@example.com
|
|
97
|
+
jane@example.com
|
|
98
|
+
admin@company.com
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### List Users
|
|
102
|
+
|
|
103
|
+
Show all users with access to a site:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
./add-users.sh list <site-url>
|
|
107
|
+
|
|
108
|
+
# Example
|
|
18
109
|
./add-users.sh list wru-bid-analysis.vercel.app
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Output includes:
|
|
113
|
+
- Email address
|
|
114
|
+
- When user was created
|
|
115
|
+
- When access was granted
|
|
116
|
+
- Last login time
|
|
117
|
+
- Total user count
|
|
118
|
+
|
|
119
|
+
### Check User
|
|
19
120
|
|
|
20
|
-
|
|
21
|
-
./add-users.sh check wru-bid-analysis.vercel.app john@example.com
|
|
121
|
+
Check a user's status across all sites:
|
|
22
122
|
|
|
23
|
-
|
|
24
|
-
./add-users.sh
|
|
123
|
+
```bash
|
|
124
|
+
./add-users.sh check <email>
|
|
125
|
+
|
|
126
|
+
# Example
|
|
127
|
+
./add-users.sh check user@example.com
|
|
25
128
|
```
|
|
26
129
|
|
|
27
|
-
|
|
130
|
+
Shows:
|
|
131
|
+
- If user exists
|
|
132
|
+
- All sites they have access to
|
|
133
|
+
- Last login information
|
|
134
|
+
|
|
135
|
+
### Remove Access
|
|
28
136
|
|
|
29
|
-
|
|
30
|
-
2. Copy the generated SQL and run it in the Supabase SQL Editor
|
|
31
|
-
3. For new users, you'll need to create them in Supabase Dashboard first
|
|
137
|
+
Remove a user's access to a specific site:
|
|
32
138
|
|
|
33
|
-
|
|
139
|
+
```bash
|
|
140
|
+
./add-users.sh remove <site-url> <email>
|
|
34
141
|
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
142
|
+
# Example
|
|
143
|
+
./add-users.sh remove docs.example.com user@example.com
|
|
144
|
+
```
|
|
38
145
|
|
|
39
|
-
|
|
146
|
+
Note: This only removes access, it doesn't delete the user account.
|
|
40
147
|
|
|
41
|
-
|
|
42
|
-
- Supabase User Management: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
|
|
148
|
+
### List Sites
|
|
43
149
|
|
|
44
|
-
|
|
150
|
+
Show all documentation sites in the system:
|
|
45
151
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
```
|
|
152
|
+
```bash
|
|
153
|
+
./add-users.sh sites
|
|
154
|
+
```
|
|
50
155
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
156
|
+
Shows:
|
|
157
|
+
- Site ID
|
|
158
|
+
- Domain
|
|
159
|
+
- Site name
|
|
160
|
+
- Creation date
|
|
161
|
+
- Number of users
|
|
56
162
|
|
|
57
|
-
|
|
163
|
+
### Delete User
|
|
164
|
+
|
|
165
|
+
Permanently delete a user (removes from ALL sites):
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
./add-users.sh delete-user <email>
|
|
169
|
+
|
|
170
|
+
# Example
|
|
171
|
+
./add-users.sh delete-user user@example.com
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
⚠️ **Warning**: This is permanent and cannot be undone!
|
|
175
|
+
|
|
176
|
+
## ⚠️ Important Limitations
|
|
177
|
+
|
|
178
|
+
1. **User Creation**: The Supabase CLI doesn't support direct user creation. The script offers two workarounds:
|
|
179
|
+
- **Manual Creation** (Recommended): Opens the Supabase dashboard where you can invite users
|
|
180
|
+
- **Programmatic Creation** (Advanced): If you provide your service_role key, the script can create users using the Admin API
|
|
181
|
+
|
|
182
|
+
2. **SQL Execution**: Older versions of Supabase CLI (< 2.7) don't support `db execute`. The script will:
|
|
183
|
+
- Try to use `psql` if you have `DATABASE_URL` set
|
|
184
|
+
- Fall back to showing SQL for manual execution in the dashboard
|
|
185
|
+
- Consider updating: `npm update -g supabase`
|
|
186
|
+
|
|
187
|
+
## 🔐 Security Notes
|
|
188
|
+
|
|
189
|
+
1. **User Creation**: When users are created, they receive a password reset email to set their own password
|
|
190
|
+
2. **Access Control**: Users only see sites they have explicit access to
|
|
191
|
+
3. **Audit Trail**: All access grants are timestamped in the database
|
|
192
|
+
4. **No Passwords**: The system never handles or stores passwords directly
|
|
193
|
+
5. **Service Role Key**: If using programmatic creation, your service_role key is never stored
|
|
194
|
+
|
|
195
|
+
## 🛠️ Troubleshooting
|
|
196
|
+
|
|
197
|
+
### "Supabase CLI not found"
|
|
198
|
+
|
|
199
|
+
Install the Supabase CLI:
|
|
200
|
+
```bash
|
|
201
|
+
npm install -g supabase
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### "Not logged in to Supabase"
|
|
205
|
+
|
|
206
|
+
Login to your Supabase account:
|
|
207
|
+
```bash
|
|
208
|
+
supabase login
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### "Project not linked"
|
|
212
|
+
|
|
213
|
+
Run the setup command:
|
|
214
|
+
```bash
|
|
215
|
+
./add-users.sh setup
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### "Site not found"
|
|
219
|
+
|
|
220
|
+
Make sure the site exists in the `docbuilder_sites` table. You can check with:
|
|
221
|
+
```bash
|
|
222
|
+
./add-users.sh sites
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### "User already exists"
|
|
226
|
+
|
|
227
|
+
This is fine - the script will continue and grant access to the site.
|
|
228
|
+
|
|
229
|
+
### "Access already granted"
|
|
230
|
+
|
|
231
|
+
The user already has access to this site. No action needed.
|
|
232
|
+
|
|
233
|
+
## 📊 Database Schema
|
|
234
|
+
|
|
235
|
+
The system uses two main tables:
|
|
236
|
+
|
|
237
|
+
### docbuilder_sites
|
|
238
|
+
- `id` (UUID) - Primary key
|
|
239
|
+
- `domain` (TEXT) - Site URL without https://
|
|
240
|
+
- `name` (TEXT) - Display name
|
|
241
|
+
- `created_at` (TIMESTAMP)
|
|
242
|
+
|
|
243
|
+
### docbuilder_access
|
|
244
|
+
- `user_id` (UUID) - References auth.users
|
|
245
|
+
- `site_id` (UUID) - References docbuilder_sites
|
|
246
|
+
- `created_at` (TIMESTAMP)
|
|
247
|
+
|
|
248
|
+
## 🎯 Common Workflows
|
|
249
|
+
|
|
250
|
+
### Setting up a new documentation site
|
|
251
|
+
|
|
252
|
+
1. Add the site to the database (manually or via SQL)
|
|
253
|
+
2. Add users who should have access:
|
|
58
254
|
```bash
|
|
59
|
-
./add-users.sh add
|
|
255
|
+
./add-users.sh add my-docs.vercel.app user1@example.com
|
|
256
|
+
./add-users.sh add my-docs.vercel.app user2@example.com
|
|
60
257
|
```
|
|
61
|
-
Copy and run the generated SQL
|
|
62
258
|
|
|
63
|
-
|
|
259
|
+
### Onboarding multiple team members
|
|
260
|
+
|
|
261
|
+
1. Create a users.txt file with all email addresses
|
|
262
|
+
2. Run bulk add:
|
|
64
263
|
```bash
|
|
65
|
-
./add-users.sh
|
|
264
|
+
./add-users.sh bulk my-docs.vercel.app users.txt
|
|
66
265
|
```
|
|
67
266
|
|
|
68
|
-
|
|
267
|
+
### Auditing access
|
|
268
|
+
|
|
269
|
+
Check who has access to a site:
|
|
270
|
+
```bash
|
|
271
|
+
./add-users.sh list my-docs.vercel.app
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Check what sites a user can access:
|
|
275
|
+
```bash
|
|
276
|
+
./add-users.sh check user@example.com
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Offboarding a user
|
|
280
|
+
|
|
281
|
+
Remove from specific site:
|
|
282
|
+
```bash
|
|
283
|
+
./add-users.sh remove my-docs.vercel.app former-employee@example.com
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Or remove completely:
|
|
287
|
+
```bash
|
|
288
|
+
./add-users.sh delete-user former-employee@example.com
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## 🔧 Configuration
|
|
292
|
+
|
|
293
|
+
The script stores its configuration in `.supabase-config` after setup. You can also set environment variables:
|
|
294
|
+
|
|
295
|
+
- `SUPABASE_PROJECT_ID` - Your project ID
|
|
296
|
+
- `SUPABASE_DB_URL` - Database connection URL (optional)
|
|
297
|
+
|
|
298
|
+
## 📝 Notes
|
|
69
299
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
300
|
+
- Site URLs should be entered without `https://` prefix
|
|
301
|
+
- Users receive password reset emails when created
|
|
302
|
+
- The script uses the Supabase CLI for all operations
|
|
303
|
+
- All actions are logged with colored output for clarity
|
|
304
|
+
- Destructive operations require confirmation
|
|
75
305
|
|
|
76
|
-
##
|
|
306
|
+
## 🆘 Support
|
|
77
307
|
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
- This gives you a chance to review before making changes
|
|
308
|
+
- GitHub: https://github.com/wapdat/doc-builder
|
|
309
|
+
- Documentation: https://doc-builder-delta.vercel.app
|
|
310
|
+
- Supabase Dashboard: https://supabase.com/dashboard
|