@knowcode/doc-builder 1.8.2 → 1.8.3
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/CHANGELOG.md +23 -3
- package/README.md +4 -4
- package/cli.js +9 -40
- package/html/README.html +3 -3
- package/html/auth.js +1 -1
- package/html/documentation-index.html +3 -3
- package/html/guides/authentication-default-change.html +3 -3
- package/html/guides/authentication-guide.html +34 -45
- package/html/guides/claude-workflow-guide.html +3 -3
- package/html/guides/documentation-standards.html +3 -3
- package/html/guides/phosphor-icons-guide.html +3 -3
- package/html/guides/private-directory-authentication.html +35 -17
- package/html/guides/public-site-deployment.html +8 -9
- package/html/guides/search-engine-verification-guide.html +3 -3
- package/html/guides/seo-guide.html +3 -3
- package/html/guides/seo-optimization-guide.html +3 -3
- package/html/guides/troubleshooting-guide.html +3 -3
- package/html/guides/windows-setup-guide.html +3 -3
- package/html/index.html +3 -3
- package/html/js/auth.js +1 -1
- package/html/login.html +1 -1
- package/html/private/cache-control-anti-pattern.html +3 -3
- package/html/private/launch/README.html +3 -3
- package/html/private/launch/auth-cleanup-summary.html +3 -3
- package/html/private/launch/bubble-plugin-specification.html +3 -3
- package/html/private/launch/go-to-market-strategy.html +3 -3
- package/html/private/launch/launch-announcements.html +3 -3
- package/html/private/launch/vercel-deployment-auth-setup.html +25 -19
- package/html/private/next-steps-walkthrough.html +16 -43
- package/html/private/supabase-auth-implementation-completed.html +6 -6
- package/html/private/supabase-auth-implementation-plan.html +14 -31
- package/html/private/supabase-auth-integration-plan.html +32 -67
- package/html/private/supabase-auth-setup-guide.html +71 -82
- package/html/private/test-private-doc.html +3 -3
- package/html/private/user-management-tooling.html +7 -13
- package/html/sitemap.xml +44 -44
- package/html/vercel-cli-setup-guide.html +3 -3
- package/html/vercel-first-time-setup-guide.html +3 -3
- package/lib/config.js +3 -11
- package/lib/core-builder.js +1 -2
- package/lib/shared-auth-config.js +2 -10
- package/lib/supabase-auth.js +5 -11
- package/package.json +1 -1
- package/setup-database-v2.sql +53 -0
- package/user-management/README.md +9 -18
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "Knowcode Ltd",
|
|
99
99
|
"url": "https://knowcode.tech"
|
|
100
100
|
},
|
|
101
|
-
"datePublished": "2025-07-
|
|
102
|
-
"dateModified": "2025-07-
|
|
101
|
+
"datePublished": "2025-07-26T11:11:45.927Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.927Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/supabase-auth-integration-plan.html"
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
|
|
139
139
|
<div class="header-actions">
|
|
140
140
|
<div class="deployment-info">
|
|
141
|
-
<span class="deployment-date" title="Built with doc-builder v1.8.
|
|
141
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
|
|
142
142
|
</div>
|
|
143
143
|
|
|
144
144
|
|
|
@@ -287,77 +287,40 @@
|
|
|
287
287
|
style RLS fill:#f87171</div>
|
|
288
288
|
</div>
|
|
289
289
|
<h2>Database Schema</h2>
|
|
290
|
-
<h3>
|
|
291
|
-
<pre><code class="language-sql">--
|
|
292
|
-
CREATE TABLE
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
slug TEXT UNIQUE NOT NULL,
|
|
296
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
297
|
-
settings JSONB DEFAULT '{}'::jsonb
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
-- Documentation sites table
|
|
301
|
-
CREATE TABLE doc_sites (
|
|
302
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
303
|
-
org_id UUID REFERENCES organizations(id),
|
|
304
|
-
name TEXT NOT NULL,
|
|
305
|
-
domain TEXT UNIQUE NOT NULL,
|
|
306
|
-
config JSONB DEFAULT '{}'::jsonb,
|
|
290
|
+
<h3>Simplified Domain-Based Design</h3>
|
|
291
|
+
<pre><code class="language-sql">-- Single table for user access control
|
|
292
|
+
CREATE TABLE docbuilder_access (
|
|
293
|
+
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
294
|
+
domain TEXT NOT NULL,
|
|
307
295
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
308
|
-
|
|
296
|
+
PRIMARY KEY (user_id, domain)
|
|
309
297
|
);
|
|
310
298
|
|
|
311
|
-
--
|
|
312
|
-
CREATE
|
|
313
|
-
user_id UUID REFERENCES auth.users(id),
|
|
314
|
-
site_id UUID REFERENCES doc_sites(id),
|
|
315
|
-
role TEXT NOT NULL DEFAULT 'viewer',
|
|
316
|
-
granted_at TIMESTAMPTZ DEFAULT NOW(),
|
|
317
|
-
granted_by UUID REFERENCES auth.users(id),
|
|
318
|
-
expires_at TIMESTAMPTZ,
|
|
319
|
-
PRIMARY KEY (user_id, site_id)
|
|
320
|
-
);
|
|
299
|
+
-- Create index for faster lookups
|
|
300
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
321
301
|
|
|
322
|
-
-- Access logs for audit trail
|
|
302
|
+
-- Optional: Access logs for audit trail
|
|
323
303
|
CREATE TABLE access_logs (
|
|
324
304
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
325
305
|
user_id UUID REFERENCES auth.users(id),
|
|
326
|
-
|
|
306
|
+
domain TEXT NOT NULL,
|
|
327
307
|
action TEXT NOT NULL,
|
|
328
308
|
metadata JSONB DEFAULT '{}'::jsonb,
|
|
329
309
|
ip_address INET,
|
|
330
310
|
user_agent TEXT,
|
|
331
311
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
332
312
|
);
|
|
333
|
-
|
|
334
|
-
-- Invitation links
|
|
335
|
-
CREATE TABLE invitations (
|
|
336
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
337
|
-
site_id UUID REFERENCES doc_sites(id),
|
|
338
|
-
email TEXT NOT NULL,
|
|
339
|
-
role TEXT NOT NULL DEFAULT 'viewer',
|
|
340
|
-
token TEXT UNIQUE NOT NULL,
|
|
341
|
-
created_by UUID REFERENCES auth.users(id),
|
|
342
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
343
|
-
expires_at TIMESTAMPTZ NOT NULL,
|
|
344
|
-
claimed_at TIMESTAMPTZ,
|
|
345
|
-
claimed_by UUID REFERENCES auth.users(id)
|
|
346
|
-
);
|
|
347
313
|
</code></pre>
|
|
348
314
|
<h3>Row Level Security Policies</h3>
|
|
349
|
-
<pre><code class="language-sql">--
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
EXISTS (
|
|
353
|
-
SELECT 1 FROM user_site_access
|
|
354
|
-
WHERE site_id = doc_sites.id
|
|
355
|
-
AND user_id = auth.uid()
|
|
356
|
-
AND (expires_at IS NULL OR expires_at > NOW())
|
|
357
|
-
)
|
|
358
|
-
);
|
|
315
|
+
<pre><code class="language-sql">-- Enable RLS on tables
|
|
316
|
+
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
317
|
+
ALTER TABLE access_logs ENABLE ROW LEVEL SECURITY;
|
|
359
318
|
|
|
360
|
-
--
|
|
319
|
+
-- Users can only see their own access records
|
|
320
|
+
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
321
|
+
FOR SELECT USING (user_id = auth.uid());
|
|
322
|
+
|
|
323
|
+
-- Access logs are append-only by authenticated users
|
|
361
324
|
CREATE POLICY "Insert access logs" ON access_logs
|
|
362
325
|
FOR INSERT WITH CHECK (user_id = auth.uid());
|
|
363
326
|
|
|
@@ -416,18 +379,20 @@ class SupabaseAuthManager {
|
|
|
416
379
|
}
|
|
417
380
|
}
|
|
418
381
|
);
|
|
419
|
-
this.siteId = config.siteId;
|
|
420
382
|
}
|
|
421
383
|
|
|
422
384
|
async checkAccess() {
|
|
423
385
|
const { data: { user } } = await this.supabase.auth.getUser();
|
|
424
386
|
if (!user) return false;
|
|
425
387
|
|
|
388
|
+
// Use current domain for access check
|
|
389
|
+
const domain = window.location.host;
|
|
390
|
+
|
|
426
391
|
const { data, error } = await this.supabase
|
|
427
|
-
.from('
|
|
428
|
-
.select('
|
|
392
|
+
.from('docbuilder_access')
|
|
393
|
+
.select('created_at')
|
|
429
394
|
.eq('user_id', user.id)
|
|
430
|
-
.eq('
|
|
395
|
+
.eq('domain', domain)
|
|
431
396
|
.single();
|
|
432
397
|
|
|
433
398
|
if (error || !data) return false;
|
|
@@ -470,7 +435,7 @@ class SupabaseAuthManager {
|
|
|
470
435
|
|
|
471
436
|
async logAccess(action, metadata = {}) {
|
|
472
437
|
await this.supabase.from('access_logs').insert({
|
|
473
|
-
|
|
438
|
+
domain: window.location.host,
|
|
474
439
|
action,
|
|
475
440
|
metadata,
|
|
476
441
|
ip_address: await this.getClientIP(),
|
|
@@ -486,8 +451,8 @@ async function buildWithSupabaseAuth(config) {
|
|
|
486
451
|
// Inject Supabase configuration
|
|
487
452
|
const supabaseConfig = {
|
|
488
453
|
supabaseUrl: config.auth.supabaseUrl,
|
|
489
|
-
supabaseAnonKey: config.auth.supabaseAnonKey
|
|
490
|
-
|
|
454
|
+
supabaseAnonKey: config.auth.supabaseAnonKey
|
|
455
|
+
// Domain is detected automatically from window.location.host
|
|
491
456
|
};
|
|
492
457
|
|
|
493
458
|
// Create enhanced auth.js with Supabase integration
|
|
@@ -521,8 +486,8 @@ async function buildWithSupabaseAuth(config) {
|
|
|
521
486
|
auth: {
|
|
522
487
|
// Supabase configuration
|
|
523
488
|
supabaseUrl: process.env.SUPABASE_URL,
|
|
524
|
-
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
525
|
-
siteId
|
|
489
|
+
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
490
|
+
// Domain-based authentication - no siteId needed
|
|
526
491
|
|
|
527
492
|
// Optional: Custom login page styling
|
|
528
493
|
loginTheme: {
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "Knowcode Ltd",
|
|
99
99
|
"url": "https://knowcode.tech"
|
|
100
100
|
},
|
|
101
|
-
"datePublished": "2025-07-
|
|
102
|
-
"dateModified": "2025-07-
|
|
101
|
+
"datePublished": "2025-07-26T11:11:45.929Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.929Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/supabase-auth-setup-guide.html"
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
|
|
139
139
|
<div class="header-actions">
|
|
140
140
|
<div class="deployment-info">
|
|
141
|
-
<span class="deployment-date" title="Built with doc-builder v1.8.
|
|
141
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
|
|
142
142
|
</div>
|
|
143
143
|
|
|
144
144
|
|
|
@@ -249,10 +249,11 @@
|
|
|
249
249
|
<p>@knowcode/doc-builder supports enterprise-grade authentication through Supabase. This provides:</p>
|
|
250
250
|
<ul>
|
|
251
251
|
<li><strong>Secure authentication</strong> with industry-standard security practices</li>
|
|
252
|
-
<li><strong>
|
|
252
|
+
<li><strong>Domain-based access</strong> - automatic authentication based on site domain</li>
|
|
253
253
|
<li><strong>User management</strong> through CLI commands</li>
|
|
254
254
|
<li><strong>Password reset</strong> functionality built-in</li>
|
|
255
255
|
<li><strong>Enterprise features</strong> like audit logging and access control</li>
|
|
256
|
+
<li><strong>Zero configuration</strong> - built-in credentials (v1.8.2+)</li>
|
|
256
257
|
</ul>
|
|
257
258
|
<h2>Prerequisites</h2>
|
|
258
259
|
<ol>
|
|
@@ -272,41 +273,30 @@
|
|
|
272
273
|
<p>Wait for the project to be created (usually 1-2 minutes).</p>
|
|
273
274
|
<h2>Step 2: Create Database Tables</h2>
|
|
274
275
|
<p>In your Supabase dashboard, go to <strong>SQL Editor</strong> and run this SQL:</p>
|
|
275
|
-
<pre><code class="language-sql">--
|
|
276
|
-
CREATE TABLE docbuilder_sites (
|
|
277
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
278
|
-
domain TEXT UNIQUE NOT NULL,
|
|
279
|
-
name TEXT NOT NULL,
|
|
280
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
-- Table 2: User access mapping
|
|
276
|
+
<pre><code class="language-sql">-- Single table for user access control (simplified!)
|
|
284
277
|
CREATE TABLE docbuilder_access (
|
|
285
278
|
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
286
|
-
|
|
279
|
+
domain TEXT NOT NULL,
|
|
287
280
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
288
|
-
PRIMARY KEY (user_id,
|
|
281
|
+
PRIMARY KEY (user_id, domain)
|
|
289
282
|
);
|
|
290
283
|
|
|
284
|
+
-- Create index for faster lookups
|
|
285
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
286
|
+
|
|
291
287
|
-- Enable Row Level Security
|
|
292
|
-
ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
|
|
293
288
|
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
294
289
|
|
|
295
|
-
-- RLS Policy: Users can only see
|
|
296
|
-
CREATE POLICY "Users see accessible sites" ON docbuilder_sites
|
|
297
|
-
FOR SELECT USING (
|
|
298
|
-
EXISTS (
|
|
299
|
-
SELECT 1 FROM docbuilder_access
|
|
300
|
-
WHERE site_id = docbuilder_sites.id
|
|
301
|
-
AND user_id = auth.uid()
|
|
302
|
-
)
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
-- RLS Policy: Users can see their own access
|
|
290
|
+
-- RLS Policy: Users can only see their own access
|
|
306
291
|
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
307
292
|
FOR SELECT USING (user_id = auth.uid());
|
|
308
293
|
</code></pre>
|
|
309
|
-
<h2>Step 3:
|
|
294
|
+
<h2>Step 3: Configure Authentication (Automatic in v1.8.2+)</h2>
|
|
295
|
+
<p>As of version 1.8.2, Supabase credentials are automatically configured! You have two options:</p>
|
|
296
|
+
<h3>Option 1: Use Built-in Credentials (Recommended)</h3>
|
|
297
|
+
<p>Simply create a <code>docs/private/</code> directory or set <code>authentication: 'supabase'</code> in your config. The system will automatically use the shared authentication database.</p>
|
|
298
|
+
<h3>Option 2: Use Custom Supabase Project</h3>
|
|
299
|
+
<p>If you want to use your own Supabase project:</p>
|
|
310
300
|
<ol>
|
|
311
301
|
<li>In your Supabase dashboard, go to <strong>Settings</strong> → <strong>API</strong></li>
|
|
312
302
|
<li>Copy these values:<ul>
|
|
@@ -317,16 +307,20 @@ CREATE POLICY "Users see own access" ON docbuilder_access
|
|
|
317
307
|
</ol>
|
|
318
308
|
<p><i class="ph ph-warning-circle" aria-label="warning"></i> <strong>Never share your service role key</strong> - only use the anon/public key for doc-builder.</p>
|
|
319
309
|
<h2>Step 4: Initialize Authentication</h2>
|
|
320
|
-
<
|
|
321
|
-
<
|
|
310
|
+
<h3>Option 1: Automatic Setup (v1.8.2+)</h3>
|
|
311
|
+
<p>Just create a config file or use the <code>--preset</code> flag:</p>
|
|
312
|
+
<pre><code class="language-javascript">// doc-builder.config.js
|
|
313
|
+
module.exports = {
|
|
314
|
+
siteName: 'My Documentation',
|
|
315
|
+
|
|
316
|
+
features: {
|
|
317
|
+
authentication: 'supabase'
|
|
318
|
+
}
|
|
319
|
+
// No auth config needed - uses built-in credentials!
|
|
320
|
+
};
|
|
322
321
|
</code></pre>
|
|
323
|
-
<
|
|
324
|
-
<
|
|
325
|
-
<li>Your Supabase project URL</li>
|
|
326
|
-
<li>Your Supabase anonymous key </li>
|
|
327
|
-
<li>A name for your documentation site</li>
|
|
328
|
-
</ul>
|
|
329
|
-
<p>It creates a <code>doc-builder.config.js</code> file like this:</p>
|
|
322
|
+
<h3>Option 2: Custom Supabase Project</h3>
|
|
323
|
+
<p>If using your own Supabase project:</p>
|
|
330
324
|
<pre><code class="language-javascript">module.exports = {
|
|
331
325
|
siteName: 'My Documentation',
|
|
332
326
|
|
|
@@ -336,24 +330,13 @@ CREATE POLICY "Users see own access" ON docbuilder_access
|
|
|
336
330
|
|
|
337
331
|
auth: {
|
|
338
332
|
supabaseUrl: 'https://xxx.supabase.co',
|
|
339
|
-
supabaseAnonKey: 'eyJ...'
|
|
340
|
-
|
|
333
|
+
supabaseAnonKey: 'eyJ...'
|
|
334
|
+
// No siteId needed - uses domain automatically!
|
|
341
335
|
}
|
|
342
336
|
};
|
|
343
337
|
</code></pre>
|
|
344
|
-
<h2>Step 5:
|
|
345
|
-
<
|
|
346
|
-
<p>In Supabase SQL Editor, run:</p>
|
|
347
|
-
<pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name)
|
|
348
|
-
VALUES ('docs.yourcompany.com', 'Company Documentation')
|
|
349
|
-
RETURNING id;
|
|
350
|
-
</code></pre>
|
|
351
|
-
<p>Copy the returned ID and update your config file's <code>siteId</code> field.</p>
|
|
352
|
-
<h3>Option B: Using CLI (Coming Soon)</h3>
|
|
353
|
-
<pre><code class="language-bash">npx @knowcode/doc-builder auth:add-site \
|
|
354
|
-
--domain docs.yourcompany.com \
|
|
355
|
-
--name "Company Documentation"
|
|
356
|
-
</code></pre>
|
|
338
|
+
<h2>Step 5: No Site Registration Needed!</h2>
|
|
339
|
+
<p>The new domain-based system eliminates the need for site registration. The system automatically uses the current domain (e.g., <code>docs.example.com</code>) as the access key. Just grant users access to your domain in the next step.</p>
|
|
357
340
|
<h2>Step 6: Create Your First User</h2>
|
|
358
341
|
<h3>Method 1: Through Supabase Dashboard</h3>
|
|
359
342
|
<ol>
|
|
@@ -367,14 +350,23 @@ RETURNING id;
|
|
|
367
350
|
<p>Users can sign up when they visit your documentation site and try to log in.</p>
|
|
368
351
|
<h2>Step 7: Grant User Access</h2>
|
|
369
352
|
<h3>Using SQL:</h3>
|
|
370
|
-
<pre><code class="language-sql">--
|
|
371
|
-
INSERT INTO docbuilder_access (user_id,
|
|
372
|
-
VALUES (
|
|
353
|
+
<pre><code class="language-sql">-- Grant access by domain (no site ID needed!)
|
|
354
|
+
INSERT INTO docbuilder_access (user_id, domain)
|
|
355
|
+
VALUES (
|
|
356
|
+
(SELECT id FROM auth.users WHERE email = 'user@example.com'),
|
|
357
|
+
'docs.yourcompany.com'
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
-- Grant access to multiple domains
|
|
361
|
+
INSERT INTO docbuilder_access (user_id, domain) VALUES
|
|
362
|
+
((SELECT id FROM auth.users WHERE email = 'user@example.com'), 'docs.yourcompany.com'),
|
|
363
|
+
((SELECT id FROM auth.users WHERE email = 'user@example.com'), 'staging-docs.yourcompany.com'),
|
|
364
|
+
((SELECT id FROM auth.users WHERE email = 'user@example.com'), 'localhost:3000');
|
|
373
365
|
</code></pre>
|
|
374
366
|
<h3>Using CLI (Coming Soon):</h3>
|
|
375
367
|
<pre><code class="language-bash">npx @knowcode/doc-builder auth:grant \
|
|
376
368
|
--email user@example.com \
|
|
377
|
-
--
|
|
369
|
+
--domain docs.yourcompany.com
|
|
378
370
|
</code></pre>
|
|
379
371
|
<h2>Step 8: Build and Deploy</h2>
|
|
380
372
|
<pre><code class="language-bash"># Build with Supabase authentication
|
|
@@ -386,55 +378,52 @@ npx @knowcode/doc-builder deploy
|
|
|
386
378
|
<p>Your documentation site now has secure authentication! <i class="ph ph-confetti" aria-label="party"></i></p>
|
|
387
379
|
<h2>User Management</h2>
|
|
388
380
|
<h3>List Users with Access</h3>
|
|
389
|
-
<pre><code class="language-sql"
|
|
381
|
+
<pre><code class="language-sql">-- List all users for a specific domain
|
|
382
|
+
SELECT u.email, da.created_at as granted_at
|
|
390
383
|
FROM docbuilder_access da
|
|
391
384
|
JOIN auth.users u ON u.id = da.user_id
|
|
392
|
-
WHERE da.
|
|
385
|
+
WHERE da.domain = 'docs.yourcompany.com';
|
|
393
386
|
</code></pre>
|
|
394
387
|
<h3>Revoke Access</h3>
|
|
395
|
-
<pre><code class="language-sql"
|
|
388
|
+
<pre><code class="language-sql">-- Remove access for a specific domain
|
|
389
|
+
DELETE FROM docbuilder_access
|
|
396
390
|
WHERE user_id = (SELECT id FROM auth.users WHERE email = 'user@example.com')
|
|
397
|
-
AND
|
|
391
|
+
AND domain = 'docs.yourcompany.com';
|
|
398
392
|
</code></pre>
|
|
399
393
|
<h3>Reset User Password</h3>
|
|
400
394
|
<p>Users can reset their own passwords through the login page "Forgot Password" link.</p>
|
|
401
395
|
<h2>Environment Variables (Optional)</h2>
|
|
402
|
-
<p>For better security, use environment variables:</p>
|
|
396
|
+
<p>For better security with custom Supabase projects, use environment variables:</p>
|
|
403
397
|
<pre><code class="language-bash"># .env
|
|
404
398
|
SUPABASE_URL=https://xxx.supabase.co
|
|
405
399
|
SUPABASE_ANON_KEY=eyJ...
|
|
406
|
-
DOC_SITE_ID=your-site-uuid
|
|
407
400
|
</code></pre>
|
|
408
401
|
<p>Update your config:</p>
|
|
409
402
|
<pre><code class="language-javascript">module.exports = {
|
|
410
403
|
auth: {
|
|
411
404
|
supabaseUrl: process.env.SUPABASE_URL,
|
|
412
|
-
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
413
|
-
siteId
|
|
405
|
+
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
406
|
+
// No siteId needed - uses domain automatically!
|
|
414
407
|
}
|
|
415
408
|
};
|
|
416
409
|
</code></pre>
|
|
417
410
|
<h2>Multi-Site Setup</h2>
|
|
418
|
-
<p>
|
|
411
|
+
<p>The domain-based system makes multi-site setup incredibly simple:</p>
|
|
419
412
|
<ol>
|
|
420
|
-
<li>
|
|
421
|
-
</ol>
|
|
422
|
-
<pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name) VALUES
|
|
423
|
-
('docs.product1.com', 'Product 1 Docs'),
|
|
424
|
-
('internal.company.com', 'Internal Docs'),
|
|
425
|
-
('api.company.com', 'API Documentation');
|
|
426
|
-
</code></pre>
|
|
427
|
-
<ol start="2">
|
|
428
|
-
<li><p>Create separate config files for each site with different <code>siteId</code> values</p>
|
|
413
|
+
<li><p><strong>No site registration needed</strong> - Each domain is automatically recognized</p>
|
|
429
414
|
</li>
|
|
430
|
-
<li><p>Grant users access to
|
|
415
|
+
<li><p><strong>Grant users access to multiple domains</strong>:</p>
|
|
431
416
|
</li>
|
|
432
417
|
</ol>
|
|
433
|
-
<pre><code class="language-sql">-- User can access
|
|
434
|
-
INSERT INTO docbuilder_access (user_id,
|
|
435
|
-
('user
|
|
436
|
-
('user
|
|
418
|
+
<pre><code class="language-sql">-- User can access multiple documentation sites
|
|
419
|
+
INSERT INTO docbuilder_access (user_id, domain) VALUES
|
|
420
|
+
((SELECT id FROM auth.users WHERE email = 'user@example.com'), 'docs.product1.com'),
|
|
421
|
+
((SELECT id FROM auth.users WHERE email = 'user@example.com'), 'internal.company.com'),
|
|
422
|
+
((SELECT id FROM auth.users WHERE email = 'user@example.com'), 'api.company.com');
|
|
437
423
|
</code></pre>
|
|
424
|
+
<ol start="3">
|
|
425
|
+
<li><strong>Same configuration for all sites</strong> - Just deploy to different domains!</li>
|
|
426
|
+
</ol>
|
|
438
427
|
<h2>Security Features</h2>
|
|
439
428
|
<h3>What Supabase Provides</h3>
|
|
440
429
|
<ul>
|
|
@@ -449,8 +438,8 @@ INSERT INTO docbuilder_access (user_id, site_id) VALUES
|
|
|
449
438
|
<h3>Row Level Security</h3>
|
|
450
439
|
<p>All data access is protected by RLS policies:</p>
|
|
451
440
|
<ul>
|
|
452
|
-
<li>Users can only see sites they have access to</li>
|
|
453
441
|
<li>Users can only see their own access records</li>
|
|
442
|
+
<li>Domain-based access is automatically enforced</li>
|
|
454
443
|
<li>No way to access other users' data</li>
|
|
455
444
|
</ul>
|
|
456
445
|
<h2>Troubleshooting</h2>
|
|
@@ -463,8 +452,8 @@ INSERT INTO docbuilder_access (user_id, site_id) VALUES
|
|
|
463
452
|
<h3>Users Can't Access Site</h3>
|
|
464
453
|
<ul>
|
|
465
454
|
<li>Verify the user exists in <code>auth.users</code> table</li>
|
|
466
|
-
<li>Check that user has access in <code>docbuilder_access</code> table
|
|
467
|
-
<li>Confirm the
|
|
455
|
+
<li>Check that user has access in <code>docbuilder_access</code> table for the correct domain</li>
|
|
456
|
+
<li>Confirm the domain in the database matches your deployment URL</li>
|
|
468
457
|
</ul>
|
|
469
458
|
<h3>Login Page Not Working</h3>
|
|
470
459
|
<ul>
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "Knowcode Ltd",
|
|
99
99
|
"url": "https://knowcode.tech"
|
|
100
100
|
},
|
|
101
|
-
"datePublished": "2025-07-
|
|
102
|
-
"dateModified": "2025-07-
|
|
101
|
+
"datePublished": "2025-07-26T11:11:45.930Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.930Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/test-private-doc.html"
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
|
|
139
139
|
<div class="header-actions">
|
|
140
140
|
<div class="deployment-info">
|
|
141
|
-
<span class="deployment-date" title="Built with doc-builder v1.8.
|
|
141
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
|
|
142
142
|
</div>
|
|
143
143
|
|
|
144
144
|
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "Knowcode Ltd",
|
|
99
99
|
"url": "https://knowcode.tech"
|
|
100
100
|
},
|
|
101
|
-
"datePublished": "2025-07-
|
|
102
|
-
"dateModified": "2025-07-
|
|
101
|
+
"datePublished": "2025-07-26T11:11:45.932Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.932Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/user-management-tooling.html"
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
|
|
139
139
|
<div class="header-actions">
|
|
140
140
|
<div class="deployment-info">
|
|
141
|
-
<span class="deployment-date" title="Built with doc-builder v1.8.
|
|
141
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
|
|
142
142
|
</div>
|
|
143
143
|
|
|
144
144
|
|
|
@@ -273,21 +273,15 @@
|
|
|
273
273
|
</li>
|
|
274
274
|
</ol>
|
|
275
275
|
<h3>Database Schema</h3>
|
|
276
|
-
<p>The system
|
|
277
|
-
<p><strong>docbuilder_sites</strong></p>
|
|
278
|
-
<ul>
|
|
279
|
-
<li><code>id</code> (UUID) - Primary key</li>
|
|
280
|
-
<li><code>domain</code> (TEXT) - Site URL without https://</li>
|
|
281
|
-
<li><code>name</code> (TEXT) - Display name</li>
|
|
282
|
-
<li><code>created_at</code> (TIMESTAMP)</li>
|
|
283
|
-
</ul>
|
|
276
|
+
<p>The system now uses a simplified single-table design:</p>
|
|
284
277
|
<p><strong>docbuilder_access</strong></p>
|
|
285
278
|
<ul>
|
|
286
279
|
<li><code>user_id</code> (UUID) - References auth.users</li>
|
|
287
|
-
<li><code>
|
|
280
|
+
<li><code>domain</code> (TEXT) - Site domain (e.g., docs.example.com)</li>
|
|
288
281
|
<li><code>created_at</code> (TIMESTAMP)</li>
|
|
289
|
-
<li>
|
|
282
|
+
<li>Primary key on (user_id, domain)</li>
|
|
290
283
|
</ul>
|
|
284
|
+
<p>No more site registration needed! The system automatically uses the current domain.</p>
|
|
291
285
|
<h2>Implementation Details</h2>
|
|
292
286
|
<h3>User Creation Methods</h3>
|
|
293
287
|
<p>Due to Supabase CLI limitations (no direct user creation commands), the system offers three methods:</p>
|