Files
hi-server/pkg/constant/context.go
T
shanshanzhong147 92cf2921dd 修复(#3): 抽奖 Stage 1 后台审计 IP/UA 丢失 + 冒烟脚本 Bearer 前缀
Closes HIF-3 (Stage 1 P1 defects from QA smoke report)

F2: admin_action_log.ip / user_agent 恒为空
- 根因:requestMeta 从 ctx 读裸字符串 key,全库无 writer 塞
- 修复:新增 AdminMetaMiddleware 用 typed constant.CtxKeyIP / CtxKeyUserAgent
- 挂载:lottery admin 组末尾(不 gate access)
- 回归护栏:UsesTypedKey + IgnoresBareStringKeys 双向断言 typed key,防止未来退化回裸字符串

F3: qa/lottery/stage1_curl.sh Bearer 前缀
- 删除两处 Bearer 前缀 + 加注释说明 ppanel AuthMiddleware 不 strip

单测 5 用例全绿;scope 严格限于 lottery admin 组,其它路径零改动;无 DB 变更。

Merged: architect review 后,将触发 staging 二次部署 — 期望这次能一并解决 shanshanzhong147 手工 SSH 后 Lottery.Enable=true 未生效的问题(若真是 mount/restart 未正确 pick up)。
2026-07-09 07:45:58 -07:00

26 lines
1.0 KiB
Go

package constant
type CtxKey string
const (
CtxKeyUser CtxKey = "user"
CtxKeySessionID CtxKey = "sessionId"
CtxKeyRequestHost CtxKey = "requestHost"
CtxKeyPlatform CtxKey = "platform"
CtxKeyPayment CtxKey = "payment"
CtxLoginType CtxKey = "loginType"
LoginType CtxKey = "loginType"
CtxKeyIdentifier CtxKey = "identifier"
CtxKeyDeviceID CtxKey = "deviceId"
CtxKeyIncludeExpired CtxKey = "includeExpired"
CtxKeyAPIVersionUseLatest CtxKey = "apiVersionUseLatest"
CtxKeyAPIHeaderRaw CtxKey = "apiHeaderRaw"
CtxKeyHasAppId CtxKey = "hasAppId"
// CtxKeyIP / CtxKeyUserAgent are populated by AdminMetaMiddleware for
// audit-writing logic (admin_action_log.ip / user_agent). Both keys use
// the typed CtxKey so ctx.Value lookups collide-safely with any bare-string
// writers a future middleware might accidentally introduce.
CtxKeyIP CtxKey = "ip"
CtxKeyUserAgent CtxKey = "user_agent"
)