Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
09f0b28
fix(security): schema.sql 不再 seed 可登录账号(INV-011)
longsizhuo Oct 18, 2026
dcc9bb1
feat(auth): provider 抽象消灭 switch + M2b 绑定流程 + 模块 README
longsizhuo Jul 26, 2026
f4ba6d0
fix(auth): OAuth 登录改为 identity-first,资料刷新只补空列
longsizhuo Oct 18, 2026
bc5bd8f
fix(auth): 绑定回调丢了意图不落入登录分支;绑定撞约束归 bind_taken
longsizhuo Oct 18, 2026
422e0b4
feat(auth): 新账号一律先验证邮箱(OTP 注册接线)
longsizhuo Oct 18, 2026
ff59307
fix(auth): 收掉 #57 review 余下的账号归属与绑定入口问题
longsizhuo Oct 18, 2026
b5172be
fix(community): 机器人桥接接口拒收经过代理的请求
longsizhuo Oct 18, 2026
1b0e9a9
docs(security): 登记 INV-012 / INV-013,更新 INV-007 / INV-008
longsizhuo Oct 18, 2026
7b2d896
docs(auth): 按 OTP 注册与绑定入口的现状更新 README / ADR-001
longsizhuo Oct 18, 2026
8f32463
chore(usercenter): 删掉无引用的 OAuthAccount 模型
longsizhuo Oct 18, 2026
fa992e0
fix(auth): 登录 #token 回显发起 tab 的 nonce(INV-007)
longsizhuo Oct 18, 2026
bfa3c1c
fix(auth): 绑定回调的意外异常回到设置页而不是裸 500
longsizhuo Oct 18, 2026
f5f71ef
fix(auth): OTP 发信失败日志不再打印 pendingId
longsizhuo Oct 18, 2026
8889468
fix(auth): OTP 发信限额改成按(邮箱, 身份)计,先查后占、失败退还
longsizhuo Oct 18, 2026
84a7994
test(auth): 锁住 completeRegistration 的建号+挂身份原子性
longsizhuo Oct 18, 2026
c29ee51
fix(auth): OTP 码送达后才生效、按邮箱封顶猜码、邮箱主人免全局限额
longsizhuo Oct 18, 2026
e05fd20
docs(auth): INV-012 / README / dev1 按最终的 OTP 限额与登录 nonce 更新
longsizhuo Oct 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ POSTGRES_PASSWORD=change_me
# 你需要**自己**在 GitHub 注册一个 OAuth App(不要用社区共享 key,回调 URL 不会匹配):
# 1. 打开 https://github.com/settings/developers → New OAuth App
# 2. Application name:随便填,如 "involution-hell-dev (你的名字)"
# 3. Homepage URL:http://localhost:3010
# 4. **Authorization callback URL:http://localhost:3010/api/auth/callback/github**
# 3. Homepage URL:http://localhost:3000
# 4. **Authorization callback URL:http://localhost:3000/api/auth/callback/github**
# 这个 URL 必须与 AUTH_URL 拼出来的一致,否则 GitHub 会拒绝并报
# "redirect_uri is not associated with this application"
# 5. 创建后页面会显示 Client ID,再点 "Generate a new client secret" 得到 Secret
# 6. 把这两个值填到下面,AUTH_URL 保持 http://localhost:3010
# 6. 把这两个值填到下面,AUTH_URL 保持 http://localhost:3000
#
# 生产环境用另一个 prod App(已注册线上域名为回调),由部署机的 .env 提供,
# 跟你本地这套完全独立,不会互相污染。
Expand All @@ -63,7 +63,8 @@ AUTH_SECRET=

# Discord 登录(可选)。要开就到 https://discord.com/developers/applications 建个 App,
# OAuth2 → Redirects 加 ${AUTH_URL}/api/auth/callback/discord,勾 identify + email scope,
# 把 Client ID / Secret 填这里。留空则站点不显示 Discord 登录、后端也不报错。
# 把 Client ID / Secret 填这里。留空后端也不报错,但登录页的 Discord 按钮照样显示,
# 点了会回到 /login?error=oauth_provider。
AUTH_DISCORD_ID=
AUTH_DISCORD_SECRET=
# Discord 登录灰度白名单(逗号分隔的 Discord user id)。留空 = Discord 对所有人开放;
Expand Down Expand Up @@ -94,10 +95,10 @@ OPENAI_MODEL=glm-4.6v-flash
SPRING_APPLICATION_NAME=backend
SERVER_PORT=8080
# 前端域名,用于 GitHub OAuth 回调重定向和 Sa-Token 会话重定向
# 本地开发:http://localhost:3010(端口与前端 dev 一致;OAuth 回调拼成
# 本地开发:http://localhost:3000(端口与前端 dev 一致;OAuth 回调拼成
# ${AUTH_URL}/api/auth/callback/github,必须和 GitHub OAuth App 注册的回调一致)
# 生产部署:https://involutionhell.com
AUTH_URL=http://localhost:3010
AUTH_URL=http://localhost:3000

