topfans/backend/services/userService
zerosaturation b7022d2dc1 fix(backend): auth boundary — trusted identity from ctx (batch 2)
- 新增 pkg/authctx: 从 Dubbo attachment/gRPC metadata 提取可信 user_id/star_id,
  统一覆盖 req 同名字段, 缺身份返 Unauthenticated。
- 各 provider 接入(堵身份伪造/越权):
  * moderation SubmitReport 等 6 RPC(举报人伪造)
  * asset CheckAssetLike/GetAssetQrcode/TrackShare(点赞/分享归因伪造)
  * social CheckFriendship(修 starID=0 隐私预言机)
  * activity PurchaseItem/BatchPurchaseItem(水晶扣费伪造)等 5 RPC
  * gallery/aiChat/task/notification 迁移 authctx, 删散落 extractUserInfo*
- social 正确性: GetUserLikedAssets OR 显式分组(防御); GetRandomUsersByStar 真随机(去 rand.Seed)。
- gateway: /auth/validate 移入 AuthMiddleware 保护组(/refresh 保留,依赖注入身份)。
- 删 userService 已迁移死函数; notification 缺身份错误码统一为 Unauthenticated。
- 各 provider 单测(伪造身份被覆盖 + 缺身份拒绝)。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 01:12:35 +08:00
..
config
configs
middleware fix(backend): auth boundary — trusted identity from ctx (batch 2) 2026-07-23 01:12:35 +08:00
mq
provider feat:增加忘记密码的功能 2026-07-09 19:00:03 +08:00
repository fix(backend): financial correctness — settlement/hours/mint idempotency (batch 1) 2026-07-23 01:11:54 +08:00
service feat:增加忘记密码的功能 2026-07-09 19:00:03 +08:00
test
go.mod
go.sum
INIT.md
main.go
README.md
UPDATE_FAN_PROFILE_SOCIAL_IMPLEMENTATION.md

User Service

用户与认证服务

功能

  • 用户注册、登录、登出
  • JWT Token 生成、刷新、验证
  • 用户基本信息管理
  • 粉丝档案管理
  • 粉丝身份切换

启动

# 开发环境
go run main.go

# 生产环境
go run main.go \
  --db-host=localhost \
  --db-port=5432 \
  --db-user=your_user \
  --db-password=your_password \
  --db-name=top-fans \
  --port=50051

环境变量

也可以通过环境变量配置:

export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=haihuizhu
export DB_PASSWORD=admin
export DB_NAME=top-fans
export SERVER_PORT=50051