@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.
- package/.claude/settings.local.json +3 -1
- package/CHANGELOG.md +22 -0
- package/assets/css/notion-style.css +9 -1
- package/html/README.html +5 -19
- package/html/css/notion-style.css +9 -1
- package/html/documentation-index.html +5 -19
- package/html/guides/authentication-default-change.html +5 -19
- package/html/guides/authentication-guide.html +189 -262
- package/html/guides/claude-workflow-guide.html +5 -19
- package/html/guides/documentation-standards.html +5 -19
- package/html/guides/phosphor-icons-guide.html +5 -19
- package/html/guides/private-directory-authentication.html +352 -0
- package/html/guides/public-site-deployment.html +11 -24
- package/html/guides/search-engine-verification-guide.html +5 -19
- package/html/guides/seo-guide.html +5 -19
- package/html/guides/seo-optimization-guide.html +5 -19
- package/html/guides/troubleshooting-guide.html +5 -19
- package/html/guides/windows-setup-guide.html +5 -19
- package/html/index.html +5 -19
- package/html/private/cache-control-anti-pattern.html +347 -0
- package/html/private/launch/README.html +289 -0
- package/html/private/launch/auth-cleanup-summary.html +279 -0
- package/html/private/launch/bubble-plugin-specification.html +925 -0
- package/html/private/launch/go-to-market-strategy.html +655 -0
- package/html/private/launch/launch-announcements.html +585 -0
- package/html/private/launch/vercel-deployment-auth-setup.html +329 -0
- package/html/private/next-steps-walkthrough.html +624 -0
- package/html/private/supabase-auth-implementation-completed.html +372 -0
- package/html/private/supabase-auth-implementation-plan.html +529 -0
- package/html/private/supabase-auth-integration-plan.html +657 -0
- package/html/private/supabase-auth-setup-guide.html +484 -0
- package/html/private/test-private-doc.html +220 -0
- package/html/sitemap.xml +113 -29
- package/html/vercel-cli-setup-guide.html +5 -19
- package/html/vercel-first-time-setup-guide.html +5 -19
- package/lib/config.js +24 -0
- package/lib/core-builder.js +40 -6
- package/lib/supabase-auth.js +60 -11
- package/package.json +1 -1
- package/user-management/README.md +81 -0
- package/user-management/add-users.sh +357 -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 -->
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
{
|
|
55
55
|
"@context": "https://schema.org",
|
|
56
56
|
"@type": "TechArticle",
|
|
57
|
-
"headline": "
|
|
58
|
-
"description": "
|
|
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-
|
|
69
|
-
"dateModified": "2025-07-
|
|
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.
|
|
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="
|
|
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'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
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 & 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
|
|
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
|
-
<
|
|
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>
|
|
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-
|
|
223
|
-
<li><i class="ph ph-
|
|
224
|
-
<li
|
|
225
|
-
<li><i class="ph ph-
|
|
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
|
|
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{
|
|
199
|
+
A[User visits page] --> B{Has JWT Token?}
|
|
231
200
|
B -->|No| C[Redirect to login]
|
|
232
|
-
B -->|Yes| D[
|
|
201
|
+
B -->|Yes| D[Verify with Supabase]
|
|
233
202
|
C --> E[Enter credentials]
|
|
234
|
-
E --> F
|
|
235
|
-
F
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
242
|
-
style
|
|
214
|
+
style L fill:#c8e6c9
|
|
215
|
+
style M fill:#ffcdd2</div>
|
|
243
216
|
</div>
|
|
244
|
-
<
|
|
217
|
+
<h2>Setting Up Authentication</h2>
|
|
218
|
+
<h3>Step 1: Create Supabase Project</h3>
|
|
245
219
|
<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>
|
|
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
|
-
<
|
|
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>
|
|
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: '
|
|
260
|
-
siteDescription: 'Internal documentation portal',
|
|
227
|
+
siteName: 'My Documentation',
|
|
261
228
|
|
|
262
229
|
features: {
|
|
263
|
-
authentication:
|
|
230
|
+
authentication: 'supabase' // Enable Supabase auth
|
|
264
231
|
},
|
|
265
232
|
|
|
266
233
|
auth: {
|
|
267
|
-
|
|
268
|
-
|
|
234
|
+
supabaseUrl: 'https://your-project.supabase.co',
|
|
235
|
+
supabaseAnonKey: 'your-anon-key',
|
|
236
|
+
siteId: 'your-site-id' // From database after setup
|
|
269
237
|
}
|
|
270
238
|
};
|
|
271
239
|
</code></pre>
|
|
272
|
-
<
|
|
273
|
-
<p>
|
|
274
|
-
<pre><code class="language-
|
|
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 "Sites visible to users with access" 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 "Access visible to own user" ON docbuilder_access
|
|
273
|
+
FOR SELECT USING (user_id = auth.uid());
|
|
275
274
|
</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
|
|
275
|
+
<h3>Step 4: Add Your Site</h3>
|
|
276
|
+
<pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name)
|
|
277
|
+
VALUES ('your-domain.com', 'Your Documentation Name');
|
|
284
278
|
</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>
|
|
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 > Users
|
|
283
|
+
-- Click "Invite user" 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 = 'user@example.com'),
|
|
290
|
+
'your-site-id'
|
|
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>
|
|
349
|
-
<li>
|
|
350
|
-
<li>
|
|
351
|
-
<li>
|
|
352
|
-
<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
|
|
357
|
-
<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
<p>
|
|
365
|
-
|
|
366
|
-
<li><strong>
|
|
367
|
-
|
|
368
|
-
<li><strong>
|
|
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's theme and styling.</p>
|
|
380
350
|
<h2>Troubleshooting</h2>
|
|
381
351
|
<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>
|
|
352
|
+
<p><strong>Users can't log in</strong></p>
|
|
388
353
|
<ul>
|
|
389
|
-
<li>Verify
|
|
390
|
-
<li>Check
|
|
391
|
-
<li>Ensure
|
|
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>
|
|
359
|
+
<p><strong>Content flashes before redirect</strong></p>
|
|
394
360
|
<ul>
|
|
395
|
-
<li>
|
|
396
|
-
<li>
|
|
397
|
-
<li>Ensure no pages exclude authentication script</li>
|
|
361
|
+
<li>This is fixed in latest versions</li>
|
|
362
|
+
<li>Ensure you're using @knowcode/doc-builder v1.7.4+</li>
|
|
398
363
|
</ul>
|
|
399
|
-
<p><strong>
|
|
364
|
+
<p><strong>Access denied after login</strong></p>
|
|
400
365
|
<ul>
|
|
401
|
-
<li>Check
|
|
402
|
-
<li>Verify
|
|
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
|
|
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
|
|
416
|
-
<li
|
|
417
|
-
<li
|
|
418
|
-
<li
|
|
419
|
-
<li
|
|
372
|
+
<li>Check browser console for errors</li>
|
|
373
|
+
<li>Verify JWT token in browser DevTools > Application > 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>
|
|
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
|
|
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: 'admin',
|
|
385
|
+
password: 'password'
|
|
386
|
+
}
|
|
441
387
|
</code></pre>
|
|
442
|
-
|
|
443
|
-
<p>
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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: 'supabase'
|
|
394
|
+
}
|
|
452
395
|
</code></pre>
|
|
396
|
+
</li>
|
|
397
|
+
</ol>
|
|
453
398
|
<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>
|
|
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'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>
|