Skip to content

feat(profile): 密钥管理入口 (Infisical) + CONTRIBUTING 基础设施访问段#303

Merged
longsizhuo merged 3 commits intomainfrom
feat/admin-secrets-card
Apr 17, 2026
Merged

feat(profile): 密钥管理入口 (Infisical) + CONTRIBUTING 基础设施访问段#303
longsizhuo merged 3 commits intomainfrom
feat/admin-secrets-card

Conversation

@longsizhuo
Copy link
Copy Markdown
Member

变更

前端代码

  • 新增 DeveloperToolsIfOwner 组件:个人主页顶部加 "密钥管理 ↗" 按钮,只对主页本人可见(路人看不到)
  • 和 AdminLinkIfOwnerAdmin 刻意分开——这个对所有登录协作者开放,Infisical 内部按 project RBAC 管权限细分
  • 按钮跳转 https://secrets.involutionhell.com(自托管 Infisical)
  • Umami 埋点 profile_devtools_secrets_click

CONTRIBUTING.md 新增 "🔐 基础设施访问" 段

  • 服务一览表:主站 / 后端 / Infisical / pgAdmin / Umami 各自的登录方式 + 访问权限
  • 怎么申请 admin 角色(走 superadmin 勾选,不要手工 INSERT user_accounts)
  • .env 文件位置 + prod/dev 故意不统一的理由(链到 wiki 本次改动日志)
  • 个人主页的开发者入口说明
  • Spring Boot dev source .env 启动姿势

相关 PR

  • backend: involutionhell-backend#14 — /api/admin/devtool-check 端点
  • wiki: Changelog 2026-04-17 Self-Hosted Infra — 完整架构变更记录

部署顺序

  1. 先合 backend PR feat(home): 完善首页页面内容 #14 → CI redeploy → /api/admin/devtool-check 生效
  2. 再合本 PR → Vercel redeploy → 用户登录主站后点按钮进 Infisical

和 AdminLinkIfOwnerAdmin 刻意分开:AdminLink 是 admin 专属入口,这个对所有登录
用户开放(只要访问的是自己主页)。对应的访问控制不在前端——Infisical 自己有
GitHub OAuth + project-level RBAC,非 admin 协作者登录后只看得到自己有权限的
secrets。

- 新加 DeveloperToolsIfOwner client 组件:owner 判定条件和 AdminLinkIfOwnerAdmin
  保持一致(githubId 或 username 任一匹配即视为本人)
- profile 页按钮栏里插在 AdminLink 前,顺序:编辑 → 密钥管理 → 管理员界面 → 排行
- data-umami-event 埋点 profile_devtools_secrets_click,方便看谁在用
- target=_blank 到 secrets.involutionhell.com(自托管 Infisical 实例)
新协作者进来要知道怎么登主站 / Infisical / pgAdmin,怎么申请 admin 角色,
.env 文件的分布与规则。之前这些都在脑子里或散在 wiki 里,CONTRIBUTING
作为贡献指南得自带一份快速索引。

- 服务一览表:谁能进 / 登录方式
- admin 权限申请流程(别手工 insert user_accounts 踩孤儿坑)
- .env 文件位置和为什么 prod/dev 故意不一样(链到 wiki changelog)
- 个人主页的开发者自助入口说明
- Spring Boot 本地启动的 source .env 姿势(memory 里的 feedback_ih_backend_dev_start)

放在 🚀 开发环境 和 📚 文档规范 之间,让人 setup 完环境后紧接着看到。
Copilot AI review requested due to automatic review settings April 17, 2026 22:58
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
involutionhell-github-io Ready Ready Preview, Comment Apr 17, 2026 11:22pm
website-preview Ready Ready Preview, Comment Apr 17, 2026 11:22pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

为个人主页增加一个仅“主页本人”可见的开发者工具入口(当前指向自托管 Infisical 密钥管理),并在 CONTRIBUTING.md 中补充基础设施访问说明,帮助协作者了解各服务的访问方式与权限申请流程。

Changes:

  • 在个人主页按钮区新增 DeveloperToolsIfOwner,渲染 “密钥管理 ↗” 外链并增加 Umami 埋点
  • 新增 DeveloperToolsIfOwner 客户端组件:基于 useAuth() 判断“已登录 + 主页 owner”
  • CONTRIBUTING.md 增加“🔐 基础设施访问”章节并整理部分 Markdown 格式空行

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
app/u/[username]/page.tsx 在个人主页按钮栏中加入开发者工具入口组件
app/u/[username]/DeveloperToolsIfOwner.tsx 新增仅 owner 可见的 Infisical 外链按钮 + Umami 事件
CONTRIBUTING.md 新增基础设施访问说明与本地启动/环境变量相关说明

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +44
<Link
href="https://secrets.involutionhell.com"
target="_blank"
rel="noopener noreferrer"
className="font-mono text-[11px] uppercase tracking-widest px-2 py-1 border border-[var(--foreground)] text-[var(--foreground)] hover:bg-[var(--foreground)] hover:text-[var(--background)] transition-colors font-bold"
data-umami-event="profile_devtools_secrets_click"
title="Infisical 密钥管理(GitHub OAuth 登录,按 project 权限查看)"
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

