Repository navigation
Conversation
给 bi_datasource / bi_dataset / bi_chart 补 owner_id(INTEGER 可空 + 索引), 存量行回填系统占位 id 0(model.SystemOwnerID,预留、永不与 bi_user.id 自增起点相碰)。 写路径 Create 显式打占位;Update 整行更新排除 owner_id(归属不随更新改写)。 读路径零行为变化:OwnerID 只在 bun model 上、json:"-",entity/契约不含它。 - 迁移 00009:可重放幂等,down 可用(已在隔离 PG18 上验 up/幂等/列/索引/回填/down)。 - tenant_id 归 Phase C(R-03),本条不带;bi_share 已由 00008 退役,不补列。 - 类型取 INTEGER 与既有预留列(bi_query/bi_dashboard/bi_dashboard_folder)一致, 偏离 issue 文字里的 BIGINT,一致性优先。 - 测试:三表各加 Create-writes-owner_id / Update-excludes-owner_id 的 sqlmock 用例。
账号体系地基:bi_user(bcrypt 口令,首个用户即 admin)+ bi_token(不透明 token, 库内只存 sha256 + 可识别前缀,明文仅签发时回显一次),会话与 PAT 共用同一校验中间件。 - 引导式注册:仅当无存活用户时开放,产出 admin 并在同一事务把 L0 占位 owner_id 的行 认到首个管理员名下(#183 验收 6,衔接 #171 的 owner_id)。之后注册关闭。 - 会话 Token 24h;Login 校验 bcrypt、签发;Verify 单次 DB 查(无签名/缓存)→ 撤销即时生效。 - Bearer 中间件:区分 session / PAT,allowPAT=false 时拒绝 PAT 调用户管理端点(#184 验收 3 的守卫住这里)。 - 端点(渐进强制,不动现有 40 个):POST /api/auth/register、/login; GET /api/auth/me、DELETE /api/auth/logout(后者用 DELETE:泛型路由对 POST 必绑 body,登出无 body 会 EOF)。 - 测试:token 原语/one-way、注册引导与二次拒绝、登录对错、Verify 命中/过期吊销、即时吊销, + 中间件缺 token/PAT 拒绝/放行(fake verifier,全绿)。 默认口径(待评审确认):不透明 token 存库(满足「撤销即时」)、bcrypt、引导式注册、渐进鉴权范围。 openapi 契约与登录/PAT 前端随 #184(PAT 管理页 + api-gen)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #183
做了什么
账号体系地基(R-82),后端全量:
00010建bi_user(bcrypt 口令;首个注册者 role=admin)+bi_token(会话与 PAT 共用一张表:只存sha256(raw)+ 短前缀,明文仅签发时回显一次,revoked_at/expires_at门控)。owner_id的行认到首个管理员名下(验收 6,衔接 [P0] R-22 三表欠账:bi_datasource/bi_dataset/bi_chart 落 owner_id #171)。之后注册关闭。Verify单次 DB 查(无签名、无缓存)→ 撤销即时生效(验收 4)。middleware.Bearer(svc, allowPAT):区分session/pat,allowPAT=false时拒绝 PAT 调用户管理端点(这是 [Phase C/触发式] R-83 Token 双轨:会话 Token(24h)+ 长期 PAT(面向 AI 工具/程序化访问) #184 验收 3「PAT 不得调管理端点」的守卫落点)。POST /api/auth/register、POST /api/auth/login、GET /api/auth/me、DELETE /api/auth/logout。采用口径(待评审确认)
x/crypto)口令哈希。Register的门槛即可。验证
go test -race ./...全绿(含contract_parity与既有 handler 测试;中间件新增独立包)。TestMigrationsUpToLatest(up + 幂等)通过。20200;登录签发;登出后原 token 立即20200(撤销即时);库内token_hash为 sha256、无明文泄露、口令为$2a$10$bcrypt。未随本 PR(归 #184)
Authorization相关 openapi 契约与make api-gen再生成。EOF 占位说明:openapi 里
Authorization: Bearer契约与前端登录页一并在 [Phase C/触发式] R-83 Token 双轨:会话 Token(24h)+ 长期 PAT(面向 AI 工具/程序化访问) #184 交付,便于一次跑通前端浏览器 E2E。