refactor: 更新认证方式为密码验证
简化认证流程,移除用户名,只需要输入访问密码: ## 后端更改 - 移除 JWT_SECRET、ADMIN_USERNAME、ADMIN_PASSWORD 配置 - 添加 ACCESS_PASSWORD 配置 - 更新认证接口:POST /api/auth/verify-password - 简化 JWT payload,只包含认证状态和时间戳 - 移除用户管理相关代码 - 更新认证中间件 ## 前端更改 - 登录页面只显示密码输入框 - 移除用户名输入和相关状态 - 更新 Pinia store 为 verifyPassword 方法 - 移除 User 类型定义 - 更新布局和设置页面 ## 文档更改 - 更新 README.md 说明新的认证方式 - 更新 DEVELOPMENT_GUIDE.md 环境变量配置 - 更新 API.md 认证接口文档 - 更新 .env.example 配置模板 ## 安全改进 - 使用 ACCESS_PASSWORD 作为 JWT 签名密钥 - 自动清理过期会话(7天) - 简化配置,更易于部署 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed626e74dc
commit
903dc1e61f
15 files changed
+124
-171
No files matched your search
+6
-14
@@ -10,17 +10,16 @@
|
||||
|
||||
## 认证
|
||||
|
||||
### 登录
|
||||
### 验证密码
|
||||
|
||||
获取访问令牌。
|
||||
验证访问密码并获取令牌。
|
||||
|
||||
**请求**
|
||||
```http
|
||||
POST /auth/login
|
||||
POST /auth/verify-password
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"username": "string",
|
||||
"password": "string"
|
||||
}
|
||||
```
|
||||
@@ -28,12 +27,8 @@ Content-Type: application/json
|
||||
**响应**
|
||||
```json
|
||||
{
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
||||
"user": {
|
||||
"id": "string",
|
||||
"username": "string",
|
||||
"createdAt": "2024-01-01T00:00:00.000Z"
|
||||
}
|
||||
"success": true,
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
||||
}
|
||||
```
|
||||
|
||||
@@ -51,10 +46,7 @@ Authorization: Bearer <token>
|
||||
```json
|
||||
{
|
||||
"valid": true,
|
||||
"user": {
|
||||
"userId": "string",
|
||||
"username": "string"
|
||||
}
|
||||
"authenticated": true
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user