@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
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,43 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.8.3] - 2025-07-26
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Complete overhaul of authentication system to use domain-based access instead of site IDs
|
|
12
|
+
- **BREAKING**: Removed site ID system entirely - authentication now uses `window.location.host`
|
|
13
|
+
- Simplified database schema to single `docbuilder_access` table with (user_id, domain) primary key
|
|
14
|
+
- No more site registration required - just grant users access to domains
|
|
15
|
+
|
|
16
|
+
### Updated
|
|
17
|
+
- All documentation updated to reflect domain-based authentication
|
|
18
|
+
- CLI commands simplified - no more site ID parameters needed
|
|
19
|
+
- User management tools now work with domains directly
|
|
20
|
+
|
|
21
|
+
### Developer Experience
|
|
22
|
+
- Much simpler setup - no site registration step
|
|
23
|
+
- Automatic domain detection from browser location
|
|
24
|
+
- Easier multi-site management - just use different domains
|
|
25
|
+
|
|
26
|
+
## [1.8.2] - 2025-07-26
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- **Automatic Supabase Credentials**: No more placeholder errors! Credentials are now built into the package
|
|
30
|
+
- **Domain-based Authentication**: No more site IDs! Authentication now uses the current domain automatically
|
|
31
|
+
- Shared authentication database across all doc-builder sites for easier management
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- Supabase URL and anonymous key are now provided by default via `shared-auth-config.js`
|
|
35
|
+
- **BREAKING**: Removed site ID system in favor of domain-based authentication
|
|
36
|
+
- Authentication now uses `window.location.host` for access control
|
|
37
|
+
- Simplified database schema to single `docbuilder_access` table
|
|
38
|
+
- Updated documentation to reflect zero-configuration authentication
|
|
39
|
+
|
|
40
|
+
### Developer Experience
|
|
41
|
+
- No need to configure Supabase credentials manually anymore
|
|
42
|
+
- Just create a `private` directory and authentication works immediately
|
|
43
|
+
- Site administrators only need to grant users access to domains, no site registration needed
|
|
44
|
+
|
|
8
45
|
## [1.8.1] - 2025-07-26
|
|
9
46
|
|
|
10
47
|
### Fixed
|
package/README.md
CHANGED
|
@@ -218,11 +218,11 @@ module.exports = {
|
|
|
218
218
|
attachments: true // Copy PDFs, Excel files, etc. (default: true)
|
|
219
219
|
},
|
|
220
220
|
|
|
221
|
-
// Supabase Authentication
|
|
221
|
+
// Supabase Authentication (v1.8.2+ has built-in defaults)
|
|
222
222
|
auth: {
|
|
223
|
-
supabaseUrl: process.env.SUPABASE_URL,
|
|
224
|
-
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
225
|
-
siteId
|
|
223
|
+
supabaseUrl: process.env.SUPABASE_URL, // Optional
|
|
224
|
+
supabaseAnonKey: process.env.SUPABASE_ANON_KEY // Optional
|
|
225
|
+
// Domain-based auth - no siteId needed!
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
```
|
package/cli.js
CHANGED
|
@@ -1506,7 +1506,6 @@ program
|
|
|
1506
1506
|
console.log(chalk.yellow('\n🔐 Supabase Authentication:'));
|
|
1507
1507
|
console.log(` • Supabase URL: ${config.auth?.supabaseUrl ? chalk.green('Configured') : chalk.red('Missing')}`);
|
|
1508
1508
|
console.log(` • Anonymous Key: ${config.auth?.supabaseAnonKey ? chalk.green('Configured') : chalk.red('Missing')}`);
|
|
1509
|
-
console.log(` • Site ID: ${config.auth?.siteId ? chalk.green('Configured') : chalk.red('Missing')}`);
|
|
1510
1509
|
}
|
|
1511
1510
|
|
|
1512
1511
|
if (config.seo?.enabled) {
|
|
@@ -1568,8 +1567,7 @@ program
|
|
|
1568
1567
|
|
|
1569
1568
|
auth: {
|
|
1570
1569
|
supabaseUrl: '${answers.supabaseUrl}',
|
|
1571
|
-
supabaseAnonKey: '${answers.supabaseAnonKey}'
|
|
1572
|
-
siteId: '' // Will be set after creating site in database
|
|
1570
|
+
supabaseAnonKey: '${answers.supabaseAnonKey}'
|
|
1573
1571
|
}
|
|
1574
1572
|
};`;
|
|
1575
1573
|
|
|
@@ -1577,51 +1575,22 @@ program
|
|
|
1577
1575
|
console.log(chalk.green(`✓ Configuration saved to ${configPath}`));
|
|
1578
1576
|
|
|
1579
1577
|
console.log(chalk.yellow('\n📋 Next steps:'));
|
|
1580
|
-
console.log('1. Create the database tables in your Supabase project (see
|
|
1581
|
-
console.log('2.
|
|
1582
|
-
console.log('3. Update the siteId in your config file');
|
|
1578
|
+
console.log('1. Create the database tables in your Supabase project (see setup-database-v2.sql)');
|
|
1579
|
+
console.log('2. Grant users access by adding their domain to docbuilder_access table');
|
|
1583
1580
|
|
|
1584
1581
|
} catch (error) {
|
|
1585
1582
|
console.error(chalk.red('Error initializing auth:'), error.message);
|
|
1586
1583
|
}
|
|
1587
1584
|
});
|
|
1588
1585
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
.description('Add a documentation site to Supabase database')
|
|
1592
|
-
.requiredOption('--domain <domain>', 'site domain (e.g., docs.example.com)')
|
|
1593
|
-
.requiredOption('--name <name>', 'site display name')
|
|
1594
|
-
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1595
|
-
.action(async (options) => {
|
|
1596
|
-
console.log(chalk.cyan('\n🌐 Add Documentation Site\n'));
|
|
1597
|
-
|
|
1598
|
-
try {
|
|
1599
|
-
const config = await loadConfig(options.config || 'doc-builder.config.js', {});
|
|
1600
|
-
|
|
1601
|
-
if (config.features?.authentication !== 'supabase') {
|
|
1602
|
-
console.error(chalk.red('Error: Supabase authentication is not configured. Run "doc-builder auth:init" first.'));
|
|
1603
|
-
return;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
// This would connect to Supabase and create the site record
|
|
1607
|
-
console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
|
|
1608
|
-
console.log('For now, manually add to your Supabase database:');
|
|
1609
|
-
console.log('');
|
|
1610
|
-
console.log(chalk.gray('INSERT INTO docbuilder_sites (domain, name)'));
|
|
1611
|
-
console.log(chalk.gray(`VALUES ('${options.domain}', '${options.name}');`));
|
|
1612
|
-
console.log('');
|
|
1613
|
-
console.log('Then update your config file with the returned site ID.');
|
|
1614
|
-
|
|
1615
|
-
} catch (error) {
|
|
1616
|
-
console.error(chalk.red('Error adding site:'), error.message);
|
|
1617
|
-
}
|
|
1618
|
-
});
|
|
1586
|
+
// Note: auth:add-site command is no longer needed with domain-based authentication
|
|
1587
|
+
// Sites don't need to be registered - just grant users access to domains directly
|
|
1619
1588
|
|
|
1620
1589
|
program
|
|
1621
1590
|
.command('auth:grant')
|
|
1622
1591
|
.description('Grant user access to documentation site')
|
|
1623
1592
|
.requiredOption('--email <email>', 'user email address')
|
|
1624
|
-
.requiredOption('--
|
|
1593
|
+
.requiredOption('--domain <domain>', 'site domain (e.g., docs.example.com)')
|
|
1625
1594
|
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1626
1595
|
.action(async (options) => {
|
|
1627
1596
|
console.log(chalk.cyan('\n👥 Grant User Access\n'));
|
|
@@ -1637,9 +1606,9 @@ program
|
|
|
1637
1606
|
console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
|
|
1638
1607
|
console.log('For now, manually add to your Supabase database:');
|
|
1639
1608
|
console.log('');
|
|
1640
|
-
console.log(chalk.gray(
|
|
1641
|
-
console.log(chalk.gray('INSERT INTO docbuilder_access (user_id,
|
|
1642
|
-
console.log(chalk.gray(`VALUES ('user-uuid-here', '${options.
|
|
1609
|
+
console.log(chalk.gray(`-- First, get the user ID from auth.users where email = '${options.email}'`));
|
|
1610
|
+
console.log(chalk.gray('INSERT INTO docbuilder_access (user_id, domain)'));
|
|
1611
|
+
console.log(chalk.gray(`VALUES ('user-uuid-here', '${options.domain}');`));
|
|
1643
1612
|
|
|
1644
1613
|
} catch (error) {
|
|
1645
1614
|
console.error(chalk.red('Error granting access:'), error.message);
|
package/html/README.html
CHANGED
|
@@ -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.854Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.854Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/README.html"
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
|
|
133
133
|
<div class="header-actions">
|
|
134
134
|
<div class="deployment-info">
|
|
135
|
-
<span class="deployment-date" title="Built with doc-builder v1.8.
|
|
135
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
|
|
136
136
|
</div>
|
|
137
137
|
|
|
138
138
|
|
package/html/auth.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// Initialize Supabase client
|
|
18
18
|
const { createClient } = supabase;
|
|
19
|
-
const supabaseClient = createClient('https://
|
|
19
|
+
const supabaseClient = createClient('https://xcihhnfcitjrwbynxmka.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhjaWhobmZjaXRqcndieW54bWthIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTM0Mzc2MzcsImV4cCI6MjA2OTAxMzYzN30.zvWp3JFIR8fBIiwuFF5gqOR_Kxb42baZS5fsBz60XOY', {
|
|
20
20
|
auth: {
|
|
21
21
|
persistSession: true,
|
|
22
22
|
autoRefreshToken: true,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
.from('docbuilder_access')
|
|
52
52
|
.select('*')
|
|
53
53
|
.eq('user_id', user.id)
|
|
54
|
-
.eq('site_id', '
|
|
54
|
+
.eq('site_id', '-knowcode-doc-builder-1753528305501-qlqnmw')
|
|
55
55
|
.single();
|
|
56
56
|
|
|
57
57
|
if (accessError || !access) {
|
|
@@ -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.864Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.864Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/documentation-index.html"
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
|
|
133
133
|
<div class="header-actions">
|
|
134
134
|
<div class="deployment-info">
|
|
135
|
-
<span class="deployment-date" title="Built with doc-builder v1.8.
|
|
135
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
|
|
136
136
|
</div>
|
|
137
137
|
|
|
138
138
|
|
|
@@ -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.867Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.867Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/authentication-default-change.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
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<meta name="description" content="
|
|
6
|
+
<meta name="description" content="> 🎉 Update v1.8.2: Supabase credentials are now automatically configured! No manual setup needed - just enable authentication and add users to the database.">
|
|
7
7
|
<title>Authentication Guide for @knowcode/doc-builder</title>
|
|
8
8
|
|
|
9
9
|
<meta name="author" content="Lindsay Smith">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<meta property="og:type" content="article">
|
|
16
16
|
<meta property="og:url" content="https://doc-builder-delta.vercel.app/guides/authentication-guide.html">
|
|
17
17
|
<meta property="og:title" content="Authentication Guide for @knowcode/doc-builder">
|
|
18
|
-
<meta property="og:description" content="
|
|
18
|
+
<meta property="og:description" content="> 🎉 Update v1.8.2: Supabase credentials are now automatically configured! No manual setup needed - just enable authentication and add users to the database.">
|
|
19
19
|
<meta property="og:image" content="https://doc-builder-delta.vercel.app/og-default.png">
|
|
20
20
|
<meta property="og:site_name" content="@knowcode/doc-builder">
|
|
21
21
|
<meta property="og:locale" content="en_US">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<meta name="twitter:site" content="@planbbackups">
|
|
26
26
|
<meta name="twitter:creator" content="@planbbackups">
|
|
27
27
|
<meta name="twitter:title" content="Authentication Guide for @knowcode/doc-builder">
|
|
28
|
-
<meta name="twitter:description" content="
|
|
28
|
+
<meta name="twitter:description" content="> 🎉 Update v1.8.2: Supabase credentials are now automatically configured! No manual setup needed - just enable authentication and add users to the database.">
|
|
29
29
|
<meta name="twitter:image" content="https://doc-builder-delta.vercel.app/og-default.png">
|
|
30
30
|
|
|
31
31
|
<!-- Custom Meta Tags -->
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@context": "https://schema.org",
|
|
89
89
|
"@type": "TechArticle",
|
|
90
90
|
"headline": "Authentication Guide for @knowcode/doc-builder",
|
|
91
|
-
"description": "
|
|
91
|
+
"description": "> 🎉 Update v1.8.2: Supabase credentials are now automatically configured! No manual setup needed - just enable authentication and add users to the database.",
|
|
92
92
|
"author": {
|
|
93
93
|
"@type": "Person",
|
|
94
94
|
"name": "Lindsay Smith"
|
|
@@ -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.870Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.870Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/authentication-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
|
|
|
@@ -220,6 +220,9 @@
|
|
|
220
220
|
<main class="content">
|
|
221
221
|
<div class="content-inner">
|
|
222
222
|
<h1>Authentication Guide for @knowcode/doc-builder</h1>
|
|
223
|
+
<blockquote>
|
|
224
|
+
<p><strong><i class="ph ph-confetti" aria-label="party"></i> Update v1.8.2</strong>: Supabase credentials are now automatically configured! No manual setup needed - just enable authentication and add users to the database.</p>
|
|
225
|
+
</blockquote>
|
|
223
226
|
<h2>Overview</h2>
|
|
224
227
|
<p>@knowcode/doc-builder supports enterprise-grade authentication through <strong>Supabase</strong> - a secure, scalable authentication platform. This guide explains how to protect your documentation with proper user authentication and access control.</p>
|
|
225
228
|
<h2>Why Supabase?</h2>
|
|
@@ -258,8 +261,10 @@
|
|
|
258
261
|
<li>Create a new project</li>
|
|
259
262
|
<li>Note your project URL and anon key</li>
|
|
260
263
|
</ol>
|
|
261
|
-
<h3>Step 2: Configure doc-builder</h3>
|
|
262
|
-
<p>
|
|
264
|
+
<h3>Step 2: Configure doc-builder (Mostly Automatic!)</h3>
|
|
265
|
+
<p>As of v1.8.2, Supabase credentials are automatically configured. You have two options:</p>
|
|
266
|
+
<p><strong>Option 1: Automatic (Recommended)</strong><br>Just create a <code>docs/private/</code> directory and authentication is automatically enabled with built-in credentials.</p>
|
|
267
|
+
<p><strong>Option 2: Custom Configuration</strong><br>Create or update <code>doc-builder.config.js</code> (only if using your own Supabase project):</p>
|
|
263
268
|
<pre><code class="language-javascript">module.exports = {
|
|
264
269
|
siteName: 'My Documentation',
|
|
265
270
|
|
|
@@ -268,64 +273,52 @@
|
|
|
268
273
|
},
|
|
269
274
|
|
|
270
275
|
auth: {
|
|
271
|
-
supabaseUrl: 'https://your-project.supabase.co',
|
|
272
|
-
supabaseAnonKey: 'your-anon-key'
|
|
273
|
-
siteId: 'your-site-id' // From database after setup
|
|
276
|
+
supabaseUrl: 'https://your-project.supabase.co', // Optional - has defaults
|
|
277
|
+
supabaseAnonKey: 'your-anon-key' // Optional - has defaults
|
|
274
278
|
}
|
|
275
279
|
};
|
|
276
280
|
</code></pre>
|
|
281
|
+
<p>Note: No more <code>siteId</code> needed! The system uses domains automatically.</p>
|
|
277
282
|
<h3>Step 3: Set Up Database</h3>
|
|
278
|
-
<p>Run
|
|
279
|
-
<pre><code class="language-sql">--
|
|
280
|
-
CREATE TABLE docbuilder_sites (
|
|
281
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
282
|
-
domain TEXT UNIQUE NOT NULL,
|
|
283
|
-
name TEXT NOT NULL,
|
|
284
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
-- Create access table
|
|
283
|
+
<p>Run this SQL command in your Supabase SQL editor (or use setup-database-v2.sql):</p>
|
|
284
|
+
<pre><code class="language-sql">-- Single table for user access control
|
|
288
285
|
CREATE TABLE docbuilder_access (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
site_id UUID NOT NULL REFERENCES docbuilder_sites(id),
|
|
286
|
+
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
287
|
+
domain TEXT NOT NULL,
|
|
292
288
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
293
|
-
|
|
289
|
+
PRIMARY KEY (user_id, domain)
|
|
294
290
|
);
|
|
295
291
|
|
|
292
|
+
-- Create index for faster lookups
|
|
293
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
294
|
+
|
|
296
295
|
-- Enable Row Level Security
|
|
297
|
-
ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
|
|
298
296
|
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
299
297
|
|
|
300
|
-
--
|
|
301
|
-
CREATE POLICY "
|
|
302
|
-
FOR SELECT USING (
|
|
303
|
-
id IN (
|
|
304
|
-
SELECT site_id FROM docbuilder_access
|
|
305
|
-
WHERE user_id = auth.uid()
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
CREATE POLICY "Access visible to own user" ON docbuilder_access
|
|
298
|
+
-- RLS Policy: Users can only see their own access
|
|
299
|
+
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
310
300
|
FOR SELECT USING (user_id = auth.uid());
|
|
311
301
|
</code></pre>
|
|
312
|
-
<h3>Step 4:
|
|
313
|
-
<
|
|
314
|
-
VALUES ('your-domain.com', 'Your Documentation Name');
|
|
315
|
-
</code></pre>
|
|
316
|
-
<p>Note the returned ID - this is your <code>siteId</code> for the config.</p>
|
|
302
|
+
<h3>Step 4: No Site Registration Needed!</h3>
|
|
303
|
+
<p>With the new domain-based system, you don't need to register sites. The system automatically uses the current domain (e.g., docs.example.com) as the access key.</p>
|
|
317
304
|
<h3>Step 5: Create Users</h3>
|
|
318
305
|
<p>Users can sign up through Supabase Auth, or you can create them:</p>
|
|
319
306
|
<pre><code class="language-sql">-- In Supabase dashboard, go to Authentication > Users
|
|
320
307
|
-- Click "Invite user" and enter their email
|
|
321
308
|
</code></pre>
|
|
322
309
|
<h3>Step 6: Grant Access</h3>
|
|
323
|
-
<pre><code class="language-sql">-- Grant user access to your
|
|
324
|
-
INSERT INTO docbuilder_access (user_id,
|
|
310
|
+
<pre><code class="language-sql">-- Grant user access to your documentation domain
|
|
311
|
+
INSERT INTO docbuilder_access (user_id, domain)
|
|
325
312
|
VALUES (
|
|
326
313
|
(SELECT id FROM auth.users WHERE email = 'user@example.com'),
|
|
327
|
-
'
|
|
314
|
+
'docs.example.com'
|
|
328
315
|
);
|
|
316
|
+
|
|
317
|
+
-- Grant multiple users access
|
|
318
|
+
INSERT INTO docbuilder_access (user_id, domain)
|
|
319
|
+
SELECT id, 'docs.example.com'
|
|
320
|
+
FROM auth.users
|
|
321
|
+
WHERE email IN ('user1@example.com', 'user2@example.com', 'user3@example.com');
|
|
329
322
|
</code></pre>
|
|
330
323
|
<h2>Deployment</h2>
|
|
331
324
|
<h3>Build with Authentication</h3>
|
|
@@ -367,11 +360,10 @@ npx @knowcode/doc-builder auth:list-users --site-id xxx
|
|
|
367
360
|
</ul>
|
|
368
361
|
<h3>Security Best Practices</h3>
|
|
369
362
|
<ol>
|
|
370
|
-
<li><p><strong>Use environment variables</strong> for
|
|
363
|
+
<li><p><strong>Use environment variables</strong> for custom config (optional):</p>
|
|
371
364
|
<pre><code class="language-javascript">auth: {
|
|
372
|
-
supabaseUrl: process.env.SUPABASE_URL,
|
|
373
|
-
supabaseAnonKey: process.env.SUPABASE_ANON_KEY
|
|
374
|
-
siteId: process.env.DOC_SITE_ID
|
|
365
|
+
supabaseUrl: process.env.SUPABASE_URL || defaultUrl,
|
|
366
|
+
supabaseAnonKey: process.env.SUPABASE_ANON_KEY || defaultKey
|
|
375
367
|
}
|
|
376
368
|
</code></pre>
|
|
377
369
|
</li>
|
|
@@ -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.874Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.874Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/claude-workflow-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
|
|
|
@@ -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.878Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.878Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/documentation-standards.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.880Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.880Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/phosphor-icons-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
|
|
|
@@ -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.883Z",
|
|
102
|
+
"dateModified": "2025-07-26T11:11:45.883Z",
|
|
103
103
|
"mainEntityOfPage": {
|
|
104
104
|
"@type": "WebPage",
|
|
105
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/private-directory-authentication.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
|
|
|
@@ -264,11 +264,12 @@ module.exports = {
|
|
|
264
264
|
};
|
|
265
265
|
</code></pre>
|
|
266
266
|
<h2>How They Work Together</h2>
|
|
267
|
-
<p>If you have <strong>both</strong> a private directory AND set
|
|
267
|
+
<p>If you have <strong>both</strong> a private directory AND set authentication in your config:</p>
|
|
268
268
|
<ul>
|
|
269
|
-
<li>The
|
|
270
|
-
<li>
|
|
271
|
-
<li>
|
|
269
|
+
<li>The private directory <strong>always</strong> triggers authentication (for security)</li>
|
|
270
|
+
<li>Setting <code>authentication: 'supabase'</code> makes the entire site private</li>
|
|
271
|
+
<li>Setting <code>authentication: false</code> is overridden by private directory presence</li>
|
|
272
|
+
<li>This ensures private content is never accidentally exposed</li>
|
|
272
273
|
</ul>
|
|
273
274
|
<h2>User Experience</h2>
|
|
274
275
|
<h3>Private Directory Mode</h3>
|
|
@@ -295,41 +296,65 @@ module.exports = {
|
|
|
295
296
|
</ul>
|
|
296
297
|
<h2>Setting Up Supabase Authentication</h2>
|
|
297
298
|
<p>Both authentication modes use Supabase for secure user management. Here's how to configure it:</p>
|
|
298
|
-
<h3>1.
|
|
299
|
-
<p>
|
|
299
|
+
<h3>1. Credentials Are Automatic! (v1.8.2+)</h3>
|
|
300
|
+
<p>No need to configure credentials anymore! The shared Supabase database is automatically configured. Each site gets a unique auto-generated site ID during build.</p>
|
|
301
|
+
<p>To override with custom credentials (optional):</p>
|
|
300
302
|
<pre><code class="language-javascript">module.exports = {
|
|
301
303
|
auth: {
|
|
302
|
-
supabaseUrl: 'https://your-project.supabase.co',
|
|
303
|
-
supabaseAnonKey: 'your-anon-key',
|
|
304
|
-
siteId: 'your-site-id'
|
|
304
|
+
supabaseUrl: 'https://your-project.supabase.co', // Optional override
|
|
305
|
+
supabaseAnonKey: 'your-anon-key', // Optional override
|
|
306
|
+
siteId: 'your-site-id' // Optional custom ID
|
|
305
307
|
}
|
|
306
308
|
};
|
|
307
309
|
</code></pre>
|
|
308
310
|
<h3>2. Create Access Control Table</h3>
|
|
309
|
-
<p>In your Supabase dashboard, run this SQL
|
|
311
|
+
<p>In your Supabase dashboard, run this SQL (or use setup-database-v2.sql):</p>
|
|
310
312
|
<pre><code class="language-sql">CREATE TABLE docbuilder_access (
|
|
311
|
-
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
312
313
|
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
313
|
-
|
|
314
|
+
domain TEXT NOT NULL,
|
|
314
315
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
315
|
-
|
|
316
|
+
PRIMARY KEY (user_id, domain)
|
|
316
317
|
);
|
|
318
|
+
|
|
319
|
+
-- Create index for performance
|
|
320
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
321
|
+
|
|
322
|
+
-- Enable Row Level Security
|
|
323
|
+
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
324
|
+
|
|
325
|
+
-- RLS Policy
|
|
326
|
+
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
327
|
+
FOR SELECT USING (user_id = auth.uid());
|
|
317
328
|
</code></pre>
|
|
318
329
|
<h3>3. Grant User Access</h3>
|
|
319
|
-
<p>Add authorized users by
|
|
330
|
+
<p>Add authorized users by domain:</p>
|
|
320
331
|
<pre><code class="language-sql">-- First, create a user in Supabase Auth
|
|
321
|
-
-- Then grant them access to your documentation
|
|
322
|
-
INSERT INTO docbuilder_access (user_id,
|
|
323
|
-
VALUES ('user-uuid-from-auth-users', '
|
|
332
|
+
-- Then grant them access to your documentation domain
|
|
333
|
+
INSERT INTO docbuilder_access (user_id, domain)
|
|
334
|
+
VALUES ('user-uuid-from-auth-users', 'docs.example.com');
|
|
335
|
+
|
|
336
|
+
-- Or grant access to multiple domains
|
|
337
|
+
INSERT INTO docbuilder_access (user_id, domain) VALUES
|
|
338
|
+
('user-uuid', 'docs.example.com'),
|
|
339
|
+
('user-uuid', 'staging-docs.example.com'),
|
|
340
|
+
('user-uuid', 'localhost:3000');
|
|
324
341
|
</code></pre>
|
|
325
|
-
<h3>
|
|
326
|
-
<p>
|
|
342
|
+
<h3>Automatic Credential Configuration</h3>
|
|
343
|
+
<p>Starting from version 1.8.2, authentication is truly zero-configuration:</p>
|
|
327
344
|
<ul>
|
|
328
|
-
<li>
|
|
329
|
-
<li>
|
|
330
|
-
<li>
|
|
331
|
-
<li>
|
|
345
|
+
<li>All doc-builder sites share the same Supabase authentication database</li>
|
|
346
|
+
<li>Credentials are built into the package - no manual configuration needed</li>
|
|
347
|
+
<li>No site IDs needed - the system uses your domain automatically</li>
|
|
348
|
+
<li>Just grant users access to your domain in the database</li>
|
|
332
349
|
</ul>
|
|
350
|
+
<p><strong>Note</strong>: When you build with a private directory:</p>
|
|
351
|
+
<pre><code>🔐 Found private directory - automatically enabling Supabase authentication
|
|
352
|
+
Note: Grant users access by adding domain to the docbuilder_access table
|
|
353
|
+
</code></pre>
|
|
354
|
+
<p><strong>Example</strong>: For a site at <code>docs.example.com</code>, grant access with:</p>
|
|
355
|
+
<pre><code class="language-sql">INSERT INTO docbuilder_access (user_id, domain)
|
|
356
|
+
VALUES ('user-uuid', 'docs.example.com');
|
|
357
|
+
</code></pre>
|
|
333
358
|
<h2>Best Practices</h2>
|
|
334
359
|
<h3>Choosing the Right Mode</h3>
|
|
335
360
|
<p><strong>Use Private Directory Mode when:</strong></p>
|