Files
Enterprise-Knowledge-Base/.env.lite.example
T
wizardchen a3411899cf fix(docreader/auth): harden gRPC TLS/Token rollout from #1359
Follow-up to #1359. Addresses a set of correctness and security gaps in
the initial docreader auth implementation.

- docker-compose: inject GRPC_TLS_*/GRPC_TLS_SERVER_NAME/GRPC_AUTH_TOKEN
  into the WeKnora-app service. Without this the Go client never saw the
  knobs, so enabling token auth on the server broke every RPC.
- client: bind tokenAuth.RequireTransportSecurity() to TLSEnabled so a
  bearer token cannot be sent over an insecure channel once TLS is on.
- server: load_tls_credentials now raises TLSConfigError on misconfig
  (cert/key missing, file unreadable, mTLS without CA); main.py exits 1
  instead of silently downgrading to insecure.
- server: replace endswith("/Check"|"/Watch") health bypass with exact
  match against /grpc.health.v1.Health/{Check,Watch}.
- server: compare tokens with hmac.compare_digest, warn on tokens < 16B.
- server: AuthInterceptor now returns an abort handler matching the
  original RPC kind (unary/stream) and uses context.abort, so streaming
  RPCs surface UNAUTHENTICATED instead of INTERNAL.
- internal/infrastructure/docparser/grpc_parser.go: drop the duplicated
  TLS/tokenAuth block and reuse docreader/client.LoadAuthConfigFromEnv +
  BuildDialOptions. Single source of truth for client-side auth.
- Add GRPC_TLS_SERVER_NAME (client SNI override) and
  GRPC_MTLS_REQUIRE_CLIENT_CERT (server explicit mTLS toggle); document
  the differing CA semantics between client and server in .env*.example.
- Reject half-configured client mTLS (cert XOR key) loudly.
- Fix missing trailing newline in .env.lite.example.

Verified locally: go build ./... and go vet ./... clean; auth.py
fail-fast / token paths smoke-tested.
2026-05-16 21:45:56 +08:00

76 lines
2.6 KiB
Bash
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.
# WeKnora Lite 配置模板
# 复制此文件为 .env.lite 并按需修改
# cp .env.lite.example .env.lite
GIN_MODE=debug
# 日志级别,可选值:debug, info, warn, error, fatal
LOG_LEVEL=debug
# 可选:日志文件绝对路径;未配置时,macOS .app 默认写入
# ~/Library/Logs/WeKnora Lite/WeKnora Lite.log
# LOG_PATH=/absolute/path/to/weknora-lite.log
# === 数据库 ===
# macOS .app 中相对路径会自动重定向到
# ~/Library/Application Support/WeKnora Lite/data/
DB_DRIVER=sqlite
DB_PATH=./data/weknora.db
# === 检索引擎(FTS5 + sqlite-vec)===
RETRIEVE_DRIVER=sqlite
# === 文件存储 ===
STORAGE_TYPE=local
LOCAL_STORAGE_BASE_DIR=./data/files
# === 流管理(内存,无 Redis)===
STREAM_MANAGER_TYPE=memory
# === LLM 服务 ===
# Ollama 本地服务(默认地址,按需修改)
OLLAMA_BASE_URL=http://127.0.0.1:11434
# 如使用其他 OpenAI 兼容服务,取消注释:
# OPENAI_API_KEY=sk-xxx
# OPENAI_BASE_URL=https://api.openai.com/v1
# === 安全配置(生产环境请务必修改!)===
TENANT_AES_KEY=CHANGE-ME-32-char-secret-key!!!!
JWT_SECRET=CHANGE-ME-jwt-secret
# === 功能开关 ===
NEO4J_ENABLE=false
WEKNORA_SANDBOX_MODE=disabled
ENABLE_GRAPH_RAG=false
DISABLE_REGISTRATION=false
# === Langfuse 可观测性(可选) ===
# 追踪 chat / embedding / rerank / VLM / ASR 的 prompt、响应与 token 消耗。
# 同时填了 PUBLIC_KEY 和 SECRET_KEY 就会自动启用,详见 docs/Langfuse集成.md。
# LANGFUSE_PUBLIC_KEY=pk-lf-xxxxxxxx
# LANGFUSE_SECRET_KEY=sk-lf-xxxxxxxx
# LANGFUSE_HOST=https://cloud.langfuse.com
# === 性能 ===
CONCURRENCY_POOL_SIZE=3
# Docreader 地址
DOCREADER_ADDR=127.0.0.1:50051
# Docreader 传输方式
DOCREADER_TRANSPORT=grpc
# gRPC TLS 配置(可选)
# GRPC_TLS_ENABLED=false
# GRPC_TLS_CERT=/path/to/server.crt # server: 必填;client: mTLS 时填
# GRPC_TLS_KEY=/path/to/server.key # 同上
# GRPC_TLS_CA=/path/to/ca.crt # client: 校验 server 证书用;server: mTLS 时签发客户端证书的 CA
# GRPC_TLS_SERVER_NAME= # 可选;当 DOCREADER_ADDR 用 IP/与证书 CN 不一致时设为证书的 hostname
# GRPC_MTLS_REQUIRE_CLIENT_CERT=false # server 端:true 时强制要求客户端证书(mTLS)
# gRPC 认证 Token(可选,客户端和服务端需配置相同的值)
# 注意:启用 GRPC_AUTH_TOKEN 时强烈建议同时启用 TLS,否则 token 会以明文随
# 每次 RPC 在网络上传输。当 GRPC_TLS_ENABLED=true 时客户端会拒绝在不安全
# 的连接上发送 token。
# GRPC_AUTH_TOKEN=your-secret-token-at-least-16-bytes