# --- Actuator ---
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics
Expand Down
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
`column "x" does not exist`。init.sql 的每张表列集必须与 schema.sql 逐列一致
(这条正是 INV-004 `user_follows` 事故的教训扩展)。

**唯一例外:可登录的 seed 账号**(admin/alice/auditor)只放 `init.sql` 和
`test-schema.sql`,**绝不能同步进 `schema.sql`**——它在生产每次启动都跑,
会把 README 公开的默认密码写进生产库(INV-011,2026-10 真实发生过)。

2. **schema.sql 里的任何 DML 必须幂等**:它每次启动都重跑。回填用
`INSERT ... ON CONFLICT DO NOTHING`,seed 用 `ON CONFLICT DO NOTHING/UPDATE`。
非幂等语句会在第二次启动 `spring.sql.init` 报错、后端拒绝启动。
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ cp .env.example .env

```bash
# 启动 PostgreSQL 18
# 此操作会自动创建 Schema 并初始化种子数据 (一致性与 NEON 保持同步)
# 此操作会自动创建 Schema 并初始化本地种子账号(只在本地库首次建卷时写入,生产不会有)
docker compose up -d postgres
```

Expand All @@ -107,12 +107,12 @@ docker compose up -d postgres

注册步骤:
1. 打开 [GitHub Settings → Developer settings → OAuth Apps](https://github.com/settings/developers) → **New OAuth App**
2. **Authorization callback URL** 必须填 `http://localhost:3010/api/auth/callback/github`(端口跟前端 dev 一致;后端会拼 `${AUTH_URL}/api/auth/callback/github`,两边要对齐)
2. **Authorization callback URL** 必须填 `http://localhost:3000/api/auth/callback/github`(端口跟前端 dev 一致;后端会拼 `${AUTH_URL}/api/auth/callback/github`,两边要对齐)
3. 创建后把 Client ID 和(点 Generate 出来的)Client Secret 填到 `.env`:
```
AUTH_GITHUB_ID=Ov23li...
AUTH_GITHUB_SECRET=xxxx
AUTH_URL=http://localhost:3010
AUTH_URL=http://localhost:3000
```

> [!TIP]
Expand All @@ -123,14 +123,14 @@ docker compose up -d postgres
同 GitHub,每个开发者用自己的 Discord App:

1. [Discord Developer Portal](https://discord.com/developers/applications) → **New Application**
2. **OAuth2 → Redirects** 加 `http://localhost:3010/api/auth/callback/discord`(与 `${AUTH_URL}/api/auth/callback/discord` 对齐)
2. **OAuth2 → Redirects** 加 `http://localhost:3000/api/auth/callback/discord`(与 `${AUTH_URL}/api/auth/callback/discord` 对齐)
3. OAuth2 → 复制 **Client ID** 和 **Client Secret**,填到 `.env`:
```
AUTH_DISCORD_ID=...
AUTH_DISCORD_SECRET=...
```

不填就不显示 Discord 登录、后端也不报错(`/oauth/render/discord` 会重定向到 `?error=oauth_provider`)。scope 由后端固定为 `identify email`,无需在 Portal 额外设置。
不填后端也不报错,但登录页的 Discord 按钮照样显示,点了会回到 `/login?error=oauth_provider`(`/oauth/render/discord` 判定未配置)。scope 由后端固定为 `identify email`,无需在 Portal 额外设置。

### 4. 启动后端服务
按以下任一方式启动:
Expand Down Expand Up @@ -166,7 +166,8 @@ Get-Content .env | Where-Object { $_ -match '^[^#].+=' } | ForEach-Object {
默认接口入口:`http://127.0.0.1:8080`

### 5. 调用示例接口
内置种子账号:
本地种子账号(来自 `docker/init-db/init.sql`,只存在于本地 docker 库和测试库;
生产跑的 `schema.sql` 不 seed 任何可登录账号,见 SECURITY.md INV-011):
- `admin / Admin@123456`
- `alice / Alice@123456`

Expand Down
Loading