@knowcode/doc-builder 1.8.1 → 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 +37 -0
- package/README.md +4 -4
- package/cli.js +9 -40
- package/html/README.html +3 -3
- package/html/auth.js +2 -2
- package/html/documentation-index.html +3 -3
- package/html/guides/authentication-default-change.html +3 -3
- package/html/guides/authentication-guide.html +41 -49
- 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 +51 -26
- 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 +2 -2
- package/html/login.html +2 -2
- package/html/private/cache-control-anti-pattern.html +5 -4
- package/html/private/launch/README.html +5 -4
- package/html/private/launch/auth-cleanup-summary.html +5 -4
- package/html/private/launch/bubble-plugin-specification.html +5 -4
- package/html/private/launch/go-to-market-strategy.html +5 -4
- package/html/private/launch/launch-announcements.html +5 -4
- package/html/private/launch/vercel-deployment-auth-setup.html +27 -20
- package/html/private/next-steps-walkthrough.html +18 -44
- package/html/private/supabase-auth-implementation-completed.html +8 -7
- package/html/private/supabase-auth-implementation-plan.html +16 -32
- package/html/private/supabase-auth-integration-plan.html +34 -68
- package/html/private/supabase-auth-setup-guide.html +73 -83
- package/html/private/test-private-doc.html +5 -4
- package/html/private/user-management-tooling.html +581 -0
- package/html/sitemap.xml +49 -43
- package/html/vercel-cli-setup-guide.html +3 -3
- package/html/vercel-first-time-setup-guide.html +3 -3
- package/lib/config.js +6 -15
- package/lib/core-builder.js +3 -4
- package/lib/shared-auth-config.js +13 -0
- package/lib/supabase-auth.js +5 -11
- package/package.json +1 -1
- package/setup-database-v2.sql +53 -0
- package/user-management/README.md +16 -21
- package/user-management/add-users.sh +37 -11
|
@@ -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.920Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.920Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/next-steps-walkthrough.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
|
|
|
@@ -223,7 +223,8 @@
|
|
|
223
223
|
<a href="/private/supabase-auth-implementation-plan.html" class="nav-item" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
|
|
224
224
|
<a href="/private/supabase-auth-integration-plan.html" class="nav-item" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
|
|
225
225
|
<a href="/private/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
|
|
226
|
-
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a
|
|
226
|
+
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
|
|
227
|
+
<a href="/private/user-management-tooling.html" class="nav-item" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
|
|
227
228
|
<div class="nav-section" data-level="2">
|
|
228
229
|
<a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
|
|
229
230
|
<i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
|
|
@@ -267,37 +268,21 @@ npm install
|
|
|
267
268
|
<li><strong>Go to SQL Editor</strong> in Supabase dashboard</li>
|
|
268
269
|
<li><strong>Run this SQL</strong> to create the required tables:</li>
|
|
269
270
|
</ol>
|
|
270
|
-
<pre><code class="language-sql">--
|
|
271
|
-
CREATE TABLE docbuilder_sites (
|
|
272
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
273
|
-
domain TEXT UNIQUE NOT NULL,
|
|
274
|
-
name TEXT NOT NULL,
|
|
275
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
-- Table 2: User access mapping
|
|
271
|
+
<pre><code class="language-sql">-- Single table for user access control (simplified!)
|
|
279
272
|
CREATE TABLE docbuilder_access (
|
|
280
273
|
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
281
|
-
|
|
274
|
+
domain TEXT NOT NULL,
|
|
282
275
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
283
|
-
PRIMARY KEY (user_id,
|
|
276
|
+
PRIMARY KEY (user_id, domain)
|
|
284
277
|
);
|
|
285
278
|
|
|
279
|
+
-- Create index for faster lookups
|
|
280
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
281
|
+
|
|
286
282
|
-- Enable Row Level Security
|
|
287
|
-
ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
|
|
288
283
|
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
289
284
|
|
|
290
|
-
-- RLS Policy: Users can only see
|
|
291
|
-
CREATE POLICY "Users see accessible sites" ON docbuilder_sites
|
|
292
|
-
FOR SELECT USING (
|
|
293
|
-
EXISTS (
|
|
294
|
-
SELECT 1 FROM docbuilder_access
|
|
295
|
-
WHERE site_id = docbuilder_sites.id
|
|
296
|
-
AND user_id = auth.uid()
|
|
297
|
-
)
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
-- RLS Policy: Users can see their own access
|
|
285
|
+
-- RLS Policy: Users can only see their own access
|
|
301
286
|
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
302
287
|
FOR SELECT USING (user_id = auth.uid());
|
|
303
288
|
</code></pre>
|
|
@@ -324,9 +309,8 @@ module.exports = {
|
|
|
324
309
|
},
|
|
325
310
|
|
|
326
311
|
auth: {
|
|
327
|
-
supabaseUrl: 'YOUR_SUPABASE_URL_HERE',
|
|
328
|
-
supabaseAnonKey: 'YOUR_ANON_KEY_HERE'
|
|
329
|
-
siteId: '' // Will be filled in next step
|
|
312
|
+
supabaseUrl: 'YOUR_SUPABASE_URL_HERE', // Optional - has defaults
|
|
313
|
+
supabaseAnonKey: 'YOUR_ANON_KEY_HERE' // Optional - has defaults
|
|
330
314
|
}
|
|
331
315
|
};
|
|
332
316
|
EOF
|
|
@@ -342,18 +326,8 @@ EOF
|
|
|
342
326
|
</code></pre>
|
|
343
327
|
<p>This should prompt you for Supabase credentials and create/update the config.</p>
|
|
344
328
|
<ol start="2">
|
|
345
|
-
<li><strong>
|
|
329
|
+
<li><strong>No site registration needed!</strong> The new system uses domains automatically.</li>
|
|
346
330
|
</ol>
|
|
347
|
-
<pre><code class="language-sql">-- Run in Supabase SQL Editor
|
|
348
|
-
INSERT INTO docbuilder_sites (domain, name)
|
|
349
|
-
VALUES ('localhost:3000', 'Test Site')
|
|
350
|
-
RETURNING id;
|
|
351
|
-
</code></pre>
|
|
352
|
-
<ol start="3">
|
|
353
|
-
<li><strong>Copy the returned site ID</strong> and update your <code>test-config.js</code>:</li>
|
|
354
|
-
</ol>
|
|
355
|
-
<pre><code class="language-javascript">siteId: 'the-uuid-returned-from-above'
|
|
356
|
-
</code></pre>
|
|
357
331
|
<h3>Step 7: Create Test Documentation</h3>
|
|
358
332
|
<ol>
|
|
359
333
|
<li><strong>Create test docs folder</strong>:</li>
|
|
@@ -421,9 +395,9 @@ If you can see this page, authentication is working!" > test-docs/README
|
|
|
421
395
|
</ol>
|
|
422
396
|
<h3>Step 11: Grant Access to Test User</h3>
|
|
423
397
|
<pre><code class="language-sql">-- Run in Supabase SQL Editor
|
|
424
|
-
-- Replace with actual user ID
|
|
425
|
-
INSERT INTO docbuilder_access (user_id,
|
|
426
|
-
VALUES ('USER_ID_FROM_STEP_10', '
|
|
398
|
+
-- Replace with actual user ID from step 10
|
|
399
|
+
INSERT INTO docbuilder_access (user_id, domain)
|
|
400
|
+
VALUES ('USER_ID_FROM_STEP_10', 'localhost:3001');
|
|
427
401
|
</code></pre>
|
|
428
402
|
<h3>Step 12: Test Complete Flow</h3>
|
|
429
403
|
<ol>
|
|
@@ -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.921Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.921Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/supabase-auth-implementation-completed.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
|
|
|
@@ -223,7 +223,8 @@
|
|
|
223
223
|
<a href="/private/supabase-auth-implementation-plan.html" class="nav-item" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
|
|
224
224
|
<a href="/private/supabase-auth-integration-plan.html" class="nav-item" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
|
|
225
225
|
<a href="/private/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
|
|
226
|
-
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a
|
|
226
|
+
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
|
|
227
|
+
<a href="/private/user-management-tooling.html" class="nav-item" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
|
|
227
228
|
<div class="nav-section" data-level="2">
|
|
228
229
|
<a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
|
|
229
230
|
<i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
|
|
@@ -293,9 +294,9 @@
|
|
|
293
294
|
authentication: 'supabase' // Must explicitly enable
|
|
294
295
|
},
|
|
295
296
|
auth: {
|
|
296
|
-
supabaseUrl: 'https://xxx.supabase.co',
|
|
297
|
-
supabaseAnonKey: 'your-anon-key'
|
|
298
|
-
siteId
|
|
297
|
+
supabaseUrl: 'https://xxx.supabase.co', // Optional - has defaults
|
|
298
|
+
supabaseAnonKey: 'your-anon-key' // Optional - has defaults
|
|
299
|
+
// No siteId needed - uses domain automatically!
|
|
299
300
|
}
|
|
300
301
|
};
|
|
301
302
|
</code></pre>
|
|
@@ -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.924Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.924Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/private/supabase-auth-implementation-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
|
|
|
@@ -223,7 +223,8 @@
|
|
|
223
223
|
<a href="/private/supabase-auth-implementation-plan.html" class="nav-item active" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
|
|
224
224
|
<a href="/private/supabase-auth-integration-plan.html" class="nav-item" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
|
|
225
225
|
<a href="/private/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
|
|
226
|
-
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a
|
|
226
|
+
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
|
|
227
|
+
<a href="/private/user-management-tooling.html" class="nav-item" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
|
|
227
228
|
<div class="nav-section" data-level="2">
|
|
228
229
|
<a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
|
|
229
230
|
<i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
|
|
@@ -277,43 +278,26 @@
|
|
|
277
278
|
|
|
278
279
|
subgraph "Supabase"
|
|
279
280
|
AuthUsers[auth.users]
|
|
280
|
-
|
|
281
|
-
DocAccess[docbuilder_access]
|
|
281
|
+
DocAccess[docbuilder_access with domain]
|
|
282
282
|
AuthUsers -.-> DocAccess
|
|
283
|
-
DocAccess -.-> DocSites
|
|
284
283
|
end</div>
|
|
285
284
|
</div>
|
|
286
285
|
<h2>Database Schema</h2>
|
|
287
|
-
<pre><code class="language-sql">--
|
|
288
|
-
CREATE TABLE docbuilder_sites (
|
|
289
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
290
|
-
domain TEXT UNIQUE NOT NULL,
|
|
291
|
-
name TEXT NOT NULL,
|
|
292
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
-- Table 2: User access mapping
|
|
286
|
+
<pre><code class="language-sql">-- Single table for user access control (simplified!)
|
|
296
287
|
CREATE TABLE docbuilder_access (
|
|
297
288
|
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
298
|
-
|
|
289
|
+
domain TEXT NOT NULL,
|
|
299
290
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
300
|
-
PRIMARY KEY (user_id,
|
|
291
|
+
PRIMARY KEY (user_id, domain)
|
|
301
292
|
);
|
|
302
293
|
|
|
294
|
+
-- Create index for faster lookups
|
|
295
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
296
|
+
|
|
303
297
|
-- Enable Row Level Security
|
|
304
|
-
ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
|
|
305
298
|
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
306
299
|
|
|
307
|
-
-- RLS
|
|
308
|
-
CREATE POLICY "Users see accessible sites" ON docbuilder_sites
|
|
309
|
-
FOR SELECT USING (
|
|
310
|
-
EXISTS (
|
|
311
|
-
SELECT 1 FROM docbuilder_access
|
|
312
|
-
WHERE site_id = docbuilder_sites.id
|
|
313
|
-
AND user_id = auth.uid()
|
|
314
|
-
)
|
|
315
|
-
);
|
|
316
|
-
|
|
300
|
+
-- RLS Policy: Users can only see their own access
|
|
317
301
|
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
318
302
|
FOR SELECT USING (user_id = auth.uid());
|
|
319
303
|
</code></pre>
|
|
@@ -328,10 +312,10 @@ CREATE POLICY "Users see own access" ON docbuilder_access
|
|
|
328
312
|
<p><strong>File</strong>: <code>lib/config.js</code></p>
|
|
329
313
|
<pre><code class="language-javascript">// Updated auth configuration - REMOVE basic auth fields
|
|
330
314
|
auth: {
|
|
331
|
-
// Only Supabase fields remain
|
|
315
|
+
// Only Supabase fields remain (domain-based, no siteId!)
|
|
332
316
|
supabaseUrl: '',
|
|
333
|
-
supabaseAnonKey: ''
|
|
334
|
-
|
|
317
|
+
supabaseAnonKey: ''
|
|
318
|
+
// Domain is detected automatically from window.location.host
|
|
335
319
|
}
|
|
336
320
|
</code></pre>
|
|
337
321
|
<h4>1.2 Create Supabase Auth Module</h4>
|
|
@@ -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
|
|
|
@@ -223,7 +223,8 @@
|
|
|
223
223
|
<a href="/private/supabase-auth-implementation-plan.html" class="nav-item" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
|
|
224
224
|
<a href="/private/supabase-auth-integration-plan.html" class="nav-item active" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
|
|
225
225
|
<a href="/private/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
|
|
226
|
-
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a
|
|
226
|
+
<a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
|
|
227
|
+
<a href="/private/user-management-tooling.html" class="nav-item" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
|
|
227
228
|
<div class="nav-section" data-level="2">
|
|
228
229
|
<a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
|
|
229
230
|
<i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
|
|
@@ -286,77 +287,40 @@
|
|
|
286
287
|
style RLS fill:#f87171</div>
|
|
287
288
|
</div>
|
|
288
289
|
<h2>Database Schema</h2>
|
|
289
|
-
<h3>
|
|
290
|
-
<pre><code class="language-sql">--
|
|
291
|
-
CREATE TABLE
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
slug TEXT UNIQUE NOT NULL,
|
|
295
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
296
|
-
settings JSONB DEFAULT '{}'::jsonb
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
-- Documentation sites table
|
|
300
|
-
CREATE TABLE doc_sites (
|
|
301
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
302
|
-
org_id UUID REFERENCES organizations(id),
|
|
303
|
-
name TEXT NOT NULL,
|
|
304
|
-
domain TEXT UNIQUE NOT NULL,
|
|
305
|
-
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,
|
|
306
295
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
307
|
-
|
|
296
|
+
PRIMARY KEY (user_id, domain)
|
|
308
297
|
);
|
|
309
298
|
|
|
310
|
-
--
|
|
311
|
-
CREATE
|
|
312
|
-
user_id UUID REFERENCES auth.users(id),
|
|
313
|
-
site_id UUID REFERENCES doc_sites(id),
|
|
314
|
-
role TEXT NOT NULL DEFAULT 'viewer',
|
|
315
|
-
granted_at TIMESTAMPTZ DEFAULT NOW(),
|
|
316
|
-
granted_by UUID REFERENCES auth.users(id),
|
|
317
|
-
expires_at TIMESTAMPTZ,
|
|
318
|
-
PRIMARY KEY (user_id, site_id)
|
|
319
|
-
);
|
|
299
|
+
-- Create index for faster lookups
|
|
300
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
320
301
|
|
|
321
|
-
-- Access logs for audit trail
|
|
302
|
+
-- Optional: Access logs for audit trail
|
|
322
303
|
CREATE TABLE access_logs (
|
|
323
304
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
324
305
|
user_id UUID REFERENCES auth.users(id),
|
|
325
|
-
|
|
306
|
+
domain TEXT NOT NULL,
|
|
326
307
|
action TEXT NOT NULL,
|
|
327
308
|
metadata JSONB DEFAULT '{}'::jsonb,
|
|
328
309
|
ip_address INET,
|
|
329
310
|
user_agent TEXT,
|
|
330
311
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
331
312
|
);
|
|
332
|
-
|
|
333
|
-
-- Invitation links
|
|
334
|
-
CREATE TABLE invitations (
|
|
335
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
336
|
-
site_id UUID REFERENCES doc_sites(id),
|
|
337
|
-
email TEXT NOT NULL,
|
|
338
|
-
role TEXT NOT NULL DEFAULT 'viewer',
|
|
339
|
-
token TEXT UNIQUE NOT NULL,
|
|
340
|
-
created_by UUID REFERENCES auth.users(id),
|
|
341
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
342
|
-
expires_at TIMESTAMPTZ NOT NULL,
|
|
343
|
-
claimed_at TIMESTAMPTZ,
|
|
344
|
-
claimed_by UUID REFERENCES auth.users(id)
|
|
345
|
-
);
|
|
346
313
|
</code></pre>
|
|
347
314
|
<h3>Row Level Security Policies</h3>
|
|
348
|
-
<pre><code class="language-sql">--
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
EXISTS (
|
|
352
|
-
SELECT 1 FROM user_site_access
|
|
353
|
-
WHERE site_id = doc_sites.id
|
|
354
|
-
AND user_id = auth.uid()
|
|
355
|
-
AND (expires_at IS NULL OR expires_at > NOW())
|
|
356
|
-
)
|
|
357
|
-
);
|
|
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;
|
|
358
318
|
|
|
359
|
-
--
|
|
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
|
|
360
324
|
CREATE POLICY "Insert access logs" ON access_logs
|
|
361
325
|
FOR INSERT WITH CHECK (user_id = auth.uid());
|
|
362
326
|
|
|
@@ -415,18 +379,20 @@ class SupabaseAuthManager {
|
|
|
415
379
|
}
|
|
416
380
|
}
|
|
417
381
|
);
|
|
418
|
-
this.siteId = config.siteId;
|
|
419
382
|
}
|
|
420
383
|
|
|
421
384
|
async checkAccess() {
|
|
422
385
|
const { data: { user } } = await this.supabase.auth.getUser();
|
|
423
386
|
if (!user) return false;
|
|
424
387
|
|
|
388
|
+
// Use current domain for access check
|
|
389
|
+
const domain = window.location.host;
|
|
390
|
+
|
|
425
391
|
const { data, error } = await this.supabase
|
|
426
|
-
.from('
|
|
427
|
-
.select('
|
|
392
|
+
.from('docbuilder_access')
|
|
393
|
+
.select('created_at')
|
|
428
394
|
.eq('user_id', user.id)
|
|
429
|
-
.eq('
|
|
395
|
+
.eq('domain', domain)
|
|
430
396
|
.single();
|
|
431
397
|
|
|
432
398
|
if (error || !data) return false;
|
|
@@ -469,7 +435,7 @@ class SupabaseAuthManager {
|
|
|
469
435
|
|
|
470
436
|
async logAccess(action, metadata = {}) {
|
|
471
437
|
await this.supabase.from('access_logs').insert({
|
|
472
|
-
|
|
438
|
+
domain: window.location.host,
|
|
473
439
|
action,
|
|
474
440
|
metadata,
|
|
475
441
|
ip_address: await this.getClientIP(),
|
|
@@ -485,8 +451,8 @@ async function buildWithSupabaseAuth(config) {
|
|
|
485
451
|
// Inject Supabase configuration
|
|
486
452
|
const supabaseConfig = {
|
|
487
453
|
supabaseUrl: config.auth.supabaseUrl,
|
|
488
|
-
supabaseAnonKey: config.auth.supabaseAnonKey
|
|
489
|
-
|
|
454
|
+
supabaseAnonKey: config.auth.supabaseAnonKey
|
|
455
|
+
// Domain is detected automatically from window.location.host
|
|
490
456
|
};
|
|
491
457
|
|
|
492
458
|
// Create enhanced auth.js with Supabase integration
|
|
@@ -520,8 +486,8 @@ async function buildWithSupabaseAuth(config) {
|
|
|
520
486
|
auth: {
|
|
521
487
|
// Supabase configuration
|
|
522
488
|
supabaseUrl: process.env.SUPABASE_URL,
|
|
523
|
-
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
524
|
-
siteId
|
|
489
|
+
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
490
|
+
// Domain-based authentication - no siteId needed
|
|
525
491
|
|
|
526
492
|
// Optional: Custom login page styling
|
|
527
493
|
loginTheme: {
|