href is hard-coded to the production Infisical domain. Other “open external infra” links in the codebase are configurable via a NEXT_PUBLIC_* env override (e.g. pgAdmin uses NEXT_PUBLIC_PGADMIN_URL), which makes preview deployments / self-host / domain changes possible without code changes. Consider reading the URL from an env var (e.g. NEXT_PUBLIC_INFISICAL_URL) and documenting it in .env.sample.

Copilot uses AI. Check for mistakes.
Comment thread CONTRIBUTING.md
Comment on lines +358 to +364
| 用途 | URL | 谁能进 | 登录方式 |
| ------------ | ----------------------------------------------- | --------------------------------------- | --------------------------------------- |
| 主站 | `https://involutionhell.com` | 所有登录用户 | GitHub OAuth |
| 后端 API | `https://api.involutionhell.com` | — (内部调用) | sa-token (cookie/header) |
| **密钥管理** | `https://secrets.involutionhell.com` | **所有登录协作者**,按 project 权限查看 | GitHub OAuth(复用主站 App) |
| 数据库管理 | `https://api.involutionhell.com/admin/pgadmin/` | **仅 admin** | 主站 cookie 自动通过 Caddy forward_auth |
| 网站分析 | `https://umami.involutionhell.com` | **仅 admin** | 本地 umami 账号 |
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “后端 API” row says auth is sa-token (cookie/header), but the frontend code actually sends the token under the satoken header and syncs a satoken cookie (see lib/use-auth.tsx). Please clarify the exact header/cookie key names here to avoid misconfiguration when people try to call the API directly.

Suggested change
| 用途 | URL | 谁能进 | 登录方式 |
| ------------ | ----------------------------------------------- | --------------------------------------- | --------------------------------------- |
| 主站 | `https://involutionhell.com` | 所有登录用户 | GitHub OAuth |
| 后端 API | `https://api.involutionhell.com` | — (内部调用) | sa-token (cookie/header) |
| **密钥管理** | `https://secrets.involutionhell.com` | **所有登录协作者**,按 project 权限查看 | GitHub OAuth(复用主站 App) |
| 数据库管理 | `https://api.involutionhell.com/admin/pgadmin/` | **仅 admin** | 主站 cookie 自动通过 Caddy forward_auth |
| 网站分析 | `https://umami.involutionhell.com` | **仅 admin** | 本地 umami 账号 |
| 用途 | URL | 谁能进 | 登录方式 |
| ------------ | ----------------------------------------------- | --------------------------------------- | ---------------------------------------------------------- |
| 主站 | `https://involutionhell.com` | 所有登录用户 | GitHub OAuth |
| 后端 API | `https://api.involutionhell.com` | — (内部调用) | sa-tokenheader: `satoken` / cookie: `satoken` |
| **密钥管理** | `https://secrets.involutionhell.com` | **所有登录协作者**,按 project 权限查看 | GitHub OAuth(复用主站 App) |
| 数据库管理 | `https://api.involutionhell.com/admin/pgadmin/` | **仅 admin** | 主站 cookie 自动通过 Caddy forward_auth |
| 网站分析 | `https://umami.involutionhell.com` | **仅 admin** | 本地 umami 账号 |

