docs: 补充 v1.2.7 登录验证(滑块 / Turnstile / Cap)文档

This commit is contained in:
O96u committed 2026-09-03 13:57:20 +08:00
1 parent 430c4de0f4
commit 4789d19d06
11 files changed
+69 -8

No files matched your search

+14
View File
@@ -13,6 +13,7 @@ Configure PicHost via environment variables (Docker / `.env`) or the in-app **Se
| Short image links | SQLite → env → default false | No |
| Date-based paths | SQLite → env → default true | No |
| Global auto-delete days | SQLite → env → default 0 | No |
| Login verification | SQLite (Settings → Access control) | No |
## Variables
@@ -64,6 +65,18 @@ Delete images older than N days globally; `0` disables. Affects **new uploads af
Local dev only: `true` bypasses login. Never use in production.
### Login verification (Settings only)
Configure under **Settings → Access control** (stored in SQLite; no env vars):
| Method | Notes |
| ------ | ----- |
| **Local slider** (default) | No third-party service |
| **Cloudflare Turnstile** | Site key + secret key |
| **Cap** | API endpoint + secret |
Login and registration share the same method. If misconfigured: `docker exec pichost slider` (or `npm run slider`) resets to the slider.
### Storage backends (optional)
Admins usually add backends in **Storage** UI; env vars such as `STORAGE_BACKEND=s3` and `S3_*` are also supported. See [Storage](./storage.md).
@@ -99,5 +112,6 @@ Restart the container after changing env vars.
| Date-based paths | `STORAGE_USE_DATE_PATH` / `STORAGE_LAYOUT` |
| WebP quality | `WEBP_QUALITY` |
| Auto-delete | `AUTO_DELETE_DAYS` |
| Login verification | (Settings → Access control only) |
Template: [`.env.example`](https://github.com/O96u/PicHost/blob/main/.env.example) in the repo root.
+14 -2
View File
@@ -39,11 +39,23 @@ See `docker-compose.yml` in the repository.
## Sign in
Management pages (upload, gallery, settings, etc.) require login. Enter username and password, **drag the slider to align with the gap**, then click **Sign in**.
Management pages (upload, gallery, settings, etc.) require login. Enter username and password, complete the verification challenge, then click **Sign in**.
The default is a **local slider** (align the thumb with the gap). Admins can switch to **Cloudflare Turnstile** or **Cap** under **Settings → Access control**, with the matching site key / secret or API endpoint.
![Login](/screenshots/login.png)
If registration is enabled, create an account from the register page. Legacy deployments may still use a secret key (see the on-screen hint).
If registration is enabled, create an account from the register page (same verification). Legacy deployments may still use a secret key (see the on-screen hint).
### Locked out of verification
If Turnstile / Cap is misconfigured and you cannot sign in, reset to the local slider on the server:
```bash
docker exec pichost slider
```
Local dev: `npm run slider`
## Forgot password
+1
View File
@@ -28,6 +28,7 @@ Open `http://localhost:3000/setup` to create the admin account. Data directory d
| `npm run typecheck` | Type check |
| `npm test` | Unit tests |
| `npm run reset-password` | Reset password (optional username) |
| `npm run slider` | Reset login verification to local slider |
| `npm run migrate` | Preview legacy dir migration (`-- --apply` to run) |
## Dev-only variables
+3 -1
View File
@@ -12,6 +12,7 @@ PicHost uses role-based access control (RBAC): **admin** and **user**. Enforceme
| Storage management (`/storage`) | ✓ | — |
| System settings (`/settings`) | ✓ | — |
| Allow registration | ✓ | — |
| Login verification (slider / Turnstile / Cap) | ✓ | — |
| Global API token | ✓ | — |
| Personal API token | ✓ | ✓ |
| Gallery stats overview (incl. user count) | ✓ | partial |
@@ -34,7 +35,8 @@ Regular users see **API**, **Gallery** in the nav; user menu: **Change password*
- By default only admins create users; **allow registration** is an admin setting
- Passwords hashed with scrypt
- Web login requires a slider captcha (align the thumb with the gap)
- Web login/register requires verification: local slider by default; admins can switch to Turnstile or Cap under **Settings → Access control**
- If verification is misconfigured: `docker exec pichost slider` resets to the local slider
- Login rate limiting
## Upload preferences & auto-delete
+14
View File
@@ -11,6 +11,7 @@ PicHost 支持通过环境变量(Docker / `.env`)与后台 **设置** 页配
| 简短图片链接 | SQLite → 环境变量 → 默认 false | 否 |
| 按年/月分组存储 | SQLite → 环境变量 → 默认 true | 否 |
| 全局自动删除天数 | SQLite → 环境变量 → 默认 0 | 否 |
| 登录人机验证 | SQLite(设置 → 访问控制) | 否 |
## 变量说明
@@ -62,6 +63,18 @@ PicHost 支持通过环境变量(Docker / `.env`)与后台 **设置** 页配
仅本地开发:`true` 绕过登录验证。生产环境勿用。
### 登录人机验证(仅后台设置)
在 **设置 → 访问控制** 配置,存入 SQLite,无对应环境变量:
| 方式 | 说明 |
| ---- | ---- |
| **本地滑块**(默认) | 无需第三方服务 |
| **Cloudflare Turnstile** | 填写 Site Key 与 Secret Key |
| **Cap** | 填写 API Endpoint 与 Secret |
登录与注册共用同一验证方式。若第三方配置错误导致无法登录,执行 `docker exec pichost slider`(或 `npm run slider`)恢复为本地滑块。
### 存储后端(可选)
管理员通常在 **存储** 页添加后端;也可用环境变量引导(如 `STORAGE_BACKEND=s3` 与 `S3_*`)。详见 [存储](./storage.md)。
@@ -97,5 +110,6 @@ services:
| 按年/月分组 | `STORAGE_USE_DATE_PATH` / `STORAGE_LAYOUT` |
| WebP 质量 | `WEBP_QUALITY` |
| 自动删除 | `AUTO_DELETE_DAYS` |
| 登录验证 | (仅后台 **设置 → 访问控制**) |
完整模板见仓库根目录 [`.env.example`](https://github.com/O96u/PicHost/blob/main/.env.example)。
+14 -2
View File
@@ -39,11 +39,23 @@ docker compose up -d
## 登录
访问上传、图库、设置等管理页面前需登录。在登录卡片中填写用户名与密码,**拖动滑块对齐缺口**完成验证后点击 **登录**。
访问上传、图库、设置等管理页面前需登录。在登录卡片中填写用户名与密码,完成人机验证后点击 **登录**。
默认使用**本地滑块**(拖动滑块对齐缺口)。管理员可在 **设置 → 访问控制** 切换为 **Cloudflare Turnstile** 或 **Cap**,并填写对应 Site Key / Secret 或 API 端点。
![登录页](/screenshots/login.png)
若管理员开启了开放注册,可前往注册页创建账号。遗留部署仍可能使用密钥登录(见界面提示)。
若管理员开启了开放注册,可前往注册页创建账号(同样需完成人机验证)。遗留部署仍可能使用密钥登录(见界面提示)。
### 验证方式被锁死时
若 Turnstile / Cap 配置错误导致无法登录,可在服务器上重置为本地滑块:
```bash
docker exec pichost slider
```
本地开发:`npm run slider`
## 忘记密码
+1
View File
@@ -28,6 +28,7 @@ npm run dev
| `npm run typecheck` | 类型检查 |
| `npm test` | 单元测试 |
| `npm run reset-password` | 重置密码(可选用户名) |
| `npm run slider` | 将登录验证重置为本地滑块 |
| `npm run migrate` | 预览遗留目录迁移(加 `-- --apply` 执行) |
## 开发专用环境变量
+3 -1
View File
@@ -12,6 +12,7 @@ PicHost 使用基于角色的访问控制(RBAC):**管理员(admin)**
| 存储后端管理(`/storage`) | ✓ | — |
| 系统设置(`/settings`) | ✓ | — |
| 开放注册开关 | ✓ | — |
| 登录人机验证方式(滑块 / Turnstile / Cap) | ✓ | — |
| 全局 API Token 管理 | ✓ | — |
| 个人 API Token | ✓ | ✓ |
| 图库统计概览(含注册用户数) | ✓ | 部分 |
@@ -34,7 +35,8 @@ PicHost 使用基于角色的访问控制(RBAC):**管理员(admin)**
- 默认仅管理员可创建用户;管理员可在设置中 **开放注册**
- 密码使用 scrypt 哈希存储
- Web 登录需先完成滑动拼图验证(拖动滑块对齐缺口)
- Web 登录/注册需完成人机验证:默认本地滑块;管理员可在 **设置 → 访问控制** 切换 Turnstile 或 Cap
- 验证配置错误无法登录时:`docker exec pichost slider` 重置为本地滑块
- 登录失败有速率限制
## 上传偏好与自动删除