@knowcode/doc-builder 1.9.20 → 1.9.21

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 (86) hide show
  1. package/cli.js +15 -1
  2. package/doc-builder.config.js +4 -2
  3. package/doc-builder.config.js.backup.1754567425847 +124 -0
  4. package/html/README.html +3 -3
  5. package/html/about-doc-builder.html +3 -3
  6. package/html/documentation-index.html +3 -3
  7. package/html/guides/authentication-default-change.html +3 -3
  8. package/html/guides/authentication-guide.html +3 -3
  9. package/html/guides/claude-workflow-guide.html +3 -3
  10. package/html/guides/configuration-guide.html +3 -3
  11. package/html/guides/documentation-standards.html +3 -3
  12. package/html/guides/html-embedding-guide.html +3 -3
  13. package/html/guides/image-modal-guide.html +3 -3
  14. package/html/guides/phosphor-icons-guide.html +3 -3
  15. package/html/guides/private-directory-authentication-troubleshooting.html +3 -3
  16. package/html/guides/private-directory-authentication.html +3 -3
  17. package/html/guides/public-site-deployment.html +3 -3
  18. package/html/guides/search-engine-verification-guide.html +3 -3
  19. package/html/guides/seo-guide.html +3 -3
  20. package/html/guides/seo-optimization-guide.html +3 -3
  21. package/html/guides/supabase-authentication-complete-guide.html +3 -3
  22. package/html/guides/troubleshooting-guide.html +3 -3
  23. package/html/guides/windows-setup-guide.html +3 -3
  24. package/html/image-modal-test.html +3 -3
  25. package/html/index.html +3 -3
  26. package/html/private/cache-control-anti-pattern.html +3 -3
  27. package/html/private/launch/README.html +3 -3
  28. package/html/private/launch/auth-cleanup-summary.html +3 -3
  29. package/html/private/launch/bubble-plugin-specification.html +3 -3
  30. package/html/private/launch/go-to-market-strategy.html +3 -3
  31. package/html/private/launch/launch-announcements.html +3 -3
  32. package/html/private/launch/vercel-deployment-auth-setup.html +3 -3
  33. package/html/private/next-steps-walkthrough.html +3 -3
  34. package/html/private/supabase-auth-implementation-completed.html +3 -3
  35. package/html/private/supabase-auth-implementation-plan.html +3 -3
  36. package/html/private/supabase-auth-integration-plan.html +3 -3
  37. package/html/private/supabase-auth-setup-guide.html +3 -3
  38. package/html/private/test-private-doc.html +3 -3
  39. package/html/private/user-management-tooling.html +3 -3
  40. package/html/prompts/beautiful-documentation-design.html +3 -3
  41. package/html/prompts/markdown-document-standards.html +3 -3
  42. package/html/prompts/project-rename-strategy-sasha-publish.html +3 -3
  43. package/html/sitemap.xml +59 -59
  44. package/html/test-questions/how-does-it-work%3F.html +3 -3
  45. package/html/test-questions/step-1%3A%20getting-started.html +3 -3
  46. package/html/test-questions/what-is-the-purpose.html +3 -3
  47. package/html/vercel-cli-setup-guide.html +3 -3
  48. package/html/vercel-first-time-setup-guide.html +3 -3
  49. package/html-static/404.html +115 -0
  50. package/html-static/README.html +456 -0
  51. package/html-static/about-doc-builder.html +425 -0
  52. package/html-static/css/notion-style.css +2426 -0
  53. package/html-static/documentation-index.html +405 -0
  54. package/html-static/guides/authentication-default-change.html +304 -0
  55. package/html-static/guides/authentication-guide.html +443 -0
  56. package/html-static/guides/claude-workflow-guide.html +1008 -0
  57. package/html-static/guides/configuration-guide.html +406 -0
  58. package/html-static/guides/documentation-standards.html +628 -0
  59. package/html-static/guides/html-embedding-guide.html +395 -0
  60. package/html-static/guides/image-modal-guide.html +449 -0
  61. package/html-static/guides/phosphor-icons-guide.html +518 -0
  62. package/html-static/guides/private-directory-authentication-troubleshooting.html +489 -0
  63. package/html-static/guides/private-directory-authentication.html +475 -0
  64. package/html-static/guides/public-site-deployment.html +365 -0
  65. package/html-static/guides/search-engine-verification-guide.html +476 -0
  66. package/html-static/guides/seo-guide.html +595 -0
  67. package/html-static/guides/seo-optimization-guide.html +821 -0
  68. package/html-static/guides/supabase-authentication-complete-guide.html +800 -0
  69. package/html-static/guides/troubleshooting-guide.html +567 -0
  70. package/html-static/guides/windows-setup-guide.html +793 -0
  71. package/html-static/image-modal-test.html +252 -0
  72. package/html-static/index.html +456 -0
  73. package/html-static/js/main.js +1692 -0
  74. package/html-static/prompts/beautiful-documentation-design.html +718 -0
  75. package/html-static/prompts/markdown-document-standards.html +356 -0
  76. package/html-static/prompts/project-rename-strategy-sasha-publish.html +464 -0
  77. package/html-static/robots.txt +5 -0
  78. package/html-static/sitemap.xml +189 -0
  79. package/html-static/test-questions/how-does-it-work%3F.html +228 -0
  80. package/html-static/test-questions/step-1%3A%20getting-started.html +223 -0
  81. package/html-static/test-questions/what-is-the-purpose.html +227 -0
  82. package/html-static/vercel-cli-setup-guide.html +429 -0
  83. package/html-static/vercel-first-time-setup-guide.html +388 -0
  84. package/lib/config.js +9 -2
  85. package/lib/core-builder.js +148 -4
  86. package/package.json +1 -1
@@ -0,0 +1,800 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="description" content="A comprehensive guide to implementing enterprise-grade authentication in @knowcode/doc-builder using Supabase.">
7
+ <title>Complete Supabase Authentication Guide</title>
8
+
9
+ <meta name="generator" content="@knowcode/doc-builder by Knowcode Ltd">
10
+ <meta name="author" content="Lindsay Smith">
11
+ <meta name="keywords" content="documentation, markdown, static site generator, vercel, notion-style, authentication, supabase">
12
+ <meta name="robots" content="index, follow">
13
+ <link rel="canonical" href="https://doc-builder-delta.vercel.app/guides/supabase-authentication-complete-guide.html">
14
+
15
+ <!-- Open Graph / Facebook -->
16
+ <meta property="og:type" content="article">
17
+ <meta property="og:url" content="https://doc-builder-delta.vercel.app/guides/supabase-authentication-complete-guide.html">
18
+ <meta property="og:title" content="Complete Supabase Authentication Guide">
19
+ <meta property="og:description" content="A comprehensive guide to implementing enterprise-grade authentication in @knowcode/doc-builder using Supabase.">
20
+ <meta property="og:image" content="https://doc-builder-delta.vercel.app/og-default.png">
21
+ <meta property="og:site_name" content="@knowcode/doc-builder">
22
+ <meta property="og:locale" content="en_US">
23
+
24
+ <!-- Twitter Card -->
25
+ <meta name="twitter:card" content="summary_large_image">
26
+ <meta name="twitter:site" content="@planbbackups">
27
+ <meta name="twitter:creator" content="@planbbackups">
28
+ <meta name="twitter:title" content="Complete Supabase Authentication Guide">
29
+ <meta name="twitter:description" content="A comprehensive guide to implementing enterprise-grade authentication in @knowcode/doc-builder using Supabase.">
30
+ <meta name="twitter:image" content="https://doc-builder-delta.vercel.app/og-default.png">
31
+
32
+ <!-- Custom Meta Tags -->
33
+ <meta name="google-site-verification" content="FtzcDTf5BQ9K5EfnGazQkgU2U4FiN3ITzM7gHwqUAqQ">
34
+ <meta name="msvalidate.01" content="B2D8C4C12C530D47AA962B24CAA09630">
35
+
36
+ <!-- Fonts -->
37
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
38
+
39
+ <!-- Icons -->
40
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
41
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@phosphor-icons/web@2.1.1/src/regular/style.css">
42
+
43
+ <!-- Mermaid -->
44
+ <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
45
+
46
+ <!-- Styles -->
47
+ <link rel="stylesheet" href="/css/notion-style.css">
48
+
49
+
50
+
51
+ <!-- Favicon -->
52
+ <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>✨</text></svg>">
53
+
54
+ <script type="application/ld+json">
55
+ {
56
+ "@context": "https://schema.org",
57
+ "@type": "TechArticle",
58
+ "headline": "Complete Supabase Authentication Guide",
59
+ "description": "A comprehensive guide to implementing enterprise-grade authentication in @knowcode/doc-builder using Supabase.",
60
+ "author": {
61
+ "@type": "Person",
62
+ "name": "Lindsay Smith"
63
+ },
64
+ "publisher": {
65
+ "@type": "Organization",
66
+ "name": "Knowcode Ltd",
67
+ "url": "https://knowcode.tech"
68
+ },
69
+ "datePublished": "2025-08-07T11:50:26.090Z",
70
+ "dateModified": "2025-08-07T11:50:26.090Z",
71
+ "mainEntityOfPage": {
72
+ "@type": "WebPage",
73
+ "@id": "https://doc-builder-delta.vercel.app/guides/supabase-authentication-complete-guide.html"
74
+ },
75
+ "breadcrumb": {
76
+ "@type": "BreadcrumbList",
77
+ "itemListElement": [
78
+ {
79
+ "@type": "ListItem",
80
+ "position": 1,
81
+ "name": "@knowcode/doc-builder",
82
+ "item": "https://doc-builder-delta.vercel.app"
83
+ },
84
+ {
85
+ "@type": "ListItem",
86
+ "position": 2,
87
+ "name": "Guides",
88
+ "item": "https://doc-builder-delta.vercel.app/guides/"
89
+ },
90
+ {
91
+ "@type": "ListItem",
92
+ "position": 3,
93
+ "name": "Supabase Authentication Complete Guide",
94
+ "item": "https://doc-builder-delta.vercel.app/guides/supabase-authentication-complete-guide.html"
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ </script>
100
+ </head>
101
+ <body>
102
+ <!-- Header -->
103
+ <header class="header">
104
+ <div class="header-content">
105
+ <a href="/index.html" class="logo">@knowcode/doc-builder</a>
106
+
107
+ <div class="header-actions">
108
+ <div class="deployment-info">
109
+ <span class="deployment-date" title="Built with doc-builder v1.9.20">Last updated: Aug 7, 2025, 11:50 AM UTC</span>
110
+ </div>
111
+
112
+
113
+
114
+ <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
115
+ <i class="fas fa-moon"></i>
116
+ </button>
117
+
118
+ <button id="menu-toggle" class="menu-toggle" aria-label="Toggle menu">
119
+ <i class="fas fa-bars"></i>
120
+ </button>
121
+ </div>
122
+ </div>
123
+ </header>
124
+
125
+
126
+
127
+ <!-- Breadcrumbs -->
128
+ <nav class="breadcrumbs" id="breadcrumbs">
129
+ <!-- Breadcrumbs will be generated by JavaScript -->
130
+ </nav>
131
+
132
+ <!-- Main Content -->
133
+ <div class="main-wrapper">
134
+ <!-- Sidebar -->
135
+ <aside class="sidebar">
136
+ <div class="sidebar-header">
137
+ <div class="filter-box">
138
+ <input type="text" placeholder="Search menu..." class="filter-input" id="nav-filter">
139
+ <i class="fas fa-search filter-icon"></i>
140
+ </div>
141
+ </div>
142
+ <nav class="navigation">
143
+
144
+ <div class="nav-section" data-level="0">
145
+ <a class="nav-title toggle-all-nav expanded" href="#" id="nav-toggle-all" title="Collapse/Expand All">
146
+ <i class="ph ph-caret-down" id="toggle-all-icon"></i> Documentation
147
+ </a>
148
+ <div class="nav-content">
149
+ <a href="/README.html" class="nav-item" data-tooltip="@knowcode/doc-builder."><i class="ph ph-file-text"></i> Overview</a>
150
+ <a href="/about-doc-builder.html" class="nav-item" data-tooltip="About @knowcode/doc-builder."><i class="ph ph-check-circle" style="color: #059669;"></i> About Doc Builder</a>
151
+ <a href="/documentation-index.html" class="nav-item" data-tooltip="This directory contains additional documentation for the @knowcode/doc-builder project, organized by topic and purpose."><i class="ph ph-pencil-simple" style="color: #d97706;"></i> Documentation Index</a>
152
+ <a href="/image-modal-test.html" class="nav-item" data-tooltip="This document tests the new image modal functionality in doc-builder."><i class="ph ph-file-text"></i> Image Modal Test</a>
153
+ <a href="/vercel-cli-setup-guide.html" class="nav-item" data-tooltip="This guide provides comprehensive instructions for installing the Vercel CLI across different operating systems."><i class="ph ph-check-circle" style="color: #059669;"></i> Vercel Cli Setup Guide</a>
154
+ <a href="/vercel-first-time-setup-guide.html" class="nav-item" data-tooltip="This guide walks you through the Vercel deployment process when using ."><i class="ph ph-check-circle" style="color: #059669;"></i> Vercel First Time Setup Guide</a></div></div>
155
+ <div class="nav-section" data-level="1">
156
+ <a class="nav-title collapsible expanded" href="#" data-target="nav-guides-1" >
157
+ <i class="ph ph-caret-right collapse-icon"></i><i class="ph ph-book"></i> Guides
158
+ </a>
159
+ <div class="nav-content" id="nav-guides-1">
160
+ <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="ph ph-file-text"></i> Authentication Default Change</a>
161
+ <a href="/guides/authentication-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform."><i class="ph ph-check-circle" style="color: #059669;"></i> Authentication Guide</a>
162
+ <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="ph ph-pencil-simple" style="color: #d97706;"></i> Claude Workflow Guide</a>
163
+ <a href="/guides/configuration-guide.html" class="nav-item" data-tooltip="This guide explains how @knowcode/doc-builder handles configuration files and settings."><i class="ph ph-check-circle" style="color: #059669;"></i> Configuration Guide</a>
164
+ <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="ph ph-pencil-simple" style="color: #d97706;"></i> Documentation Standards</a>
165
+ <a href="/guides/html-embedding-guide.html" class="nav-item" data-tooltip="Starting from version 1.9.2, doc-builder treats HTML files ( and ) as attachments that are automatically copied to your output directory during the..."><i class="ph ph-check-circle" style="color: #059669;"></i> Html Embedding Guide</a>
166
+ <a href="/guides/image-modal-guide.html" class="nav-item" data-tooltip="When users click on any image in your generated documentation, it opens in a professional modal overlay with: Full-screen viewing experience Smooth..."><i class="ph ph-check-circle" style="color: #059669;"></i> Image Modal Guide</a>
167
+ <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="ph ph-pencil-simple" style="color: #d97706;"></i> Phosphor Icons Guide</a>
168
+ <a href="/guides/private-directory-authentication.html" class="nav-item" data-tooltip="The @knowcode/doc-builder provides flexible authentication options to protect your documentation."><i class="ph ph-check-circle" style="color: #059669;"></i> Private Directory Authentication</a>
169
+ <a href="/guides/private-directory-authentication-troubleshooting.html" class="nav-item" data-tooltip="Private Directory Authentication Troubleshooting."><i class="ph ph-check-circle" style="color: #059669;"></i> Private Directory Authentication Troubleshooting</a>
170
+ <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="ph ph-check-circle" style="color: #059669;"></i> Public Site Deployment</a>
171
+ <a href="/guides/search-engine-verification-guide.html" class="nav-item" data-tooltip="Search engine verification provides access to powerful webmaster tools:."><i class="ph ph-check-circle" style="color: #059669;"></i> Search Engine Verification Guide</a>
172
+ <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="ph ph-check-circle" style="color: #059669;"></i> Seo Guide</a>
173
+ <a href="/guides/seo-optimization-guide.html" class="nav-item" data-tooltip="Comprehensive guide to optimizing documentation for search engines. Learn SEO best practices, use built-in features, and improve your rankings."><i class="ph ph-check-circle" style="color: #059669;"></i> SEO Optimization Guide for @knowcode/doc-builder</a>
174
+ <a href="/guides/supabase-authentication-complete-guide.html" class="nav-item active" data-tooltip="@knowcode/doc-builder includes built-in Supabase authentication that provides enterprise-grade security with zero configuration."><i class="ph ph-check-circle" style="color: #059669;"></i> Supabase Authentication Complete Guide</a>
175
+ <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="ph ph-check-circle" style="color: #059669;"></i> Troubleshooting Guide</a>
176
+ <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="ph ph-check-circle" style="color: #059669;"></i> Windows Setup Guide</a></div></div>
177
+ <div class="nav-section" data-level="1">
178
+ <a class="nav-title collapsible" href="#" data-target="nav-prompts-1" >
179
+ <i class="ph ph-caret-right collapse-icon"></i><i class="ph ph-chat-circle-dots"></i> Prompts
180
+ </a>
181
+ <div class="nav-content collapsed" id="nav-prompts-1">
182
+ <a href="/prompts/beautiful-documentation-design.html" class="nav-item" data-tooltip="🎨 Beautiful Documentation Design Guide."><i class="ph ph-check-circle" style="color: #059669;"></i> Beautiful Documentation Design</a>
183
+ <a href="/prompts/markdown-document-standards.html" class="nav-item" data-tooltip="Detailed introduction to the topic..."><i class="ph ph-pencil-simple" style="color: #d97706;"></i> Markdown Document Standards</a>
184
+ <a href="/prompts/project-rename-strategy-sasha-publish.html" class="nav-item" data-tooltip="This document outlines the comprehensive strategy for renaming the @knowcode/doc-builder project to &quot;sasha-publish&quot;, including all package references,..."><i class="ph ph-x-circle" style="color: #dc2626;"></i> Project Rename Strategy Sasha Publish</a></div></div>
185
+ <div class="nav-section" data-level="1">
186
+ <a class="nav-title collapsible" href="#" data-target="nav-test-questions-1" >
187
+ <i class="ph ph-caret-right collapse-icon"></i><i class="ph ph-folder"></i> Test Questions
188
+ </a>
189
+ <div class="nav-content collapsed" id="nav-test-questions-1">
190
+ <a href="/test-questions/how-does-it-work%3F.html" class="nav-item" data-tooltip="This is a test file to verify that question marks work properly in filenames."><i class="ph ph-file-text"></i> How Does It Work?</a>
191
+ <a href="/test-questions/step-1%3A%20getting-started.html" class="nav-item" data-tooltip="Step 1: Getting Started."><i class="ph ph-file-text"></i> Step 1: Getting Started</a>
192
+ <a href="/test-questions/what-is-the-purpose.html" class="nav-item" data-tooltip="Understanding the purpose of our documentation system"><i class="ph ph-file-text"></i> What Is The Purpose?</a></div></div>
193
+ </nav>
194
+ <div class="resize-handle"></div>
195
+ </aside>
196
+
197
+ <!-- Content Area -->
198
+ <main class="content">
199
+ <div class="content-inner">
200
+ <h1>Complete Supabase Authentication Guide</h1>
201
+ <p>A comprehensive guide to implementing enterprise-grade authentication in @knowcode/doc-builder using Supabase.</p>
202
+ <h2>Table of Contents</h2>
203
+ <ul>
204
+ <li><a href="#overview">Overview</a></li>
205
+ <li><a href="#how-it-works">How It Works</a></li>
206
+ <li><a href="#authentication-modes">Authentication Modes</a></li>
207
+ <li><a href="#quick-setup">Quick Setup</a></li>
208
+ <li><a href="#database-setup">Database Setup</a></li>
209
+ <li><a href="#user-management">User Management</a></li>
210
+ <li><a href="#security-features">Security Features</a></li>
211
+ <li><a href="#configuration-options">Configuration Options</a></li>
212
+ <li><a href="#troubleshooting">Troubleshooting</a></li>
213
+ <li><a href="#advanced-topics">Advanced Topics</a></li>
214
+ </ul>
215
+ <h2>Overview</h2>
216
+ <p>@knowcode/doc-builder includes built-in <strong>Supabase authentication</strong> that provides enterprise-grade security with zero configuration. The system uses JWT tokens, domain-based access control, and automatic session management to protect your documentation.</p>
217
+ <h3>Why Supabase?</h3>
218
+ <table>
219
+ <thead>
220
+ <tr>
221
+ <th>Feature</th>
222
+ <th>Benefit</th>
223
+ </tr>
224
+ </thead>
225
+ <tbody><tr>
226
+ <td><i style="font-size: 1.2em" class="ph ph-lock-key" aria-label="secure"></i> <strong>Enterprise Security</strong></td>
227
+ <td>JWT tokens, bcrypt password hashing, Row Level Security</td>
228
+ </tr>
229
+ <tr>
230
+ <td><i style="font-size: 1.2em" class="ph ph-users" aria-label="team"></i> <strong>Scalable User Management</strong></td>
231
+ <td>Handles millions of users with fine-grained access control</td>
232
+ </tr>
233
+ <tr>
234
+ <td><i style="font-size: 1.2em" class="ph ph-globe-hemisphere-west" aria-label="world"></i> <strong>Global Infrastructure</strong></td>
235
+ <td>Built on PostgreSQL with worldwide edge locations</td>
236
+ </tr>
237
+ <tr>
238
+ <td><i style="font-size: 1.2em" class="ph ph-money" aria-label="money"></i> <strong>Generous Free Tier</strong></td>
239
+ <td>50,000 monthly active users at no cost</td>
240
+ </tr>
241
+ <tr>
242
+ <td><i style="font-size: 1.2em" class="ph ph-arrows-clockwise" aria-label="refresh"></i> <strong>Real-time Updates</strong></td>
243
+ <td>Live permission changes without restarts</td>
244
+ </tr>
245
+ <tr>
246
+ <td><i style="font-size: 1.2em" class="ph ph-shield" aria-label="security"></i> <strong>Built-in Security</strong></td>
247
+ <td>Multi-factor auth, OAuth providers, audit logs</td>
248
+ </tr>
249
+ </tbody></table>
250
+ <h2>How It Works</h2>
251
+ <p>The authentication system follows this flow:</p>
252
+ <div class="mermaid-wrapper">
253
+ <div class="mermaid">graph TD
254
+ A[User visits documentation page] --> B{Has valid JWT token?}
255
+ B -->|No| C[Redirect to login page]
256
+ B -->|Yes| D[Verify token with Supabase]
257
+
258
+ C --> E[User enters credentials]
259
+ E --> F[Authenticate with Supabase]
260
+ F --> G{Valid credentials?}
261
+ G -->|No| H[Show error message]
262
+ G -->|Yes| I[Issue JWT token]
263
+
264
+ I --> J[Check domain access in database]
265
+ D --> J
266
+
267
+ J --> K{User has access to domain?}
268
+ K -->|Yes| L[Show protected content]
269
+ K -->|No| M[Show access denied page]
270
+
271
+ style A fill:#e1f5fe
272
+ style L fill:#c8e6c9
273
+ style M fill:#ffcdd2
274
+ style H fill:#ffcdd2</div>
275
+ </div>
276
+ <h3>Technical Architecture</h3>
277
+ <ol>
278
+ <li><strong>Client-Side Check</strong>: JavaScript checks for valid JWT token on page load</li>
279
+ <li><strong>Supabase Verification</strong>: Token verified against Supabase auth service</li>
280
+ <li><strong>Domain-Based Access</strong>: User access checked against <code>docbuilder_access</code> table</li>
281
+ <li><strong>Content Display</strong>: Protected content shown only to authorized users</li>
282
+ <li><strong>Session Management</strong>: Automatic token refresh and session persistence</li>
283
+ </ol>
284
+ <h2>Authentication Modes</h2>
285
+ <p>@knowcode/doc-builder supports three authentication modes:</p>
286
+ <h3>1. <i style="font-size: 1.2em" class="ph ph-globe-hemisphere-west" aria-label="world"></i> Global Authentication</h3>
287
+ <p><strong>When to use</strong>: Entire documentation site requires login</p>
288
+ <pre><code class="language-javascript">// doc-builder.config.js
289
+ module.exports = {
290
+ features: {
291
+ authentication: &#39;supabase&#39; // Entire site protected
292
+ }
293
+ };
294
+ </code></pre>
295
+ <p><strong>Behavior</strong>:</p>
296
+ <ul>
297
+ <li>All pages require authentication</li>
298
+ <li>Redirects to login if not authenticated</li>
299
+ <li>Shows access denied if user lacks domain access</li>
300
+ </ul>
301
+ <h3>2. <i style="font-size: 1.2em" class="ph ph-folder" aria-label="folder"></i> Private Directory Authentication</h3>
302
+ <p><strong>When to use</strong>: Public docs with some private sections (most common)</p>
303
+ <pre><code class="language-bash"># Create private directory - authentication automatically enabled
304
+ mkdir docs/private
305
+ echo &quot;# Admin Documentation&quot; &gt; docs/private/admin-guide.md
306
+ </code></pre>
307
+ <p><strong>Behavior</strong>:</p>
308
+ <ul>
309
+ <li>Public pages accessible to everyone</li>
310
+ <li><code>/private/</code> folders require authentication</li>
311
+ <li>Seamless navigation between public and private content</li>
312
+ </ul>
313
+ <h3>3. <i style="font-size: 1.2em" class="ph ph-arrows-clockwise" aria-label="refresh"></i> Hybrid Mode</h3>
314
+ <p><strong>When to use</strong>: Complex access requirements</p>
315
+ <pre><code class="language-javascript">// doc-builder.config.js
316
+ module.exports = {
317
+ features: {
318
+ authentication: &#39;supabase&#39;, // Global auth enabled
319
+ privateDirectoryAuth: true // Also check private directories
320
+ }
321
+ };
322
+ </code></pre>
323
+ <p><strong>Behavior</strong>:</p>
324
+ <ul>
325
+ <li>Combines global and directory-based authentication</li>
326
+ <li>Granular control over different sections</li>
327
+ <li>Advanced user permission management</li>
328
+ </ul>
329
+ <h2>Quick Setup</h2>
330
+ <h3>Option 1: Zero Configuration (Recommended)</h3>
331
+ <p>The easiest way to get started - built-in credentials included:</p>
332
+ <pre><code class="language-bash"># 1. Create private content
333
+ mkdir docs/private
334
+ echo &quot;# Secret Documentation&quot; &gt; docs/private/admin.md
335
+
336
+ # 2. Deploy with authentication automatically enabled
337
+ npx @knowcode/doc-builder deploy
338
+
339
+ # 3. Add users in Supabase dashboard
340
+ # Visit your deployed site - authentication is ready!
341
+ </code></pre>
342
+ <h3>Option 2: Custom Configuration</h3>
343
+ <p>For advanced users who want to use their own Supabase project:</p>
344
+ <pre><code class="language-javascript">// doc-builder.config.js
345
+ module.exports = {
346
+ siteName: &#39;My Secure Docs&#39;,
347
+
348
+ features: {
349
+ authentication: &#39;supabase&#39;
350
+ },
351
+
352
+ auth: {
353
+ supabaseUrl: process.env.SUPABASE_URL || &#39;https://your-project.supabase.co&#39;,
354
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY || &#39;your-anon-key&#39;
355
+ }
356
+ };
357
+ </code></pre>
358
+ <h2>Database Setup</h2>
359
+ <h3>Automatic Setup (Built-in Project)</h3>
360
+ <p>If you&#39;re using the built-in Supabase project (recommended), the database is already configured. Skip to <a href="#user-management">User Management</a>.</p>
361
+ <h3>Manual Setup (Custom Project)</h3>
362
+ <p>If using your own Supabase project, run this SQL in the Supabase SQL editor:</p>
363
+ <pre><code class="language-sql">-- Create access control table
364
+ CREATE TABLE docbuilder_access (
365
+ user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
366
+ domain TEXT NOT NULL,
367
+ created_at TIMESTAMPTZ DEFAULT NOW(),
368
+ updated_at TIMESTAMPTZ DEFAULT NOW(),
369
+ PRIMARY KEY (user_id, domain)
370
+ );
371
+
372
+ -- Create indexes for performance
373
+ CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
374
+ CREATE INDEX idx_docbuilder_access_user_id ON docbuilder_access(user_id);
375
+
376
+ -- Enable Row Level Security
377
+ ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
378
+
379
+ -- RLS Policy: Users can only see their own access records
380
+ CREATE POLICY &quot;Users see own access&quot; ON docbuilder_access
381
+ FOR SELECT USING (user_id = auth.uid());
382
+
383
+ -- RLS Policy: Service role can manage all access
384
+ CREATE POLICY &quot;Service role manages access&quot; ON docbuilder_access
385
+ FOR ALL USING (current_setting(&#39;role&#39;) = &#39;service_role&#39;);
386
+
387
+ -- Create trigger to update timestamp
388
+ CREATE OR REPLACE FUNCTION update_updated_at_column()
389
+ RETURNS TRIGGER AS $
390
+ BEGIN
391
+ NEW.updated_at = NOW();
392
+ RETURN NEW;
393
+ END;
394
+ $ language &#39;plpgsql&#39;;
395
+
396
+ CREATE TRIGGER update_docbuilder_access_updated_at
397
+ BEFORE UPDATE ON docbuilder_access
398
+ FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
399
+ </code></pre>
400
+ <h3>Database Schema</h3>
401
+ <p>The authentication system uses a simple schema:</p>
402
+ <pre><code class="language-sql">-- Table: docbuilder_access
403
+ -- Purpose: Controls which users can access which documentation domains
404
+
405
+ Column Type Description
406
+ ----------- ----------- ----------------------------------
407
+ user_id UUID Reference to auth.users(id)
408
+ domain TEXT Domain name (e.g., docs.example.com)
409
+ created_at TIMESTAMPTZ When access was granted
410
+ updated_at TIMESTAMPTZ Last modified timestamp
411
+ </code></pre>
412
+ <h2>User Management</h2>
413
+ <h3>Creating Users</h3>
414
+ <p><strong>Option 1: Supabase Dashboard</strong></p>
415
+ <ol>
416
+ <li>Visit your Supabase project dashboard</li>
417
+ <li>Go to Authentication → Users</li>
418
+ <li>Click &quot;Invite user&quot;</li>
419
+ <li>Enter email address</li>
420
+ <li>User receives signup email</li>
421
+ </ol>
422
+ <p><strong>Option 2: User Self-Registration</strong><br>Users can sign up at your login page if enabled in Supabase settings.</p>
423
+ <h3>Granting Access</h3>
424
+ <p>Grant a user access to your documentation domain:</p>
425
+ <pre><code class="language-sql">-- Grant access to a single user
426
+ INSERT INTO docbuilder_access (user_id, domain)
427
+ VALUES (
428
+ (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;),
429
+ &#39;docs.example.com&#39;
430
+ );
431
+
432
+ -- Grant access to multiple users
433
+ INSERT INTO docbuilder_access (user_id, domain)
434
+ SELECT id, &#39;docs.example.com&#39;
435
+ FROM auth.users
436
+ WHERE email IN (
437
+ &#39;admin@example.com&#39;,
438
+ &#39;developer@example.com&#39;,
439
+ &#39;manager@example.com&#39;
440
+ );
441
+
442
+ -- Grant access to all existing users (be careful!)
443
+ INSERT INTO docbuilder_access (user_id, domain)
444
+ SELECT id, &#39;docs.example.com&#39; FROM auth.users;
445
+ </code></pre>
446
+ <h3>Revoking Access</h3>
447
+ <p>Remove a user&#39;s access to your documentation:</p>
448
+ <pre><code class="language-sql">-- Remove specific user access
449
+ DELETE FROM docbuilder_access
450
+ WHERE user_id = (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;)
451
+ AND domain = &#39;docs.example.com&#39;;
452
+
453
+ -- Remove all access for a domain (nuclear option)
454
+ DELETE FROM docbuilder_access WHERE domain = &#39;docs.example.com&#39;;
455
+ </code></pre>
456
+ <h3>Bulk User Management</h3>
457
+ <p><strong>Add users from CSV:</strong></p>
458
+ <pre><code class="language-sql">-- Create temporary table
459
+ CREATE TEMP TABLE user_emails (email TEXT);
460
+
461
+ -- Insert emails (replace with your list)
462
+ INSERT INTO user_emails VALUES
463
+ (&#39;user1@example.com&#39;),
464
+ (&#39;user2@example.com&#39;),
465
+ (&#39;user3@example.com&#39;);
466
+
467
+ -- Grant access to all
468
+ INSERT INTO docbuilder_access (user_id, domain)
469
+ SELECT u.id, &#39;docs.example.com&#39;
470
+ FROM auth.users u
471
+ JOIN user_emails e ON u.email = e.email;
472
+ </code></pre>
473
+ <p><strong>View all users with access:</strong></p>
474
+ <pre><code class="language-sql">SELECT
475
+ u.email,
476
+ u.created_at as user_created,
477
+ da.created_at as access_granted,
478
+ da.domain
479
+ FROM auth.users u
480
+ JOIN docbuilder_access da ON u.id = da.user_id
481
+ WHERE da.domain = &#39;docs.example.com&#39;
482
+ ORDER BY da.created_at DESC;
483
+ </code></pre>
484
+ <h2>Security Features</h2>
485
+ <h3>What&#39;s Included</h3>
486
+ <table>
487
+ <thead>
488
+ <tr>
489
+ <th>Security Feature</th>
490
+ <th>Implementation</th>
491
+ <th>Benefit</th>
492
+ </tr>
493
+ </thead>
494
+ <tbody><tr>
495
+ <td><strong>JWT Authentication</strong></td>
496
+ <td>Industry-standard tokens</td>
497
+ <td>Stateless, secure authentication</td>
498
+ </tr>
499
+ <tr>
500
+ <td><strong>Password Hashing</strong></td>
501
+ <td>bcrypt with salt</td>
502
+ <td>Passwords never stored in plaintext</td>
503
+ </tr>
504
+ <tr>
505
+ <td><strong>Row Level Security</strong></td>
506
+ <td>PostgreSQL RLS policies</td>
507
+ <td>Database-level access control</td>
508
+ </tr>
509
+ <tr>
510
+ <td><strong>Session Management</strong></td>
511
+ <td>Automatic token refresh</td>
512
+ <td>Seamless user experience</td>
513
+ </tr>
514
+ <tr>
515
+ <td><strong>HTTPS Only</strong></td>
516
+ <td>Enforced in production</td>
517
+ <td>Encrypted data transmission</td>
518
+ </tr>
519
+ <tr>
520
+ <td><strong>Domain Validation</strong></td>
521
+ <td>Runtime domain checking</td>
522
+ <td>Prevents unauthorized access</td>
523
+ </tr>
524
+ <tr>
525
+ <td><strong>Content Protection</strong></td>
526
+ <td>Client-side verification</td>
527
+ <td>No content served to unauthorized users</td>
528
+ </tr>
529
+ </tbody></table>
530
+ <h3>Security Best Practices</h3>
531
+ <ol>
532
+ <li><p><strong>Use Environment Variables</strong> (for custom projects):</p>
533
+ <pre><code class="language-bash"># .env.local
534
+ SUPABASE_URL=https://your-project.supabase.co
535
+ SUPABASE_ANON_KEY=your-anon-key
536
+ </code></pre>
537
+ </li>
538
+ <li><p><strong>Regular Access Audits</strong>:</p>
539
+ <pre><code class="language-sql">-- Review user access monthly
540
+ SELECT u.email, da.domain, da.created_at
541
+ FROM auth.users u
542
+ JOIN docbuilder_access da ON u.id = da.user_id
543
+ ORDER BY da.created_at DESC;
544
+ </code></pre>
545
+ </li>
546
+ <li><p><strong>Monitor Authentication Logs</strong>:</p>
547
+ <ul>
548
+ <li>Check Supabase dashboard for login attempts</li>
549
+ <li>Review failed authentication events</li>
550
+ <li>Set up alerts for suspicious activity</li>
551
+ </ul>
552
+ </li>
553
+ <li><p><strong>Custom Domain Setup</strong>:</p>
554
+ <pre><code class="language-bash"># Use professional domains for better security
555
+ https://docs.yourcompany.com # Good
556
+ https://random-string.vercel.app # Less secure
557
+ </code></pre>
558
+ </li>
559
+ </ol>
560
+ <h2>Configuration Options</h2>
561
+ <h3>Basic Configuration</h3>
562
+ <pre><code class="language-javascript">// doc-builder.config.js - Minimal setup
563
+ module.exports = {
564
+ features: {
565
+ authentication: &#39;supabase&#39; // Enable authentication
566
+ }
567
+ };
568
+ </code></pre>
569
+ <h3>Advanced Configuration</h3>
570
+ <pre><code class="language-javascript">// doc-builder.config.js - Full configuration
571
+ module.exports = {
572
+ siteName: &#39;Secure Documentation&#39;,
573
+ siteDescription: &#39;Private company documentation&#39;,
574
+
575
+ features: {
576
+ authentication: &#39;supabase&#39;, // Enable Supabase auth
577
+ privateDirectoryAuth: true, // Also protect /private/ directories
578
+ mermaid: true, // Enable diagrams
579
+ tooltips: true, // Enable tooltips
580
+ phosphorIcons: true // Use Phosphor icons
581
+ },
582
+
583
+ auth: {
584
+ // Optional: Use custom Supabase project
585
+ supabaseUrl: process.env.SUPABASE_URL,
586
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
587
+
588
+ // Optional: Custom login page settings
589
+ loginPageTitle: &#39;Access Documentation&#39;,
590
+ loginPageSubtitle: &#39;Enter your credentials to continue&#39;
591
+ },
592
+
593
+ // SEO settings work with authentication
594
+ seo: {
595
+ author: &#39;Your Company&#39;,
596
+ keywords: [&#39;documentation&#39;, &#39;secure&#39;, &#39;private&#39;],
597
+ ogImage: &#39;/images/og-secure.png&#39;
598
+ }
599
+ };
600
+ </code></pre>
601
+ <h3>Environment Variables</h3>
602
+ <pre><code class="language-bash"># .env.local - For custom Supabase projects
603
+ SUPABASE_URL=https://your-project.supabase.co
604
+ SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCI...
605
+
606
+ # Optional: Custom domain for authentication
607
+ AUTH_DOMAIN=docs.yourcompany.com
608
+ </code></pre>
609
+ <h2>Troubleshooting</h2>
610
+ <h3>Common Issues</h3>
611
+ <h4><i style="font-size: 1.2em" class="ph ph-magnifying-glass" aria-label="search"></i> <strong>Users can&#39;t log in</strong></h4>
612
+ <p><strong>Symptoms</strong>: Login form shows errors, authentication fails</p>
613
+ <p><strong>Solutions</strong>:</p>
614
+ <ol>
615
+ <li>Check Supabase project is active and accessible</li>
616
+ <li>Verify credentials in config file</li>
617
+ <li>Ensure user exists in <code>auth.users</code> table</li>
618
+ <li>Check user&#39;s email is confirmed (if confirmation required)</li>
619
+ </ol>
620
+ <pre><code class="language-sql">-- Check if user exists
621
+ SELECT email, email_confirmed_at FROM auth.users WHERE email = &#39;user@example.com&#39;;
622
+
623
+ -- Check user access
624
+ SELECT * FROM docbuilder_access
625
+ WHERE user_id = (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;);
626
+ </code></pre>
627
+ <h4><i style="font-size: 1.2em" class="ph ph-arrows-clockwise" aria-label="refresh"></i> <strong>Content flashes before redirect</strong></h4>
628
+ <p><strong>Symptoms</strong>: Protected content briefly visible before login redirect</p>
629
+ <p><strong>Solutions</strong>:</p>
630
+ <ol>
631
+ <li>Update to latest version (<code>npm install @knowcode/doc-builder@latest</code>)</li>
632
+ <li>Check network speed - slow connections may see flashing</li>
633
+ <li>Verify authentication script is loading properly</li>
634
+ </ol>
635
+ <pre><code class="language-html">&lt;!-- This CSS is automatically included to prevent flashing --&gt;
636
+ &lt;style&gt;
637
+ body { visibility: hidden; opacity: 0; }
638
+ body.authenticated { visibility: visible; opacity: 1; }
639
+ &lt;/style&gt;
640
+ </code></pre>
641
+ <h4><i style="font-size: 1.2em" class="ph ph-x-circle" aria-label="error"></i> <strong>Access denied after login</strong></h4>
642
+ <p><strong>Symptoms</strong>: User logs in successfully but sees &quot;Access Denied&quot; page</p>
643
+ <p><strong>Solutions</strong>:</p>
644
+ <ol>
645
+ <li>Check user has entry in <code>docbuilder_access</code> table</li>
646
+ <li>Verify domain matches exactly (including subdomains)</li>
647
+ <li>Check RLS policies are correctly configured</li>
648
+ </ol>
649
+ <pre><code class="language-sql">-- Debug access check
650
+ SELECT
651
+ u.email,
652
+ da.domain,
653
+ &#39;Expected: &#39; || &#39;your-actual-domain.com&#39; as expected_domain
654
+ FROM auth.users u
655
+ LEFT JOIN docbuilder_access da ON u.id = da.user_id
656
+ WHERE u.email = &#39;user@example.com&#39;;
657
+ </code></pre>
658
+ <h4><i style="font-size: 1.2em" class="ph ph-plug" aria-label="plugin"></i> <strong>Authentication not working locally</strong></h4>
659
+ <p><strong>Symptoms</strong>: Authentication works on deployment but not locally</p>
660
+ <p><strong>Solutions</strong>:</p>
661
+ <ol>
662
+ <li>Check localhost is included in Supabase allowed origins</li>
663
+ <li>Use <code>http://localhost:3000</code> exactly in Supabase settings</li>
664
+ <li>Clear browser cache and cookies</li>
665
+ </ol>
666
+ <h3>Debug Checklist</h3>
667
+ <p>When authentication isn&#39;t working:</p>
668
+ <ul>
669
+ <li><input disabled="" type="checkbox"> Check browser console for JavaScript errors</li>
670
+ <li><input disabled="" type="checkbox"> Verify JWT token in DevTools → Application → Local Storage</li>
671
+ <li><input disabled="" type="checkbox"> Test Supabase connection in browser network tab</li>
672
+ <li><input disabled="" type="checkbox"> Confirm domain in database matches deployment URL</li>
673
+ <li><input disabled="" type="checkbox"> Check Supabase project is active and not paused</li>
674
+ <li><input disabled="" type="checkbox"> Verify user email is confirmed (if required)</li>
675
+ <li><input disabled="" type="checkbox"> Test with a fresh incognito browser window</li>
676
+ </ul>
677
+ <h3>Getting Help</h3>
678
+ <ol>
679
+ <li><strong>Check the logs</strong>: Browser console and Supabase dashboard</li>
680
+ <li><strong>Test components</strong>: Try logging in directly to Supabase dashboard</li>
681
+ <li><strong>Verify setup</strong>: Run through setup steps again</li>
682
+ <li><strong>Ask for help</strong>: Open an issue on GitHub with full error details</li>
683
+ </ol>
684
+ <h2>Advanced Topics</h2>
685
+ <h3>Custom Authentication Pages</h3>
686
+ <p>While @knowcode/doc-builder generates beautiful login pages automatically, you can customize them:</p>
687
+ <pre><code class="language-javascript">// doc-builder.config.js
688
+ module.exports = {
689
+ auth: {
690
+ // Custom login page configuration
691
+ loginPageTitle: &#39;Secure Access Required&#39;,
692
+ loginPageSubtitle: &#39;Please authenticate to view our documentation&#39;,
693
+
694
+ // Custom styling (advanced)
695
+ customLoginCSS: `
696
+ .auth-box {
697
+ border-radius: 12px;
698
+ box-shadow: 0 8px 32px rgba(0,0,0,0.1);
699
+ }
700
+ `
701
+ }
702
+ };
703
+ </code></pre>
704
+ <h3>Multi-Domain Setup</h3>
705
+ <p>For organizations with multiple documentation sites:</p>
706
+ <pre><code class="language-sql">-- Grant user access to multiple domains
707
+ INSERT INTO docbuilder_access (user_id, domain) VALUES
708
+ ((SELECT id FROM auth.users WHERE email = &#39;admin@example.com&#39;), &#39;docs.example.com&#39;),
709
+ ((SELECT id FROM auth.users WHERE email = &#39;admin@example.com&#39;), &#39;api.example.com&#39;),
710
+ ((SELECT id FROM auth.users WHERE email = &#39;admin@example.com&#39;), &#39;internal.example.com&#39;);
711
+
712
+ -- View user&#39;s access across all domains
713
+ SELECT u.email, array_agg(da.domain) as accessible_domains
714
+ FROM auth.users u
715
+ JOIN docbuilder_access da ON u.id = da.user_id
716
+ GROUP BY u.id, u.email;
717
+ </code></pre>
718
+ <h3>OAuth Integration</h3>
719
+ <p>Enable social login through Supabase (optional):</p>
720
+ <ol>
721
+ <li><p><strong>In Supabase Dashboard</strong>:</p>
722
+ <ul>
723
+ <li>Go to Authentication → Settings</li>
724
+ <li>Enable desired providers (Google, GitHub, etc.)</li>
725
+ <li>Configure OAuth credentials</li>
726
+ </ul>
727
+ </li>
728
+ <li><p><strong>Update your config</strong>:</p>
729
+ </li>
730
+ </ol>
731
+ <pre><code class="language-javascript">// doc-builder.config.js
732
+ module.exports = {
733
+ auth: {
734
+ enableOAuth: true,
735
+ oauthProviders: [&#39;google&#39;, &#39;github&#39;]
736
+ }
737
+ };
738
+ </code></pre>
739
+ <h3>Role-Based Access Control</h3>
740
+ <p>Implement different permission levels:</p>
741
+ <pre><code class="language-sql">-- Add role column to access table
742
+ ALTER TABLE docbuilder_access ADD COLUMN role TEXT DEFAULT &#39;reader&#39;;
743
+
744
+ -- Grant different roles
745
+ INSERT INTO docbuilder_access (user_id, domain, role) VALUES
746
+ ((SELECT id FROM auth.users WHERE email = &#39;admin@example.com&#39;), &#39;docs.example.com&#39;, &#39;admin&#39;),
747
+ ((SELECT id FROM auth.users WHERE email = &#39;editor@example.com&#39;), &#39;docs.example.com&#39;, &#39;editor&#39;),
748
+ ((SELECT id FROM auth.users WHERE email = &#39;reader@example.com&#39;), &#39;docs.example.com&#39;, &#39;reader&#39;);
749
+ </code></pre>
750
+ <h3>API Access Control</h3>
751
+ <p>Protect API documentation or interactive content:</p>
752
+ <pre><code class="language-javascript">// In your custom HTML pages
753
+ &lt;script&gt;
754
+ async function checkAuthForAPI() {
755
+ const { data: { user } } = await supabaseClient.auth.getUser();
756
+ if (!user) {
757
+ // Redirect to login or show error
758
+ return false;
759
+ }
760
+ return true;
761
+ }
762
+
763
+ // Use in interactive demos
764
+ if (await checkAuthForAPI()) {
765
+ // Show API explorer or interactive content
766
+ }
767
+ &lt;/script&gt;
768
+ </code></pre>
769
+ <h2>Conclusion</h2>
770
+ <p>Supabase authentication in @knowcode/doc-builder provides enterprise-grade security with minimal setup. The system handles everything from user management to session persistence, letting you focus on creating great documentation.</p>
771
+ <p><strong>Key takeaways</strong>:</p>
772
+ <ul>
773
+ <li><i style="font-size: 1.2em" class="ph ph-rocket-launch" aria-label="launch"></i> <strong>Zero configuration</strong> required with built-in credentials</li>
774
+ <li><i style="font-size: 1.2em" class="ph ph-globe" aria-label="global"></i> <strong>Domain-based access</strong> control eliminates complex site registration</li>
775
+ <li><i style="font-size: 1.2em" class="ph ph-folder" aria-label="folder"></i> <strong>Private directory</strong> support for hybrid public/private docs</li>
776
+ <li><i style="font-size: 1.2em" class="ph ph-lock" aria-label="locked"></i> <strong>Enterprise security</strong> with JWT tokens and Row Level Security</li>
777
+ <li><i style="font-size: 1.2em" class="ph ph-users" aria-label="team"></i> <strong>Scalable user management</strong> supporting unlimited users</li>
778
+ </ul>
779
+ <p>For most use cases, simply creating a <code>/private/</code> directory and running <code>npx @knowcode/doc-builder deploy</code> is all you need to secure your documentation.</p>
780
+ <p>Need help? Check the <a href="#troubleshooting">troubleshooting section</a> or open an issue on GitHub.</p>
781
+
782
+ </div>
783
+ </main>
784
+ </div>
785
+
786
+ <!-- Scripts -->
787
+ <script>
788
+ // Pass configuration to frontend
789
+ window.docBuilderConfig = {
790
+ features: {
791
+ showPdfDownload: true,
792
+ menuDefaultOpen: false,
793
+ mermaidEnhanced: true
794
+ }
795
+ };
796
+ </script>
797
+ <script src="/js/main.js"></script>
798
+
799
+ </body>
800
+ </html>