Copilot uses AI. Check for mistakes.
Comment thread CONTRIBUTING.md
Comment on lines +374 to +379
- 本地 dev:
- 后端:`involution-hell-project/backend/.env`(`set -a && . ./.env && set +a` 注入 Spring Boot)
- 前端:`involution-hell-project/frontend/.env`
- 生产:`/home/ubuntu/involution-hell/.env`(**只在部署机**,不在仓库里;CI 不覆盖)
- 两份 .env **故意有差异**(PGHOST / SERVER_PORT / AUTH_URL)—— 不要强行统一,参见 wiki [Changelog 2026-04-17](https://github.com/InvolutionHell/involutionhell/wiki/Changelog-2026-04-17-Self-Hosted-Infra) 的架构说明
- **所有秘密值**将来会迁到 Infisical 单一真源,`.env` 只存极少数 bootstrap 配置。改动期间前后仓两份并存,改值要同步改两处
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .env paths here don’t match this repository’s layout (this repo has .env.sample at the root and typically uses .env.local for Next.js; there is no frontend/ directory in-repo). Please rewrite this section to describe the env file location(s) for this repo explicitly, and (if needed) separately describe the external backend repo’s .env so contributors don’t create files in non-existent paths.

Suggested change
- 本地 dev:
- 后端:`involution-hell-project/backend/.env``set -a && . ./.env && set +a` 注入 Spring Boot)
- 前端:`involution-hell-project/frontend/.env`
- 生产:`/home/ubuntu/involution-hell/.env`**只在部署机**,不在仓库里;CI 不覆盖)
- 两份 .env **故意有差异**(PGHOST / SERVER_PORT / AUTH_URL)—— 不要强行统一,参见 wiki [Changelog 2026-04-17](https://github.com/InvolutionHell/involutionhell/wiki/Changelog-2026-04-17-Self-Hosted-Infra) 的架构说明
- **所有秘密值**将来会迁到 Infisical 单一真源,`.env` 只存极少数 bootstrap 配置。改动期间前后仓两份并存,改值要同步改两处
- **本仓库(当前仓库)**
- 根目录的 `.env.sample` 是模板;本地开发时按需在**仓库根目录**创建 `.env.local`
- 这个仓库里**没有** `frontend/` 目录,不要创建 `frontend/.env`
- **外部后端仓库(如你同时在本地跑后端)**
- 后端的 `.env`**后端仓库自己的根目录/约定位置**,不在当前仓库内
- 如需注入 Spring Boot,进入后端仓库后再使用该仓库自己的 `.env`(例如 `set -a && . ./.env && set +a`
- **生产环境**`/home/ubuntu/involution-hell/.env`**只在部署机**,不在当前仓库里;CI 不覆盖)
- 不同环境 / 不同仓库的 `.env` **故意有差异**(如 PGHOST / SERVER_PORT / AUTH_URL)—— 不要强行统一,参见 wiki [Changelog 2026-04-17](https://github.com/InvolutionHell/involutionhell/wiki/Changelog-2026-04-17-Self-Hosted-Infra) 的架构说明
- **所有秘密值**将来会迁到 Infisical 单一真源,`.env` 只存极少数 bootstrap 配置。改动期间若前后端仓库同时依赖本地配置,改值时请分别同步到各自仓库

Copilot uses AI. Check for mistakes.
Comment thread CONTRIBUTING.md
./mvnw spring-boot:run
```

前端 `BACKEND_URL` 指 `http://localhost:8081`,前后一致。
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line hard-codes BACKEND_URL as http://localhost:8081, but the repo’s .env.sample currently documents BACKEND_URL=http://localhost:8080. To prevent local dev confusion, either align the port here with .env.sample or phrase it as “set BACKEND_URL to your backend’s local address (see .env.sample)”.

Suggested change
前端 `BACKEND_URL` `http://localhost:8081`,前后一致
前端 `BACKEND_URL` 请设置为你本地后端的访问地址,具体示例请参见 `.env.sample`,并确保前后一致

Copilot uses AI. Check for mistakes.
Comment thread CONTRIBUTING.md Outdated

登录主站后,访问**自己**的个人主页 `/u/<你的 github id>`,在顶部按钮栏能看到:

- **密钥管理 ↗**(所有登录协作者可见) → 跳 Infisical
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this list you say “密钥管理 ↗(所有登录协作者可见)”, but the implementation only renders the button when the viewer is the profile owner (and logged in). Please reword this bullet to reflect the actual visibility rule (e.g. “所有登录协作者在访问自己主页时可见/仅本人可见”) to avoid readers thinking they’ll see it on others’ profiles.

Suggested change
- **密钥管理 ↗**所有登录协作者可见) → 跳 Infisical
- **密钥管理 ↗**所有登录协作者在访问自己主页时可见) → 跳 Infisical

Copilot uses AI. Check for mistakes.
CR 指出 '所有登录协作者可见' 有歧义——按钮实现只在本人访问自己主页时
渲染,路人和其他登录用户在别人主页上看不到。Infisical 站本身才是对所有协作
者开放。分清楚两层语义避免贡献者迷惑。
@longsizhuo longsizhuo merged commit cce5335 into main Apr 17, 2026
5 of 7 checks passed
@longsizhuo longsizhuo deleted the feat/admin-secrets-card branch April 17, 2026 23:11
@longsizhuo longsizhuo restored the feat/admin-secrets-card branch April 17, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants