@knowcode/doc-builder 1.7.6 → 1.8.1
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/.claude/settings.local.json +6 -1
- package/CHANGELOG.md +29 -0
- package/assets/css/notion-style.css +9 -1
- package/assets/js/main.js +10 -6
- package/html/README.html +44 -20
- package/html/auth.js +62 -13
- package/html/css/notion-style.css +9 -1
- package/html/documentation-index.html +44 -20
- package/html/guides/authentication-default-change.html +44 -20
- package/html/guides/authentication-guide.html +228 -263
- package/html/guides/claude-workflow-guide.html +44 -20
- package/html/guides/documentation-standards.html +44 -20
- package/html/guides/phosphor-icons-guide.html +44 -20
- package/html/guides/private-directory-authentication.html +472 -0
- package/html/guides/public-site-deployment.html +50 -25
- package/html/guides/search-engine-verification-guide.html +44 -20
- package/html/guides/seo-guide.html +44 -20
- package/html/guides/seo-optimization-guide.html +44 -20
- package/html/guides/troubleshooting-guide.html +44 -20
- package/html/guides/windows-setup-guide.html +44 -20
- package/html/index.html +44 -20
- package/html/js/auth.js +118 -39
- package/html/js/main.js +10 -6
- package/html/login.html +4 -4
- package/html/logout.html +2 -2
- package/html/private/cache-control-anti-pattern.html +408 -0
- package/html/private/launch/README.html +350 -0
- package/html/private/launch/auth-cleanup-summary.html +340 -0
- package/html/private/launch/bubble-plugin-specification.html +986 -0
- package/html/private/launch/go-to-market-strategy.html +716 -0
- package/html/private/launch/launch-announcements.html +646 -0
- package/html/private/launch/vercel-deployment-auth-setup.html +390 -0
- package/html/private/next-steps-walkthrough.html +685 -0
- package/html/private/supabase-auth-implementation-completed.html +433 -0
- package/html/private/supabase-auth-implementation-plan.html +590 -0
- package/html/private/supabase-auth-integration-plan.html +718 -0
- package/html/private/supabase-auth-setup-guide.html +545 -0
- package/html/private/test-private-doc.html +281 -0
- package/html/robots.txt +4 -0
- package/html/sitemap.xml +113 -29
- package/html/vercel-cli-setup-guide.html +44 -20
- package/html/vercel-first-time-setup-guide.html +44 -20
- package/lib/config.js +21 -3
- package/lib/core-builder.js +49 -7
- package/lib/supabase-auth.js +80 -25
- package/package.json +1 -1
- package/user-management/README.md +306 -0
- package/user-management/add-users.sh +730 -0
- package/user-management/create-user.js +65 -0
- 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="
|
|
7
|
-
<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,
|
|
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="
|
|
18
|
-
<meta property="og:description" content="
|
|
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="
|
|
28
|
-
<meta name="twitter:description" content="
|
|
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 -->
|
|
@@ -46,6 +46,39 @@
|
|
|
46
46
|
<link rel="stylesheet" href="/css/notion-style.css">
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
<!-- Hide content until auth check -->
|
|
50
|
+
<style>
|
|
51
|
+
body {
|
|
52
|
+
visibility: hidden;
|
|
53
|
+
opacity: 0;
|
|
54
|
+
transition: opacity 0.3s ease;
|
|
55
|
+
}
|
|
56
|
+
body.authenticated {
|
|
57
|
+
visibility: visible;
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
|
60
|
+
/* Show login/logout pages immediately */
|
|
61
|
+
body.auth-page {
|
|
62
|
+
visibility: visible;
|
|
63
|
+
opacity: 1;
|
|
64
|
+
}
|
|
65
|
+
/* Style auth button consistently */
|
|
66
|
+
.auth-btn {
|
|
67
|
+
background: none;
|
|
68
|
+
border: none;
|
|
69
|
+
color: var(--text-secondary);
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
padding: 0.5rem;
|
|
72
|
+
border-radius: 0.5rem;
|
|
73
|
+
transition: all 0.2s;
|
|
74
|
+
font-size: 1.1rem;
|
|
75
|
+
}
|
|
76
|
+
.auth-btn:hover {
|
|
77
|
+
background: var(--bg-secondary);
|
|
78
|
+
color: var(--text-primary);
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
|
|
49
82
|
|
|
50
83
|
<!-- Favicon -->
|
|
51
84
|
<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>">
|
|
@@ -54,8 +87,8 @@
|
|
|
54
87
|
{
|
|
55
88
|
"@context": "https://schema.org",
|
|
56
89
|
"@type": "TechArticle",
|
|
57
|
-
"headline": "
|
|
58
|
-
"description": "
|
|
90
|
+
"headline": "Authentication Guide for @knowcode/doc-builder",
|
|
91
|
+
"description": "@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform. This guide explains how to...",
|
|
59
92
|
"author": {
|
|
60
93
|
"@type": "Person",
|
|
61
94
|
"name": "Lindsay Smith"
|
|
@@ -65,8 +98,8 @@
|
|
|
65
98
|
"name": "Knowcode Ltd",
|
|
66
99
|
"url": "https://knowcode.tech"
|
|
67
100
|
},
|
|
68
|
-
"datePublished": "2025-07-
|
|
69
|
-
"dateModified": "2025-07-
|
|
101
|
+
"datePublished": "2025-07-26T10:20:52.380Z",
|
|
102
|
+
"dateModified": "2025-07-26T10:20:52.380Z",
|
|
70
103
|
"mainEntityOfPage": {
|
|
71
104
|
"@type": "WebPage",
|
|
72
105
|
"@id": "https://doc-builder-delta.vercel.app/guides/authentication-guide.html"
|
|
@@ -105,10 +138,14 @@
|
|
|
105
138
|
|
|
106
139
|
<div class="header-actions">
|
|
107
140
|
<div class="deployment-info">
|
|
108
|
-
<span class="deployment-date" title="Built with doc-builder v1.
|
|
141
|
+
<span class="deployment-date" title="Built with doc-builder v1.8.0">Last updated: Jul 26, 2025, 10:20 AM UTC</span>
|
|
109
142
|
</div>
|
|
110
143
|
|
|
111
144
|
|
|
145
|
+
<a href="../../login.html" class="auth-btn" title="Login/Logout">
|
|
146
|
+
<i class="fas fa-sign-in-alt"></i>
|
|
147
|
+
</a>
|
|
148
|
+
|
|
112
149
|
|
|
113
150
|
<button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
|
|
114
151
|
<i class="fas fa-moon"></i>
|
|
@@ -164,31 +201,17 @@
|
|
|
164
201
|
</a>
|
|
165
202
|
<div class="nav-content" id="nav-guides-1">
|
|
166
203
|
<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="
|
|
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>
|
|
204
|
+
<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
205
|
<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
206
|
<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've implemented Supabase authentication, let's walk through testing the implementation and preparing for deployment."><i class="fas fa-file-alt"></i> Next Steps Walkthrough</a>
|
|
172
207
|
<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>
|
|
208
|
+
<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="fas fa-file-alt"></i> Private Directory Authentication</a>
|
|
173
209
|
<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
210
|
<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
211
|
<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
212
|
<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
213
|
<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
214
|
<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 & 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
215
|
</nav>
|
|
193
216
|
<div class="resize-handle"></div>
|
|
194
217
|
</aside>
|
|
@@ -196,281 +219,222 @@
|
|
|
196
219
|
<!-- Content Area -->
|
|
197
220
|
<main class="content">
|
|
198
221
|
<div class="content-inner">
|
|
199
|
-
<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>
|
|
222
|
+
<h1>Authentication Guide for @knowcode/doc-builder</h1>
|
|
205
223
|
<h2>Overview</h2>
|
|
206
|
-
<
|
|
207
|
-
<
|
|
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>
|
|
224
|
+
<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
|
+
<h2>Why Supabase?</h2>
|
|
221
226
|
<ul>
|
|
222
|
-
<li><i class="ph ph-
|
|
223
|
-
<li><i class="ph ph-
|
|
224
|
-
<li
|
|
225
|
-
<li><i class="ph ph-
|
|
227
|
+
<li><i class="ph ph-lock-key" aria-label="secure"></i> <strong>Enterprise Security</strong>: JWT tokens, bcrypt password hashing, Row Level Security</li>
|
|
228
|
+
<li><i class="ph ph-users" aria-label="team"></i> <strong>Multi-User Support</strong>: Unlimited users with fine-grained access control</li>
|
|
229
|
+
<li>🌍 <strong>Scalable</strong>: Built on PostgreSQL, handles millions of users</li>
|
|
230
|
+
<li><i class="ph ph-arrows-clockwise" aria-label="refresh"></i> <strong>Real-time</strong>: Live updates when permissions change</li>
|
|
231
|
+
<li><i class="ph ph-money" aria-label="money"></i> <strong>Generous Free Tier</strong>: 50,000 monthly active users free</li>
|
|
226
232
|
</ul>
|
|
227
|
-
<h2>How
|
|
233
|
+
<h2>How It Works</h2>
|
|
228
234
|
<div class="mermaid-wrapper">
|
|
229
235
|
<div class="mermaid">graph TD
|
|
230
|
-
A[User visits page] --> B{
|
|
236
|
+
A[User visits page] --> B{Has JWT Token?}
|
|
231
237
|
B -->|No| C[Redirect to login]
|
|
232
|
-
B -->|Yes| D[
|
|
238
|
+
B -->|Yes| D[Verify with Supabase]
|
|
233
239
|
C --> E[Enter credentials]
|
|
234
|
-
E --> F
|
|
235
|
-
F
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
240
|
+
E --> F[Authenticate with Supabase]
|
|
241
|
+
F --> G{Valid?}
|
|
242
|
+
G -->|No| H[Show error]
|
|
243
|
+
G -->|Yes| I[Receive JWT token]
|
|
244
|
+
I --> J[Check site access]
|
|
245
|
+
J --> K{Has access?}
|
|
246
|
+
K -->|Yes| L[Show content]
|
|
247
|
+
K -->|No| M[Access denied]
|
|
248
|
+
D --> J
|
|
239
249
|
|
|
240
250
|
style A fill:#e1f5fe
|
|
241
|
-
style
|
|
242
|
-
style
|
|
251
|
+
style L fill:#c8e6c9
|
|
252
|
+
style M fill:#ffcdd2</div>
|
|
243
253
|
</div>
|
|
244
|
-
<
|
|
254
|
+
<h2>Setting Up Authentication</h2>
|
|
255
|
+
<h3>Step 1: Create Supabase Project</h3>
|
|
245
256
|
<ol>
|
|
246
|
-
<li
|
|
247
|
-
<li
|
|
248
|
-
<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>
|
|
257
|
+
<li>Go to <a href="https://supabase.com">Supabase</a></li>
|
|
258
|
+
<li>Create a new project</li>
|
|
259
|
+
<li>Note your project URL and anon key</li>
|
|
252
260
|
</ol>
|
|
253
|
-
<
|
|
254
|
-
<
|
|
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>
|
|
261
|
+
<h3>Step 2: Configure doc-builder</h3>
|
|
262
|
+
<p>Create or update <code>doc-builder.config.js</code>:</p>
|
|
258
263
|
<pre><code class="language-javascript">module.exports = {
|
|
259
|
-
siteName: '
|
|
260
|
-
siteDescription: 'Internal documentation portal',
|
|
264
|
+
siteName: 'My Documentation',
|
|
261
265
|
|
|
262
266
|
features: {
|
|
263
|
-
authentication:
|
|
267
|
+
authentication: 'supabase' // Enable Supabase auth
|
|
264
268
|
},
|
|
265
269
|
|
|
266
270
|
auth: {
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
supabaseUrl: 'https://your-project.supabase.co',
|
|
272
|
+
supabaseAnonKey: 'your-anon-key',
|
|
273
|
+
siteId: 'your-site-id' // From database after setup
|
|
269
274
|
}
|
|
270
275
|
};
|
|
271
276
|
</code></pre>
|
|
272
|
-
<
|
|
273
|
-
<p>
|
|
274
|
-
<pre><code class="language-
|
|
277
|
+
<h3>Step 3: Set Up Database</h3>
|
|
278
|
+
<p>Run these SQL commands in your Supabase SQL editor:</p>
|
|
279
|
+
<pre><code class="language-sql">-- Create sites table
|
|
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
|
|
288
|
+
CREATE TABLE docbuilder_access (
|
|
289
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
290
|
+
user_id UUID NOT NULL REFERENCES auth.users(id),
|
|
291
|
+
site_id UUID NOT NULL REFERENCES docbuilder_sites(id),
|
|
292
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
293
|
+
UNIQUE(user_id, site_id)
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
-- Enable Row Level Security
|
|
297
|
+
ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
|
|
298
|
+
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
299
|
+
|
|
300
|
+
-- Create policies
|
|
301
|
+
CREATE POLICY "Sites visible to users with access" ON docbuilder_sites
|
|
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
|
|
310
|
+
FOR SELECT USING (user_id = auth.uid());
|
|
275
311
|
</code></pre>
|
|
276
|
-
<
|
|
277
|
-
<
|
|
278
|
-
|
|
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
|
|
312
|
+
<h3>Step 4: Add Your Site</h3>
|
|
313
|
+
<pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name)
|
|
314
|
+
VALUES ('your-domain.com', 'Your Documentation Name');
|
|
284
315
|
</code></pre>
|
|
285
|
-
<
|
|
286
|
-
<
|
|
287
|
-
<
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
<
|
|
292
|
-
<
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
<
|
|
300
|
-
</
|
|
301
|
-
<
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
</
|
|
307
|
-
<
|
|
308
|
-
<
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
</
|
|
314
|
-
<h2>
|
|
315
|
-
<h3>
|
|
316
|
-
<
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
<
|
|
326
|
-
<
|
|
327
|
-
<
|
|
328
|
-
</
|
|
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>
|
|
316
|
+
<p>Note the returned ID - this is your <code>siteId</code> for the config.</p>
|
|
317
|
+
<h3>Step 5: Create Users</h3>
|
|
318
|
+
<p>Users can sign up through Supabase Auth, or you can create them:</p>
|
|
319
|
+
<pre><code class="language-sql">-- In Supabase dashboard, go to Authentication > Users
|
|
320
|
+
-- Click "Invite user" and enter their email
|
|
321
|
+
</code></pre>
|
|
322
|
+
<h3>Step 6: Grant Access</h3>
|
|
323
|
+
<pre><code class="language-sql">-- Grant user access to your site
|
|
324
|
+
INSERT INTO docbuilder_access (user_id, site_id)
|
|
325
|
+
VALUES (
|
|
326
|
+
(SELECT id FROM auth.users WHERE email = 'user@example.com'),
|
|
327
|
+
'your-site-id'
|
|
328
|
+
);
|
|
329
|
+
</code></pre>
|
|
330
|
+
<h2>Deployment</h2>
|
|
331
|
+
<h3>Build with Authentication</h3>
|
|
332
|
+
<pre><code class="language-bash"># Build with auth enabled (reads from config)
|
|
333
|
+
npx @knowcode/doc-builder build
|
|
334
|
+
|
|
335
|
+
# Build without auth (override config)
|
|
336
|
+
npx @knowcode/doc-builder build --no-auth
|
|
337
|
+
</code></pre>
|
|
338
|
+
<h3>Deploy to Vercel</h3>
|
|
339
|
+
<pre><code class="language-bash"># Deploy with auth
|
|
340
|
+
npx @knowcode/doc-builder deploy
|
|
341
|
+
|
|
342
|
+
# Deploy public site
|
|
343
|
+
npx @knowcode/doc-builder deploy --no-auth
|
|
344
|
+
</code></pre>
|
|
345
|
+
<h2>User Management</h2>
|
|
346
|
+
<h3>CLI Commands (Future)</h3>
|
|
347
|
+
<pre><code class="language-bash"># Add user to site
|
|
348
|
+
npx @knowcode/doc-builder auth:grant --email user@example.com --site-id xxx
|
|
349
|
+
|
|
350
|
+
# Remove user access
|
|
351
|
+
npx @knowcode/doc-builder auth:revoke --email user@example.com --site-id xxx
|
|
352
|
+
|
|
353
|
+
# List users with access
|
|
354
|
+
npx @knowcode/doc-builder auth:list-users --site-id xxx
|
|
355
|
+
</code></pre>
|
|
356
|
+
<h3>Manual Management</h3>
|
|
357
|
+
<p>Use Supabase dashboard or SQL commands to manage users and access.</p>
|
|
358
|
+
<h2>Security Features</h2>
|
|
359
|
+
<h3>What Supabase Provides</h3>
|
|
347
360
|
<ul>
|
|
348
|
-
<li>
|
|
349
|
-
<li>
|
|
350
|
-
<li>
|
|
351
|
-
<li>
|
|
352
|
-
<li>
|
|
361
|
+
<li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>JWT Authentication</strong>: Industry-standard secure tokens</li>
|
|
362
|
+
<li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Password Hashing</strong>: bcrypt with salt</li>
|
|
363
|
+
<li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Row Level Security</strong>: Database-level access control</li>
|
|
364
|
+
<li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Session Management</strong>: Automatic token refresh</li>
|
|
365
|
+
<li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>Multi-Factor Auth</strong>: Optional 2FA support</li>
|
|
366
|
+
<li><i class="ph ph-check-circle" aria-label="checked"></i> <strong>OAuth Providers</strong>: Google, GitHub, etc. (optional)</li>
|
|
353
367
|
</ul>
|
|
354
368
|
<h3>Security Best Practices</h3>
|
|
355
369
|
<ol>
|
|
356
|
-
<li><strong>Use
|
|
357
|
-
<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
<p>
|
|
365
|
-
|
|
366
|
-
<li><strong>
|
|
367
|
-
|
|
368
|
-
<li><strong>
|
|
370
|
+
<li><p><strong>Use environment variables</strong> for sensitive config:</p>
|
|
371
|
+
<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
|
|
375
|
+
}
|
|
376
|
+
</code></pre>
|
|
377
|
+
</li>
|
|
378
|
+
<li><p><strong>Enable RLS policies</strong> on all tables</p>
|
|
379
|
+
</li>
|
|
380
|
+
<li><p><strong>Regular access audits</strong> - review who has access</p>
|
|
381
|
+
</li>
|
|
382
|
+
<li><p><strong>Use custom domains</strong> for professional appearance</p>
|
|
383
|
+
</li>
|
|
384
|
+
<li><p><strong>Monitor usage</strong> in Supabase dashboard</p>
|
|
385
|
+
</li>
|
|
369
386
|
</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's theme and styling.</p>
|
|
380
387
|
<h2>Troubleshooting</h2>
|
|
381
388
|
<h3>Common Issues</h3>
|
|
382
|
-
<p><strong>Users
|
|
383
|
-
<ul>
|
|
384
|
-
<li>Session cookies expire when browser closes</li>
|
|
385
|
-
<li>Consider implementing "remember me" functionality</li>
|
|
386
|
-
</ul>
|
|
387
|
-
<p><strong>Login page shows but credentials don't work</strong></p>
|
|
388
|
-
<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>
|
|
392
|
-
</ul>
|
|
393
|
-
<p><strong>Some pages accessible without login</strong></p>
|
|
389
|
+
<p><strong>Users can't log in</strong></p>
|
|
394
390
|
<ul>
|
|
395
|
-
<li>Verify
|
|
396
|
-
<li>Check
|
|
397
|
-
<li>Ensure
|
|
391
|
+
<li>Verify Supabase project is active</li>
|
|
392
|
+
<li>Check credentials are correct</li>
|
|
393
|
+
<li>Ensure user exists in auth.users</li>
|
|
394
|
+
<li>Verify site domain matches configuration</li>
|
|
398
395
|
</ul>
|
|
399
|
-
<p><strong>
|
|
396
|
+
<p><strong>Content flashes before redirect</strong></p>
|
|
400
397
|
<ul>
|
|
401
|
-
<li>
|
|
402
|
-
<li>
|
|
398
|
+
<li>This is fixed in latest versions</li>
|
|
399
|
+
<li>Ensure you're using @knowcode/doc-builder v1.7.4+</li>
|
|
403
400
|
</ul>
|
|
404
|
-
<
|
|
405
|
-
<p>Check browser developer console for:</p>
|
|
401
|
+
<p><strong>Access denied after login</strong></p>
|
|
406
402
|
<ul>
|
|
407
|
-
<li>
|
|
408
|
-
<li>
|
|
409
|
-
<li>
|
|
410
|
-
<li>Network requests</li>
|
|
403
|
+
<li>Check user has entry in docbuilder_access table</li>
|
|
404
|
+
<li>Verify site_id matches your configuration</li>
|
|
405
|
+
<li>Check RLS policies are correctly set up</li>
|
|
411
406
|
</ul>
|
|
412
|
-
<
|
|
413
|
-
<p>For more robust authentication, consider:</p>
|
|
407
|
+
<h3>Debug Checklist</h3>
|
|
414
408
|
<ol>
|
|
415
|
-
<li
|
|
416
|
-
<li
|
|
417
|
-
<li
|
|
418
|
-
<li
|
|
419
|
-
<li
|
|
409
|
+
<li>Check browser console for errors</li>
|
|
410
|
+
<li>Verify JWT token in browser DevTools > Application > Storage</li>
|
|
411
|
+
<li>Test Supabase connection separately</li>
|
|
412
|
+
<li>Check network tab for API calls</li>
|
|
413
|
+
<li>Verify domain in database matches deployment</li>
|
|
420
414
|
</ol>
|
|
421
|
-
<h2>
|
|
422
|
-
<
|
|
423
|
-
<
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
username: 'team',
|
|
431
|
-
password: 'handbook2025'
|
|
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
|
|
415
|
+
<h2>Migration from Old Auth</h2>
|
|
416
|
+
<p>If you were using the old authentication system:</p>
|
|
417
|
+
<ol>
|
|
418
|
+
<li><p><strong>Remove old config</strong>:</p>
|
|
419
|
+
<pre><code class="language-javascript">// Remove this:
|
|
420
|
+
auth: {
|
|
421
|
+
username: 'admin',
|
|
422
|
+
password: 'password'
|
|
423
|
+
}
|
|
441
424
|
</code></pre>
|
|
442
|
-
|
|
443
|
-
<p>
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
Password: handbook2025
|
|
450
|
-
|
|
451
|
-
Please bookmark the site after logging in.
|
|
425
|
+
</li>
|
|
426
|
+
<li><p><strong>Set up Supabase</strong> following this guide</p>
|
|
427
|
+
</li>
|
|
428
|
+
<li><p><strong>Update config</strong> to use Supabase:</p>
|
|
429
|
+
<pre><code class="language-javascript">features: {
|
|
430
|
+
authentication: 'supabase'
|
|
431
|
+
}
|
|
452
432
|
</code></pre>
|
|
433
|
+
</li>
|
|
434
|
+
</ol>
|
|
453
435
|
<h2>Conclusion</h2>
|
|
454
|
-
<p>
|
|
455
|
-
<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>
|
|
436
|
+
<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>
|
|
437
|
+
<p>For public documentation that doesn't need authentication, simply set <code>authentication: false</code> or use the <code>--no-auth</code> flag during build/deploy.</p>
|
|
474
438
|
|
|
475
439
|
</div>
|
|
476
440
|
</main>
|
|
@@ -487,6 +451,7 @@ Please bookmark the site after logging in.
|
|
|
487
451
|
};
|
|
488
452
|
</script>
|
|
489
453
|
<script src="/js/main.js"></script>
|
|
490
|
-
|
|
454
|
+
<script src="https://unpkg.com/@supabase/supabase-js@2"></script>
|
|
455
|
+
<script src="/js/auth.js"></script>
|
|
491
456
|
</body>
|
|
492
457
|
</html>
|