@knowcode/doc-builder 1.7.6 → 1.8.0

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.
Files changed (42) hide show
  1. package/.claude/settings.local.json +3 -1
  2. package/CHANGELOG.md +22 -0
  3. package/assets/css/notion-style.css +9 -1
  4. package/html/README.html +5 -19
  5. package/html/css/notion-style.css +9 -1
  6. package/html/documentation-index.html +5 -19
  7. package/html/guides/authentication-default-change.html +5 -19
  8. package/html/guides/authentication-guide.html +189 -262
  9. package/html/guides/claude-workflow-guide.html +5 -19
  10. package/html/guides/documentation-standards.html +5 -19
  11. package/html/guides/phosphor-icons-guide.html +5 -19
  12. package/html/guides/private-directory-authentication.html +352 -0
  13. package/html/guides/public-site-deployment.html +11 -24
  14. package/html/guides/search-engine-verification-guide.html +5 -19
  15. package/html/guides/seo-guide.html +5 -19
  16. package/html/guides/seo-optimization-guide.html +5 -19
  17. package/html/guides/troubleshooting-guide.html +5 -19
  18. package/html/guides/windows-setup-guide.html +5 -19
  19. package/html/index.html +5 -19
  20. package/html/private/cache-control-anti-pattern.html +347 -0
  21. package/html/private/launch/README.html +289 -0
  22. package/html/private/launch/auth-cleanup-summary.html +279 -0
  23. package/html/private/launch/bubble-plugin-specification.html +925 -0
  24. package/html/private/launch/go-to-market-strategy.html +655 -0
  25. package/html/private/launch/launch-announcements.html +585 -0
  26. package/html/private/launch/vercel-deployment-auth-setup.html +329 -0
  27. package/html/private/next-steps-walkthrough.html +624 -0
  28. package/html/private/supabase-auth-implementation-completed.html +372 -0
  29. package/html/private/supabase-auth-implementation-plan.html +529 -0
  30. package/html/private/supabase-auth-integration-plan.html +657 -0
  31. package/html/private/supabase-auth-setup-guide.html +484 -0
  32. package/html/private/test-private-doc.html +220 -0
  33. package/html/sitemap.xml +113 -29
  34. package/html/vercel-cli-setup-guide.html +5 -19
  35. package/html/vercel-first-time-setup-guide.html +5 -19
  36. package/lib/config.js +24 -0
  37. package/lib/core-builder.js +40 -6
  38. package/lib/supabase-auth.js +60 -11
  39. package/package.json +1 -1
  40. package/user-management/README.md +81 -0
  41. package/user-management/add-users.sh +357 -0
  42. package/user-management/users.txt +15 -0
@@ -3,19 +3,19 @@
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="&gt; SECURITY WARNING: This basic authentication method has been deprecated and removed due to security vulnerabilities.">
7
- <title>⚠️ DEPRECATED: Basic Authentication Guide</title>
6
+ <meta name="description" content="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform. This guide explains how to...">
7
+ <title>Authentication Guide for @knowcode/doc-builder</title>
8
8
 
9
9
  <meta name="author" content="Lindsay Smith">
10
- <meta name="keywords" content="documentation, markdown, static site generator, vercel, notion-style, authentication, login">
10
+ <meta name="keywords" content="documentation, markdown, static site generator, vercel, notion-style, supabase, authentication">
11
11
  <meta name="robots" content="index, follow">
12
12
  <link rel="canonical" href="https://doc-builder-delta.vercel.app/guides/authentication-guide.html">
13
13
 
14
14
  <!-- Open Graph / Facebook -->
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
- <meta property="og:title" content="⚠️ DEPRECATED: Basic Authentication Guide">
18
- <meta property="og:description" content="&gt; SECURITY WARNING: This basic authentication method has been deprecated and removed due to security vulnerabilities.">
17
+ <meta property="og:title" content="Authentication Guide for @knowcode/doc-builder">
18
+ <meta property="og:description" content="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform. This guide explains how to...">
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">
@@ -24,8 +24,8 @@
24
24
  <meta name="twitter:card" content="summary_large_image">
25
25
  <meta name="twitter:site" content="@planbbackups">
26
26
  <meta name="twitter:creator" content="@planbbackups">
