← ClaudeAtlas

reset-user-passwordlisted

Reset a user's password in the production database (break-glass — no self-service reset endpoint exists). User-invoked only.
hyhmrright/Confer · ★ 3 · Data & Documents · score 72
Install: claude install-skill hyhmrright/Confer
破窗操作:直接重置生产库中某个用户的密码。Confer **没有自助/管理员密码重置端点**,密码以 Argon2id 哈希存于 `users.password_hash`。此 skill 把已验证的手动流程固化下来,避免每次临场摸索。 **前置说明(已踩过的坑)** - 生产库角色是 `confer`(不是默认 `postgres`),库名也是 `confer`,见 `docker-compose.prod.yml`�� - gateway 容器跑 **Bun**,而 `bun -e`/eval 上下文无法解析 node_modules import;可行办法是**写一个真实的 `.cjs` 文件、用绝对路径 `require()` argon2**,再用 bun 执行。 - `argon2.verify(hash, password)` 从哈希串自带的参数解码校验,所以只要用容器里的 argon2 生成一个合法 Argon2id 哈希即可,无需手工对齐 m/t/p 参数。 **步骤** 1. 确认目标用户名与新密码(与用户口头确认,**切勿**把密码写进会被记录的命令日志/提交里)。先核对账号存在: ```bash docker compose -f docker-compose.prod.yml exec postgres \ psql -U confer -d confer -c \ "select id, username, role from users where username = '<USERNAME>';" ``` 2. 在 gateway 容器内生成 Argon2id 哈希(真实 `.cjs` 文件 + 绝对路径 require,避开 Bun eval 限制)。用 `read -rs` 读入新密码(不回显、不进 shell 历史),再经 **stdin 管道**送进容器——`printf` 是 shell 内建,密码不进任何进程的 argv(`ps`/`/proc` 都看不到)。**不要**用 `-e NEWPW="$NEWPW"`:那会把明文塞进 `docker` 的 argv: ```bash read -rs NEWPW # 输入新密码后回车(终端不回显) printf '%s\n' "$NEWPW" | docker compose -f docker-compose.prod.yml exec -T gateway sh -c ' IFS= read -r PW; export PW cat > /tmp/hash.cjs <<EOF const argon2 = require(process.cwd() + "/node_modules/argon2/argon2.cjs"); argon2.hash(process.env.PW).then((h) => process.stdout.write(h)); EOF bun /tmp/hash.cjs; echo; rm -f /tmp/hash.cjs' ``` (`-T` 关闭 TTY 分配,否则管道 stdin 进不去;容器内 `read` 收下密码、`export PW` 只进环境不进 argv。)若 `node_modules/argon2/argon2.cjs` 不在 WORKDIR 下,先 `docker compose