Files
OJ2/.env.example
yuetsh b7adf2993d fix(阶段3): 去掉判题机 token 的弱默认值
F5:token 校验实现本身是对的(用了 timingSafeEqual),问题是缺省值
"oj2-dev-token" 写死在仓库里 —— 写死在仓库里的 token 等于没有 token。

后端改为对齐旧后端 options/options.py:93 的 fail-safe:
env 缺失时生成随机值并在启动日志里告警,判题机连不上,但不会静默用弱默认值。
compose 改为 ${OJ2_JUDGE_TOKEN:?...},未设置直接报错退出。

本地开发怎么设写在 docker/compose.dev.yml 顶部与 .env.example 里:
两个变量名不同(判题机镜像认 TOKEN,后端认 JUDGE_SERVER_TOKEN)但值必须相同。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 01:59:27 -06:00

13 lines
612 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
DATABASE_URL=postgres://onlinejudge:onlinejudge@localhost:5433/onlinejudge
REDIS_URL=redis://localhost:6380
JUDGE_SERVER_URL=http://localhost:8081
# 判题机 token自己生成不要用固定值。
# TOKEN=$(openssl rand -hex 32)
# echo "JUDGE_SERVER_TOKEN=$TOKEN" >> .env # 后端读这里
# echo "OJ2_JUDGE_TOKEN=$TOKEN" >> docker/.env # 判题机容器读这里,两边必须一致
# 留空的话后端会随机生成一个并在启动日志里告警,判题机心跳会被 403 挡掉。
JUDGE_SERVER_TOKEN=
JUDGE_CONCURRENCY=2
OJ2_DEV_USERNAME=student
OJ2_DEV_PASSWORD=student123