27
- <meta name="twitter:title" content="⚠️ DEPRECATED: Basic Authentication Guide">
28
- <meta name="twitter:description" content="&gt; SECURITY WARNING: This basic authentication method has been deprecated and removed due to security vulnerabilities.">
27
+ <meta name="twitter:title" content="Authentication Guide for @knowcode/doc-builder">
28
+ <meta name="twitter:description" content="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform. This guide explains how to...">
29
29
  <meta name="twitter:image" content="https://doc-builder-delta.vercel.app/og-default.png">
30
30
 
31
31
  <!-- Custom Meta Tags -->
@@ -54,8 +54,8 @@
54
54
  {
55
55
  "@context": "https://schema.org",
56
56
  "@type": "TechArticle",
57
- "headline": "⚠️ DEPRECATED: Basic Authentication Guide",
58
- "description": "> SECURITY WARNING: This basic authentication method has been deprecated and removed due to security vulnerabilities.",
57
+ "headline": "Authentication Guide for @knowcode/doc-builder",
58
+ "description": "@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform. This guide explains how to...",
59
59
  "author": {
60
60
  "@type": "Person",
61
61
  "name": "Lindsay Smith"
@@ -65,8 +65,8 @@
65
65
  "name": "Knowcode Ltd",
66
66
  "url": "https://knowcode.tech"
67
67
  },
68
- "datePublished": "2025-07-25T13:49:06.520Z",
69
- "dateModified": "2025-07-25T13:49:06.520Z",
68
+ "datePublished": "2025-07-26T09:59:22.945Z",
69
+ "dateModified": "2025-07-26T09:59:22.945Z",
70
70
  "mainEntityOfPage": {
71
71
  "@type": "WebPage",
72
72
  "@id": "https://doc-builder-delta.vercel.app/guides/authentication-guide.html"
@@ -105,7 +105,7 @@
105
105
 
106
106
  <div class="header-actions">
107
107
  <div class="deployment-info">
108
- <span class="deployment-date" title="Built with doc-builder v1.7.5">Last updated: Jul 25, 2025, 01:49 PM UTC</span>
108
+ <span class="deployment-date" title="Built with doc-builder v1.8.0">Last updated: Jul 26, 2025, 09:59 AM UTC</span>
109
109
  </div>
110
110
 
111
111
 
@@ -164,31 +164,17 @@
164
164
  </a>
165
165
  <div class="nav-content" id="nav-guides-1">
166
166
  <a href="/guides/authentication-default-change.html" class="nav-item" data-tooltip="Starting from version 1.7.4, @knowcode/doc-builder now defaults to no authentication for all documentation sites."><i class="fas fa-file-alt"></i> Authentication Default Change</a>
167
- <a href="/guides/authentication-guide.html" class="nav-item active" data-tooltip="🚨 This authentication method has been REMOVED in version 2.0.0 due to serious security flaws."><i class="fas fa-file-alt"></i> Authentication Guide</a>
168
- <a href="/guides/cache-control-anti-pattern.html" class="nav-item" data-tooltip="Cache Control Anti-Pattern: Why Aggressive Cache-Busting is Bad for Documentation Sites."><i class="fas fa-file-alt"></i> Cache Control Anti Pattern</a>
167
+ <a href="/guides/authentication-guide.html" class="nav-item active" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform."><i class="fas fa-file-alt"></i> Authentication Guide</a>
169
168
  <a href="/guides/claude-workflow-guide.html" class="nav-item" data-tooltip="This guide demonstrates an efficient workflow for using Claude Code with a refined CLAUDE.md file to create high-quality documentation and deploy it..."><i class="fas fa-file-alt"></i> Claude Workflow Guide</a>
170
169
  <a href="/guides/documentation-standards.html" class="nav-item" data-tooltip="This document defines the documentation standards and conventions for the @knowcode/doc-builder project."><i class="fas fa-file-alt"></i> Documentation Standards</a>
171
- <a href="/guides/next-steps-walkthrough.html" class="nav-item" data-tooltip="Now that we&#039;ve implemented Supabase authentication, let&#039;s walk through testing the implementation and preparing for deployment."><i class="fas fa-file-alt"></i> Next Steps Walkthrough</a>
172
170
  <a href="/guides/phosphor-icons-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder automatically converts Unicode emojis in your markdown files to beautiful Phosphor icons in the generated HTML."><i class="fas fa-file-alt"></i> Phosphor Icons Guide</a>
171
+ <a href="/guides/private-directory-authentication.html" class="nav-item" data-tooltip="The @knowcode/doc-builder now includes automatic authentication for documents placed in a directory."><i class="fas fa-file-alt"></i> Private Directory Authentication</a>
173
172
  <a href="/guides/public-site-deployment.html" class="nav-item" data-tooltip="The @knowcode/doc-builder now supports deploying public documentation sites without authentication."><i class="fas fa-file-alt"></i> Public Site Deployment</a>
174
173
  <a href="/guides/search-engine-verification-guide.html" class="nav-item" data-tooltip="Search engine verification provides access to powerful webmaster tools:."><i class="fas fa-file-alt"></i> Search Engine Verification Guide</a>
175
174
  <a href="/guides/seo-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder includes comprehensive SEO (Search Engine Optimization) features to help your documentation rank better in search results and..."><i class="fas fa-file-alt"></i> Seo Guide</a>
176
175
  <a href="/guides/seo-optimization-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder includes comprehensive SEO (Search Engine Optimization) features that automatically optimize your documentation for search..."><i class="fas fa-file-alt"></i> Seo Optimization Guide</a>
177
- <a href="/guides/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>
178
- <a href="/guides/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>
179
- <a href="/guides/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder now supports enterprise-grade authentication through Supabase, replacing the previous insecure basic authentication."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
180
176
  <a href="/guides/troubleshooting-guide.html" class="nav-item" data-tooltip="This guide helps you resolve common issues when using @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Troubleshooting Guide</a>
181
- <a href="/guides/vercel-deployment-auth-setup.html" class="nav-item" data-tooltip="Vercel Deployment Authentication Setup Guide."><i class="fas fa-file-alt"></i> Vercel Deployment Auth Setup</a>
182
177
  <a href="/guides/windows-setup-guide.html" class="nav-item" data-tooltip="This guide helps Windows users set up the complete AI-powered documentation workflow using Claude Code, @knowcode/doc-builder, and Vercel."><i class="fas fa-file-alt"></i> Windows Setup Guide</a></div></div>
183
- <div class="nav-section" data-level="1">
184
- <a class="nav-title collapsible" href="/launch/README.html" data-target="nav-launch-1" >
185
- <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
186
- </a>
187
- <div class="nav-content collapsed" id="nav-launch-1">
188
- <a href="/launch/README.html" class="nav-item" data-tooltip="This directory contains all documentation related to the commercial launch of @knowcode/doc-builder, including go-to-market strategy, platform..."><i class="fas fa-file-alt"></i> Launch Overview</a>
189
- <a href="/launch/bubble-plugin-specification.html" class="nav-item" data-tooltip="This document outlines the technical specification for creating a Bubble.io plugin that integrates @knowcode/doc-builder, enabling Bubble developers..."><i class="fas fa-file-alt"></i> Bubble Plugin Specification</a>
190
- <a href="/launch/go-to-market-strategy.html" class="nav-item" data-tooltip="Go-to-Market Strategy &amp; Product Launch Plan."><i class="fas fa-file-alt"></i> Go To Market Strategy</a>
191
- <a href="/launch/launch-announcements.html" class="nav-item" data-tooltip="This document contains ready-to-use announcement templates for launching @knowcode/doc-builder across various platforms and channels."><i class="fas fa-file-alt"></i> Launch Announcements</a></div></div>
192
178
  </nav>
193
179
  <div class="resize-handle"></div>
194
180
  </aside>
@@ -196,281 +182,222 @@
196
182
  <!-- Content Area -->
197
183
  <main class="content">
198
184
  <div class="content-inner">
199
- <h1><i class="ph ph-warning-circle" aria-label="warning"></i> DEPRECATED: Basic Authentication Guide</h1>
200
- <blockquote>
201
- <p><strong>SECURITY WARNING</strong>: This basic authentication method has been deprecated and removed due to security vulnerabilities. </p>
202
- <p><strong>Use <a href="supabase-auth-setup-guide.md">Supabase Authentication</a> instead</strong> for secure, enterprise-grade authentication.</p>
203
- </blockquote>
204
- <h1>Authentication Guide for @knowcode/doc-builder (DEPRECATED)</h1>
185
+ <h1>Authentication Guide for @knowcode/doc-builder</h1>
205
186
  <h2>Overview</h2>
206
- <blockquote>
207
- <p><i class="ph ph-siren" aria-label="alert"></i> <strong>This authentication method has been REMOVED in version 2.0.0</strong> due to serious security flaws. Please migrate to <a href="supabase-auth-setup-guide.md">Supabase Authentication</a>.</p>
208
- </blockquote>
209
- <p>This guide explains the old, insecure authentication method that was available in @knowcode/doc-builder v1.x. It has been completely removed for security reasons.</p>
210
- <h2>What is Authentication?</h2>
211
- <p>The authentication feature in doc-builder provides a simple way to protect your documentation from unauthorized access. When enabled, users must log in with a username and password before viewing any documentation pages.</p>
212
- <h3>Features</h3>
213
- <ul>
214
- <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Client-side authentication</strong> - Works with static site hosting</li>
215
- <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Cookie-based sessions</strong> - Users stay logged in across pages</li>
216
- <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Redirect handling</strong> - Returns users to requested page after login</li>
217
- <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Logout functionality</strong> - Clear session and return to login</li>
218
- <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Customizable credentials</strong> - Set your own username/password</li>
219
- </ul>
220
- <h3>Limitations</h3>
187
+ <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>
188
+ <h2>Why Supabase?</h2>
221
189
  <ul>
222
- <li><i class="ph ph-warning-circle" aria-label="warning"></i> <strong>Basic security</strong> - Suitable for casual protection only</li>
223
- <li><i class="ph ph-warning-circle" aria-label="warning"></i> <strong>Client-side validation</strong> - Not suitable for highly sensitive data</li>
224
- <li><i class="ph ph-warning-circle" aria-label="warning"></i> <strong>Single user</strong> - No multi-user or role-based access</li>
225
- <li><i class="ph ph-warning-circle" aria-label="warning"></i> <strong>Credentials in JavaScript</strong> - Visible in browser developer tools</li>
190
+ <li><i class="ph ph-lock-key" aria-label="secure"></i> <strong>Enterprise Security</strong>: JWT tokens, bcrypt password hashing, Row Level Security</li>
191
+ <li><i class="ph ph-users" aria-label="team"></i> <strong>Multi-User Support</strong>: Unlimited users with fine-grained access control</li>
192
+ <li>🌍 <strong>Scalable</strong>: Built on PostgreSQL, handles millions of users</li>
193
+ <li><i class="ph ph-arrows-clockwise" aria-label="refresh"></i> <strong>Real-time</strong>: Live updates when permissions change</li>
194
+ <li><i class="ph ph-money" aria-label="money"></i> <strong>Generous Free Tier</strong>: 50,000 monthly active users free</li>
226
195
  </ul>
227
- <h2>How Authentication Works</h2>
196
+ <h2>How It Works</h2>
228
197
  <div class="mermaid-wrapper">
229
198
  <div class="mermaid">graph TD
230
- A[User visits page] --> B{Authenticated?}
199
+ A[User visits page] --> B{Has JWT Token?}
231
200
  B -->|No| C[Redirect to login]
232
- B -->|Yes| D[Show content]
201
+ B -->|Yes| D[Verify with Supabase]
233
202
  C --> E[Enter credentials]
234
- E --> F{Valid?}
235
- F -->|No| G[Show error]
236
- F -->|Yes| H[Set cookie]
237
- H --> I[Redirect to original page]
238
- G --> E
203
+ E --> F[Authenticate with Supabase]
204
+ F --> G{Valid?}
205
+ G -->|No| H[Show error]
206
+ G -->|Yes| I[Receive JWT token]
207
+ I --> J[Check site access]
208
+ J --> K{Has access?}
209
+ K -->|Yes| L[Show content]
210
+ K -->|No| M[Access denied]
211
+ D --> J
239
212
 
240
213
  style A fill:#e1f5fe
241
- style D fill:#c8e6c9
242
- style G fill:#ffcdd2</div>
214
+ style L fill:#c8e6c9
215
+ style M fill:#ffcdd2</div>
243
216
  </div>
244
- <h3>Technical Flow</h3>
217
+ <h2>Setting Up Authentication</h2>
218
+ <h3>Step 1: Create Supabase Project</h3>
245
219
  <ol>
246
- <li><strong>Page Load</strong>: Every page includes <code>auth.js</code> which checks for authentication</li>
247
- <li><strong>Cookie Check</strong>: Looks for <code>doc-auth</code> cookie with valid token</li>
248
- <li><strong>Redirect</strong>: Unauthenticated users sent to <code>/login.html</code></li>
249
- <li><strong>Login</strong>: Credentials validated client-side against config values</li>
250
- <li><strong>Session</strong>: Base64-encoded token stored in cookie</li>
251
- <li><strong>Access</strong>: Authenticated users can view all pages</li>
220
+ <li>Go to <a href="https://supabase.com">Supabase</a></li>
221
+ <li>Create a new project</li>
222
+ <li>Note your project URL and anon key</li>
252
223
  </ol>
253
- <h2>Configuration</h2>
254
- <h3>Enable Authentication</h3>
255
- <p>Authentication can be enabled in three ways:</p>
256
- <h4>1. Configuration File</h4>
257
- <p>Create <code>doc-builder.config.js</code> in your project root:</p>
224
+ <h3>Step 2: Configure doc-builder</h3>
225
+ <p>Create or update <code>doc-builder.config.js</code>:</p>
258
226
  <pre><code class="language-javascript">module.exports = {
259
- siteName: &#39;@knowcode/doc-builder&#39;,
260
- siteDescription: &#39;Internal documentation portal&#39;,
227
+ siteName: &#39;My Documentation&#39;,
261
228
 
262
229
  features: {
263
- authentication: true
230
+ authentication: &#39;supabase&#39; // Enable Supabase auth
264
231
  },
265
232
 
266
233
  auth: {
267
- username: &#39;myusername&#39;,
268
- password: &#39;mysecurepassword&#39;
234
+ supabaseUrl: &#39;https://your-project.supabase.co&#39;,
235
+ supabaseAnonKey: &#39;your-anon-key&#39;,
236
+ siteId: &#39;your-site-id&#39; // From database after setup
269
237
  }
270
238
  };
271
239
  </code></pre>
272
- <h4>2. Using Presets</h4>
273
- <p>Use the notion-inspired preset which has authentication enabled by default:</p>
274
- <pre><code class="language-bash">npx @knowcode/doc-builder@latest build --preset notion-inspired
240
+ <h3>Step 3: Set Up Database</h3>
241
+ <p>Run these SQL commands in your Supabase SQL editor:</p>
242
+ <pre><code class="language-sql">-- Create sites table
243
+ CREATE TABLE docbuilder_sites (
244
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
245
+ domain TEXT UNIQUE NOT NULL,
246
+ name TEXT NOT NULL,
247
+ created_at TIMESTAMPTZ DEFAULT NOW()
248
+ );
249
+
250
+ -- Create access table
251
+ CREATE TABLE docbuilder_access (
252
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
253
+ user_id UUID NOT NULL REFERENCES auth.users(id),
254
+ site_id UUID NOT NULL REFERENCES docbuilder_sites(id),
255
+ created_at TIMESTAMPTZ DEFAULT NOW(),
256
+ UNIQUE(user_id, site_id)
257
+ );
258
+
259
+ -- Enable Row Level Security
260
+ ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
261
+ ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
262
+
263
+ -- Create policies
264
+ CREATE POLICY &quot;Sites visible to users with access&quot; ON docbuilder_sites
265
+ FOR SELECT USING (
266
+ id IN (
267
+ SELECT site_id FROM docbuilder_access
268
+ WHERE user_id = auth.uid()
269
+ )
270
+ );
271
+
272
+ CREATE POLICY &quot;Access visible to own user&quot; ON docbuilder_access
273
+ FOR SELECT USING (user_id = auth.uid());
275
274
  </code></pre>
276
- <p>Default credentials for preset:</p>
277
- <ul>
278
- <li>Username: <code>admin</code></li>
279
- <li>Password: <code>docs2025</code></li>
280
- </ul>
281
- <h4>3. Command Line</h4>
282
- <p>Disable authentication for a specific build:</p>
283
- <pre><code class="language-bash">npx @knowcode/doc-builder@latest build --no-auth
275
+ <h3>Step 4: Add Your Site</h3>
276
+ <pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name)
277
+ VALUES (&#39;your-domain.com&#39;, &#39;Your Documentation Name&#39;);
284
278
  </code></pre>
285
- <h3>Configuration Options</h3>
286
- <table>
287
- <thead>
288
- <tr>
289
- <th>Option</th>
290
- <th>Type</th>
291
- <th>Default</th>
292
- <th>Description</th>
293
- </tr>
294
- </thead>
295
- <tbody><tr>
296
- <td><code>features.authentication</code></td>
297
- <td>boolean</td>
298
- <td><code>false</code></td>
299
- <td>Enable/disable authentication</td>
300
- </tr>
301
- <tr>
302
- <td><code>auth.username</code></td>
303
- <td>string</td>
304
- <td><code>&#39;admin&#39;</code></td>
305
- <td>Login username</td>
306
- </tr>
307
- <tr>
308
- <td><code>auth.password</code></td>
309
- <td>string</td>
310
- <td><code>&#39;password&#39;</code></td>
311
- <td>Login password</td>
312
- </tr>
313
- </tbody></table>
314
- <h2>Usage</h2>
315
- <h3>For Site Administrators</h3>
316
- <ol>
317
- <li><strong>Set Credentials</strong>: Configure username/password in <code>doc-builder.config.js</code></li>
318
- <li><strong>Build Site</strong>: Run <code>npx @knowcode/doc-builder@latest build</code></li>
319
- <li><strong>Deploy</strong>: Upload to your hosting provider</li>
320
- <li><strong>Share Credentials</strong>: Provide login details to authorized users</li>
321
- </ol>
322
- <h3>For End Users</h3>
323
- <ol>
324
- <li><strong>Visit Site</strong>: Navigate to any documentation page</li>
325
- <li><strong>Login</strong>: Enter username and password on login page</li>
326
- <li><strong>Browse</strong>: Access all documentation pages</li>
327
- <li><strong>Logout</strong>: Click logout link in header (when available)</li>
328
- </ol>
329
- <h2>Security Considerations</h2>
330
- <h3><i class="ph ph-warning-circle" aria-label="warning"></i> Important Warnings</h3>
331
- <ol>
332
- <li><strong>Client-Side Only</strong>: Authentication happens in the browser, making it unsuitable for truly sensitive data</li>
333
- <li><strong>Visible Credentials</strong>: Username/password are embedded in JavaScript and visible to anyone who views page source</li>
334
- <li><strong>No Server Validation</strong>: Any user who knows the credentials can access the site</li>
335
- <li><strong>Static Files</strong>: All documentation files are still publicly accessible if URLs are known</li>
336
- </ol>
337
- <h3>When to Use</h3>
338
- <p><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Good for:</strong></p>
339
- <ul>
340
- <li>Internal team documentation</li>
341
- <li>Preview deployments</li>
342
- <li>Casual access control</li>
343
- <li>Preventing search engine indexing</li>
344
- <li>Client presentations</li>
345
- </ul>
346
- <p><i class="ph ph-x-circle" aria-label="error"></i> <strong>Not suitable for:</strong></p>
279
+ <p>Note the returned ID - this is your <code>siteId</code> for the config.</p>
280
+ <h3>Step 5: Create Users</h3>
281
+ <p>Users can sign up through Supabase Auth, or you can create them:</p>
282
+ <pre><code class="language-sql">-- In Supabase dashboard, go to Authentication &gt; Users
283
+ -- Click &quot;Invite user&quot; and enter their email
284
+ </code></pre>
285
+ <h3>Step 6: Grant Access</h3>
286
+ <pre><code class="language-sql">-- Grant user access to your site
287
+ INSERT INTO docbuilder_access (user_id, site_id)
288
+ VALUES (
289
+ (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;),
290
+ &#39;your-site-id&#39;
291
+ );
292
+ </code></pre>
293
+ <h2>Deployment</h2>
294
+ <h3>Build with Authentication</h3>
295
+ <pre><code class="language-bash"># Build with auth enabled (reads from config)
296
+ npx @knowcode/doc-builder build
297
+
298
+ # Build without auth (override config)
299
+ npx @knowcode/doc-builder build --no-auth
300
+ </code></pre>
301
+ <h3>Deploy to Vercel</h3>
302
+ <pre><code class="language-bash"># Deploy with auth
303
+ npx @knowcode/doc-builder deploy
304
+
305
+ # Deploy public site
306
+ npx @knowcode/doc-builder deploy --no-auth
307
+ </code></pre>
308
+ <h2>User Management</h2>
309
+ <h3>CLI Commands (Future)</h3>
310
+ <pre><code class="language-bash"># Add user to site
311
+ npx @knowcode/doc-builder auth:grant --email user@example.com --site-id xxx
312
+
313
+ # Remove user access
314
+ npx @knowcode/doc-builder auth:revoke --email user@example.com --site-id xxx
315
+
316
+ # List users with access
317
+ npx @knowcode/doc-builder auth:list-users --site-id xxx
318
+ </code></pre>
319
+ <h3>Manual Management</h3>
320
+ <p>Use Supabase dashboard or SQL commands to manage users and access.</p>
321
+ <h2>Security Features</h2>
322
+ <h3>What Supabase Provides</h3>
347
323
  <ul>
348
- <li>Highly confidential information</li>
349
- <li>Personal data (GDPR/privacy)</li>
350
- <li>Financial or legal documents</li>
351
- <li>Source code or API keys</li>
352
- <li>Medical records</li>
324
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>JWT Authentication</strong>: Industry-standard secure tokens</li>
325
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Password Hashing</strong>: bcrypt with salt</li>
326
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Row Level Security</strong>: Database-level access control</li>
327
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Session Management</strong>: Automatic token refresh</li>
328
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Multi-Factor Auth</strong>: Optional 2FA support</li>
329
+ <li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>OAuth Providers</strong>: Google, GitHub, etc. (optional)</li>
353
330
  </ul>
354
331
  <h3>Security Best Practices</h3>
355
332
  <ol>
356
- <li><strong>Use HTTPS</strong>: Always deploy to HTTPS-enabled hosting</li>
357
- <li><strong>Strong Passwords</strong>: Use complex, unique passwords</li>
358
- <li><strong>Regular Updates</strong>: Change credentials periodically</li>
359
- <li><strong>Monitor Access</strong>: Check hosting logs for unusual activity</li>
360
- <li><strong>Consider Alternatives</strong>: For sensitive data, use server-side authentication</li>
361
- </ol>
362
- <h2>Implementation Details</h2>
363
- <h3>Generated Files</h3>
364
- <p>When authentication is enabled, doc-builder creates:</p>
365
- <ol>
366
- <li><strong>login.html</strong> - Login page with form</li>
367
- <li><strong>logout.html</strong> - Logout confirmation page </li>
368
- <li><strong>auth.js</strong> - Authentication check script (included on all pages)</li>
333
+ <li><p><strong>Use environment variables</strong> for sensitive config:</p>
334
+ <pre><code class="language-javascript">auth: {
335
+ supabaseUrl: process.env.SUPABASE_URL,
336
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
337
+ siteId: process.env.DOC_SITE_ID
338
+ }
339
+ </code></pre>
340
+ </li>
341
+ <li><p><strong>Enable RLS policies</strong> on all tables</p>
342
+ </li>
343
+ <li><p><strong>Regular access audits</strong> - review who has access</p>
344
+ </li>
345
+ <li><p><strong>Use custom domains</strong> for professional appearance</p>
346
+ </li>
347
+ <li><p><strong>Monitor usage</strong> in Supabase dashboard</p>
348
+ </li>
369
349
  </ol>
370
- <h3>Cookie Format</h3>
371
- <p>The authentication cookie:</p>
372
- <ul>
373
- <li>Name: <code>doc-auth</code></li>
374
- <li>Value: Base64-encoded <code>username:password</code></li>
375
- <li>Path: <code>/</code> (entire site)</li>
376
- <li>Expiry: Session (until browser closed)</li>
377
- </ul>
378
- <h3>Customization</h3>
379
- <p>The login/logout pages use the same CSS as your documentation, inheriting your site&#39;s theme and styling.</p>
380
350
  <h2>Troubleshooting</h2>
381
351
  <h3>Common Issues</h3>
382
- <p><strong>Users get logged out frequently</strong></p>
383
- <ul>
384
- <li>Session cookies expire when browser closes</li>
385
- <li>Consider implementing &quot;remember me&quot; functionality</li>
386
- </ul>
387
- <p><strong>Login page shows but credentials don&#39;t work</strong></p>
352
+ <p><strong>Users can&#39;t log in</strong></p>
388
353
  <ul>
389
- <li>Verify credentials in config match exactly (case-sensitive)</li>
390
- <li>Check browser console for JavaScript errors</li>
391
- <li>Ensure cookies are enabled</li>
354
+ <li>Verify Supabase project is active</li>
355
+ <li>Check credentials are correct</li>
356
+ <li>Ensure user exists in auth.users</li>
357
+ <li>Verify site domain matches configuration</li>
392
358
  </ul>
393
- <p><strong>Some pages accessible without login</strong></p>
359
+ <p><strong>Content flashes before redirect</strong></p>
394
360
  <ul>
395
- <li>Verify all HTML pages include auth.js</li>
396
- <li>Check for direct file access (PDFs, images)</li>
397
- <li>Ensure no pages exclude authentication script</li>
361
+ <li>This is fixed in latest versions</li>
362
+ <li>Ensure you&#39;re using @knowcode/doc-builder v1.7.4+</li>
398
363
  </ul>
399
- <p><strong>Login redirects to wrong page</strong></p>
364
+ <p><strong>Access denied after login</strong></p>
400
365
  <ul>
401
- <li>Check redirect parameter handling</li>
402
- <li>Verify relative vs absolute URLs</li>
366
+ <li>Check user has entry in docbuilder_access table</li>
367
+ <li>Verify site_id matches your configuration</li>
368
+ <li>Check RLS policies are correctly set up</li>
403
369
  </ul>
404
- <h3>Debug Mode</h3>
405
- <p>Check browser developer console for:</p>
406
- <ul>
407
- <li>Cookie values</li>
408
- <li>Redirect URLs </li>
409
- <li>JavaScript errors</li>
410
- <li>Network requests</li>
411
- </ul>
412
- <h2>Alternatives</h2>
413
- <p>For more robust authentication, consider:</p>
370
+ <h3>Debug Checklist</h3>
414
371
  <ol>
415
- <li><strong>Vercel Authentication</strong> - Built-in password protection</li>
416
- <li><strong>Netlify Identity</strong> - User management service</li>
417
- <li><strong>Auth0</strong> - Full authentication platform</li>
418
- <li><strong>Cloudflare Access</strong> - Zero-trust security</li>
419
- <li><strong>Basic Auth</strong> - Server-level protection</li>
372
+ <li>Check browser console for errors</li>
373
+ <li>Verify JWT token in browser DevTools &gt; Application &gt; Storage</li>
374
+ <li>Test Supabase connection separately</li>
375
+ <li>Check network tab for API calls</li>
376
+ <li>Verify domain in database matches deployment</li>
420
377
  </ol>
421
- <h2>Example Implementation</h2>
422
- <h3>Simple Protected Docs</h3>
423
- <pre><code class="language-javascript">// doc-builder.config.js
424
- module.exports = {
425
- siteName: &#39;@knowcode/doc-builder&#39;,
426
- features: {
427
- authentication: true
428
- },
429
- auth: {
430
- username: &#39;team&#39;,
431
- password: &#39;handbook2025&#39;
432
- }
433
- };
434
- </code></pre>
435
- <h3>Build and Deploy</h3>
436
- <pre><code class="language-bash"># Build with authentication
437
- npx @knowcode/doc-builder@latest build
438
-
439
- # Deploy to Vercel
440
- npx @knowcode/doc-builder@latest deploy
378
+ <h2>Migration from Old Auth</h2>
379
+ <p>If you were using the old authentication system:</p>
380
+ <ol>
381
+ <li><p><strong>Remove old config</strong>:</p>
382
+ <pre><code class="language-javascript">// Remove this:
383
+ auth: {
384
+ username: &#39;admin&#39;,
385
+ password: &#39;password&#39;
386
+ }
441
387
  </code></pre>
442
- <h3>User Instructions</h3>
443
- <p>Email to team:</p>
444
- <pre><code>Our documentation is now available at:
445
- https://docs.example.com
446
-
447
- Login credentials:
448
- Username: team
449
- Password: handbook2025
450
-
451
- Please bookmark the site after logging in.
388
+ </li>
389
+ <li><p><strong>Set up Supabase</strong> following this guide</p>
390
+ </li>
391
+ <li><p><strong>Update config</strong> to use Supabase:</p>
392
+ <pre><code class="language-javascript">features: {
393
+ authentication: &#39;supabase&#39;
394
+ }
452
395
  </code></pre>
396
+ </li>
397
+ </ol>
453
398
  <h2>Conclusion</h2>
454
- <p>The authentication feature in @knowcode/doc-builder provides a simple way to add basic access control to your documentation. While not suitable for highly sensitive information, it&#39;s perfect for internal docs, client previews, and casual protection needs.</p>
455
- <p>Remember: For production use with sensitive data, always implement proper server-side authentication with your hosting provider.</p>
456
- <hr>
457
- <h2>Document History</h2>
458
- <table>
459
- <thead>
460
- <tr>
461
- <th>Date</th>
462
- <th>Version</th>
463
- <th>Author</th>
464
- <th>Changes</th>
465
- </tr>
466
- </thead>
467
- <tbody><tr>
468
- <td>2025-07-21</td>
469
- <td>1.0</td>
470
- <td>System</td>
471
- <td>Initial authentication guide</td>
472
- </tr>
473
- </tbody></table>
399
+ <p>Supabase authentication provides enterprise-grade security for your documentation while maintaining ease of use. With proper setup, you get secure, scalable authentication that grows with your needs.</p>
400
+ <p>For public documentation that doesn&#39;t need authentication, simply set <code>authentication: false</code> or use the <code>--no-auth</code> flag during build/deploy.</p>
474
401
 
475
402
  </div>
476
403
  </main>