diff --git a/deploy/kubernetes/app-runtime/Chart.yaml b/deploy/kubernetes/app-runtime/Chart.yaml index 56fcd34402..8236c56230 100644 --- a/deploy/kubernetes/app-runtime/Chart.yaml +++ b/deploy/kubernetes/app-runtime/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: bisheng-app-runtime description: Open source namespace-scoped BiSheng application runtime version: 0.2.0 -appVersion: 3.1.0-alpha1-fix +appVersion: 3.1.0-alpha1-fix2 type: application diff --git a/docker/.env.example b/docker/.env.example index 24e2ded3ac..cb9dd5191c 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -14,8 +14,8 @@ CR_REGISTRY_PASSWORD=dataelem # Backend and worker share one image; OpenFGA and its migration share another. # CR release tags below are AMD64; on ARM64 append -arm64 to the five BISHENG service image tags. # Tag builds publish -amd64/-arm64 first; the formal tags are promoted after Release approval. -BISHENG_BACKEND_IMAGE=cr.dataelem.com/dataelement/bisheng-backend:v3.1.0-alpha1-fix -BISHENG_FRONTEND_IMAGE=cr.dataelem.com/dataelement/bisheng-frontend:v3.1.0-alpha1-fix +BISHENG_BACKEND_IMAGE=cr.dataelem.com/dataelement/bisheng-backend:v3.1.0-alpha1-fix2 +BISHENG_FRONTEND_IMAGE=cr.dataelem.com/dataelement/bisheng-frontend:v3.1.0-alpha1-fix2 # always: refresh published tags; missing: use cached images (also supports local acceptance builds). BISHENG_IMAGE_PULL_POLICY=always MYSQL_IMAGE=cr.dataelem.com/mysql:8.0 @@ -26,13 +26,13 @@ ETCD_IMAGE=cr.dataelem.com/quay.io/coreos/etcd:v3.5.5 MINIO_IMAGE=cr.dataelem.com/minio/minio:RELEASE.2023-03-20T20-16-18Z MILVUS_IMAGE=cr.dataelem.com/milvusdb/milvus:v2.5.10 # Full image reference replaces the former SANDBOX_IMAGE_TAG setting. -BISHENG_SANDBOX_IMAGE=cr.dataelem.com/dataelement/bisheng-sandbox:v3.1.0-alpha1-fix +BISHENG_SANDBOX_IMAGE=cr.dataelem.com/dataelement/bisheng-sandbox:v3.1.0-alpha1-fix2 # Optional FT profile: historical FT version, independent of platform tags. BISHENG_FT_IMAGE=cr.dataelem.com/dataelement/bisheng-ft:v0.5.0 BISHENG_FT_PORT=8000 # Optional app-runtime profile images. -BISHENG_RUNTIME_MANAGER_IMAGE=cr.dataelem.com/dataelement/bisheng-runtime-manager:v3.1.0-alpha1-fix -BISHENG_APP_PROXY_IMAGE=cr.dataelem.com/dataelement/bisheng-app-proxy:v3.1.0-alpha1-fix +BISHENG_RUNTIME_MANAGER_IMAGE=cr.dataelem.com/dataelement/bisheng-runtime-manager:v3.1.0-alpha1-fix2 +BISHENG_APP_PROXY_IMAGE=cr.dataelem.com/dataelement/bisheng-app-proxy:v3.1.0-alpha1-fix2 # Socket proxy uses separate architecture tags; the unsuffixed tag is AMD64. DOCKER_SOCKET_PROXY_IMAGE=cr.dataelem.com/tecnativa/docker-socket-proxy:0.3.0 # ARM alternative: set DOCKER_SOCKET_PROXY_IMAGE to cr.dataelem.com/tecnativa/docker-socket-proxy:0.3.0-arm64. diff --git a/docker/README.md b/docker/README.md index ca4fe8caee..049c5a2482 100644 --- a/docker/README.md +++ b/docker/README.md @@ -162,9 +162,9 @@ docker compose logs gateway 首次运行 install.sh 为各运行时身份生成不同随机密钥,重跑不会轮换。关闭 Vibe 时将实际 YAML 的 `app_runtime.enabled` 改为 false,并从 `.env` 的 `COMPOSE_PROFILES` 移除 app-runtime;保留数据。仅修改 profile 不会修改用户自管 YAML。沙箱按现有 endpoints/执行器配置关闭,已有会话的停用需要单独安排。 -模板服务 tag 跟随 v3.1.0-alpha1-fix,实际安装需使用包含本次变更的后端/运行时发行镜像。源码验证不表示镜像已构建、已推送或线上已更新。 +模板服务 tag 跟随 v3.1.0-alpha1-fix2,实际安装需使用包含本次变更的后端/运行时发行镜像。源码验证不表示镜像已构建、已推送或线上已更新。 -## 中间件凭据配置(v3.1.0-alpha1-fix) +## 中间件凭据配置(v3.1.0-alpha1-fix2) 仍使用本文开头的原命令。首次在同一安装过程中输入并确认密码;密钥、加密配置、组件凭据文件和版本参数由安装器自动管理。再次执行逐项选择是否改密,直接回车保留;选中项按提示隐藏输入并确认维护。失败修复后仍用原命令续跑,无需手动执行 keygen/prepare 或填写 bundle/key/revision。 diff --git a/docker/bisheng-sandbox/Dockerfile b/docker/bisheng-sandbox/Dockerfile index 9db192fee8..e2716757d6 100644 --- a/docker/bisheng-sandbox/Dockerfile +++ b/docker/bisheng-sandbox/Dockerfile @@ -1,6 +1,6 @@ # Isolation-environment image: backend venv + office binaries + runner HTTP. # Build from the repository root (same Dockerfile for amd64 / arm64): -# docker build -f docker/bisheng-sandbox/Dockerfile -t dataelement/bisheng-sandbox:v3.1.0-alpha1-fix . +# docker build -f docker/bisheng-sandbox/Dockerfile -t dataelement/bisheng-sandbox:v3.1.0-alpha1-fix2 . # # Derived from src/backend/base.Dockerfile: full uv.lock venv, LibreOffice, pandoc, # fonts, ffmpeg, plus the PPTD engine at /opt/pptd-runtime. Does NOT copy diff --git a/docker/helm/README.md b/docker/helm/README.md index 9d5d085b85..0d42320caf 100644 --- a/docker/helm/README.md +++ b/docker/helm/README.md @@ -3,11 +3,11 @@ 唯一父 Chart 为 [`bisheng/`](./bisheng/),完整教程见 [Chart README](./bisheng/README.md)。 运行控制面唯一源码在 `deploy/kubernetes/app-runtime`,代码沙箱唯一源码在 `docker/helm/bisheng-sandbox`;父 Chart 以固定版本本地依赖打包,避免复制后漂移。 -当前是 **3.1.0-alpha1-fix 源码改造**,尚未构建本次 Backend/Runtime Manager 镜像,未在新集群验收。不能把已有 3.0.0 镜像配到新 Chart 后宣称可安装。正式发布流程须提供同一版本镜像清单、真实 digest 和官方双架构运行目录,再运行 `scripts/package_helm.py`。 +当前是 **3.1.0-alpha1-fix2 源码改造**,尚未构建本次 Backend/Runtime Manager 镜像,未在新集群验收。不能把已有 3.0.0 镜像配到新 Chart 后宣称可安装。正式发布流程须提供同一版本镜像清单、真实 digest 和官方双架构运行目录,再运行 `scripts/package_helm.py`。 本目录不依赖私有 `k8s-product` 仓库,不包含任何客户集群地址或凭据,不安装 StorageClass/CSI,也不格式化节点磁盘。 -## 凭据密钥环(v3.1.0-alpha1-fix) +## 凭据密钥环(v3.1.0-alpha1-fix2) v3.1.0-beta2 起,所有 backend 镜像进程(含 render-settings 初始化容器)通过 `BS_SECRET_KEYS_FILE` 读取外部密钥环,镜像内不再有默认加密密钥。Chart 把密钥环投影到 `/run/settings-secrets/credential-keys/keys.json`(只读,0400),render-settings 用它把数据库、Redis 密码加密写进生成的 config.yaml,业务进程用它解密。 diff --git a/docker/helm/bisheng-sandbox/Chart.yaml b/docker/helm/bisheng-sandbox/Chart.yaml index 54303c9676..c516ff746c 100644 --- a/docker/helm/bisheng-sandbox/Chart.yaml +++ b/docker/helm/bisheng-sandbox/Chart.yaml @@ -3,7 +3,7 @@ name: bisheng-sandbox description: Isolation-environment runners for BiSheng (StatefulSet + headless Service). type: application version: 0.2.0 -appVersion: 3.1.0-alpha1-fix +appVersion: 3.1.0-alpha1-fix2 keywords: - bisheng - sandbox diff --git a/docker/helm/bisheng-sandbox/values.yaml b/docker/helm/bisheng-sandbox/values.yaml index 9c17e33242..08f4600e3e 100644 --- a/docker/helm/bisheng-sandbox/values.yaml +++ b/docker/helm/bisheng-sandbox/values.yaml @@ -3,7 +3,7 @@ fullnameOverride: '' nameOverride: code-runner image: repository: dataelement/bisheng-sandbox - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 pullPolicy: IfNotPresent digest: '' imagePullSecrets: [] diff --git a/docker/helm/bisheng/Chart.yaml b/docker/helm/bisheng/Chart.yaml index 5d0a14527a..c7da93577b 100644 --- a/docker/helm/bisheng/Chart.yaml +++ b/docker/helm/bisheng/Chart.yaml @@ -4,7 +4,7 @@ description: BiSheng standard platform, optional infrastructure, Vibe runtime an code sandbox type: application version: 0.2.0 -appVersion: 3.1.0-alpha1-fix +appVersion: 3.1.0-alpha1-fix2 keywords: - bisheng - llm diff --git a/docker/helm/bisheng/README.md b/docker/helm/bisheng/README.md index 6404fd4066..9f426bd5cb 100644 --- a/docker/helm/bisheng/README.md +++ b/docker/helm/bisheng/README.md @@ -2,7 +2,7 @@ ## 交付状态和前提 -这是 3.1.0-alpha1-fix 标准安装源码,包含正式初始化命令及运行协议变更。**本轮只完成代码与部署文件;配套镜像尚未构建,真实安装和双架构验收尚未执行。** 正式用户应使用包含 `files/image-set.json`、`files/runtime-catalog/catalog.json` 及锁文件的发行 Chart,不能将源码 Chart 配到旧版镜像。 +这是 3.1.0-alpha1-fix2 标准安装源码,包含正式初始化命令及运行协议变更。**本轮只完成代码与部署文件;配套镜像尚未构建,真实安装和双架构验收尚未执行。** 正式用户应使用包含 `files/image-set.json`、`files/runtime-catalog/catalog.json` 及锁文件的发行 Chart,不能将源码 Chart 配到旧版镜像。 运行前提:Kubernetes 1.28+、Helm 3.14+,Linux amd64 或 arm64 节点;支持实际执行 NetworkPolicy 的 CNI;API Server 能到达 Admission HTTPS Service。运维提供本集群 Pod/Service CIDR、DNS/API/内部平台访问范围,以及可用的持久存储。Chart 不安装存储驱动、不探测后宣称网络隔离成立、不修改节点 cgroup/磁盘。 diff --git a/docker/helm/bisheng/values.yaml b/docker/helm/bisheng/values.yaml index 426e6d19f8..cab80e389b 100644 --- a/docker/helm/bisheng/values.yaml +++ b/docker/helm/bisheng/values.yaml @@ -70,7 +70,7 @@ backend: replicaCount: 1 image: repository: dataelement/bisheng-backend - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 digest: '' pullPolicy: IfNotPresent resources: @@ -116,7 +116,7 @@ worker: replicaCount: 1 image: repository: dataelement/bisheng-backend - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 digest: '' pullPolicy: IfNotPresent resources: @@ -145,7 +145,7 @@ linsight: replicaCount: 1 image: repository: dataelement/bisheng-backend - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 digest: '' pullPolicy: IfNotPresent resources: @@ -175,7 +175,7 @@ beat: replicaCount: 1 image: repository: dataelement/bisheng-backend - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 digest: '' pullPolicy: IfNotPresent resources: @@ -203,7 +203,7 @@ frontend: replicaCount: 1 image: repository: dataelement/bisheng-frontend - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 digest: '' pullPolicy: IfNotPresent resources: @@ -674,7 +674,7 @@ sandbox: nameOverride: code-runner image: repository: dataelement/bisheng-sandbox - tag: v3.1.0-alpha1-fix + tag: v3.1.0-alpha1-fix2 pullPolicy: IfNotPresent digest: '' imagePullSecrets: [] diff --git a/docs/AUTH_WEB_SESSION_MIGRATION.md b/docs/AUTH_WEB_SESSION_MIGRATION.md new file mode 100644 index 0000000000..331fcd08be --- /dev/null +++ b/docs/AUTH_WEB_SESSION_MIGRATION.md @@ -0,0 +1,28 @@ +# Desktop / Work 网页会话统一到 auth + +对应问题 #2854。平台认证(签名、会话状态、身份/租户、父引用及活动续期)统一由用户域 auth 管理;Desktop、Web、Token Exchange 和 MCP 消费相同的认证接缝。工具/知识等资源的业务权限继续由现有 PermissionService 与资源服务校验,auth 不新增业务权限旁路。 + +## 新客户端协议 + +1. 宿主用有效平台 Bearer 调用 `POST /api/v1/auth/web-session`,响应 `data` 包含一次性 `ticket`、`consume_url`、60 秒票据期限以及子会话 `session_id`。原生父会话必须属于 bisheng-desktop 或 bisheng-mobile。 +2. 宿主只请求同源 `/api/v1/auth/web-session/consume?ticket=...`,使用 manual redirect。服务端原子消费票据,设置 `platform_access_` HttpOnly Cookie 和非秘密的 `platform_session_hint=`,303 返回 `/workspace`。票据不作为 Cookie 或 Access Token 使用,不发送至第三方,不跟随任意重定向。 +3. WebView 安装这一组 Cookie 后加载工作台;宿主 MCP/知识请求携带相同 Cookie 组合。也可直接使用有效平台 Bearer 调用业务服务,其校验仍经过 auth。不要混用不同身份的 Bearer/Cookie。 +4. 每个 MCP tools/call 在业务工具执行前经统一 auth Activity 检查父子会话和续期,之后再执行工具权限校验。父会话撤销后子会话不可继续调用。账号/企业切换与取消时丢弃旧异步返回及旧 Cookie,不将票据、Token 交给模型或 renderer。 + +## 兼容与废弃 + +| 旧入口 | 状态 | 替代 | +| --- | --- | --- | +| POST /api/v1/dsh/web-session | deprecated;兼容旧 DSH 和有效平台 Desktop 凭据,保留既有响应结构 | POST /api/v1/auth/web-session + GET consume | +| POST /api/v1/dsh/token(及 /api 兼容别名) | deprecated;旧票据交接暂保留,新平台刷新应迁移 | POST /api/v1/auth/refresh | +| POST /api/v1/dsh/logout(及 /api 兼容别名) | deprecated;保留旧凭据注销 | POST /api/v1/auth/logout | +| POST /api/v1/user/login | deprecated;保留旧登录适配 | POST /api/v1/auth/login | +| POST /api/v1/user/logout | deprecated;保留旧注销适配 | POST /api/v1/auth/logout | + +上述废弃接口通过 OpenAPI `deprecated=true` 标识;DSH 兼容接口额外返回 RFC 9745 `Deprecation` 日期响应头(2026-12-02 07:00 UTC)。没有声明删除日期。Desktop 浏览器授权/PKCE/identity_ticket 发起与回调仍是现有有效协议,本次不将它误标为已有完整替代。业务 MCP 路由保持原路径,它是工具业务入口,不承载新的凭据签发。 + +兼容期内,旧客户端可继续以旧 DSH 或有效平台 Desktop Token 创建短期网页 Cookie,已签发 Cookie 也继续验证;若关联平台 Token,验证和活动复核复用统一 auth,不再拿平台会话 ID 查旧 DSH 表。保留 c8fff9a 的设备续期、撤销及准入层回归覆盖,以及独立的 presence 路径修复。新客户端直接使用新协议,不在失败时回退旧接口。 + +## 交付边界 + +可以先发布兼容服务端,再分批升级 bisheng-work 企业插件;旧客户端继续使用旧桥接,新客户端使用 auth 票据。只修改服务端不会让已安装 Desktop 自动切换请求协议。未安装、未部署的源码变更不能作为 issue 的真实环境验收;最终应观察真实 MCP 搜索结果及来源链接,并复核注销、撤销、票据重放和身份不匹配拒绝。 diff --git a/docs/BISHENG_DESKTOP_TOKEN_EXCHANGE.md b/docs/BISHENG_DESKTOP_TOKEN_EXCHANGE.md index 69864dc33b..153a3b3931 100644 --- a/docs/BISHENG_DESKTOP_TOKEN_EXCHANGE.md +++ b/docs/BISHENG_DESKTOP_TOKEN_EXCHANGE.md @@ -23,6 +23,10 @@ scope=openid profile email 目标 `xpie` 必须是已启用的非内置应用;第一方平台会话换证不要求目标额外开启 Token Exchange Grant Type。第三方 OAuth 来源的换证授权规则保持不变。Scope 必须属于目标允许范围与 `openid/profile/email` 的交集。已验证的第一方平台会话静默换证:不需要两两 exchange policy,也不读取目标的 `require_consent` 或用户 OAuth 同意记录,不弹授权确认。该规则仅作用于第一方 Token Exchange;正常 OAuth 授权码登录和第三方来源换证仍遵循各自授权规则。目标启用状态、Scope、身份和租户绑定、父会话有效性及撤销检查继续执行。 +## 网页与 MCP 桥接 + +新 Desktop/Work 统一使用 auth 一次性网页票据和平台 Cookie,凭据验证及活动复核由 auth 共享入口管理。旧 `/dsh/web-session`、`/dsh/token` 和 `/dsh/logout` 适配接口标记 deprecated;浏览器授权回调体验保留。协议及兼容范围见 [auth 网页会话迁移](AUTH_WEB_SESSION_MIGRATION.md)。 + ## 兼容边界 旧 `/api/v1/dsh/*` 登录协议及既有内置 OAuth `dsh-desktop` 注册保留兼容,不改写数据库标识,不把旧 DSH Token 冒充统一平台 Token。`bisheng-desktop` 是统一第一方会话标识;重新走一次原浏览器授权登录即可获取新会话。已存在的旧 DSH 会话不会被自动转换;客户端若严格校验旧 Token 的 typ/aud 或固定响应字段,需要适配统一平台 Token 结构,不能继续假设旧 DSH 专属 Token。这里的名称统一针对第一方认证标识和默认显示名称,既有 API 路径和软件包命名保持兼容。 diff --git a/features/v3.1.0-alpha1/003-platform-auth-session/design.md b/features/v3.1.0-alpha1/003-platform-auth-session/design.md index 762b3616b4..a930a5f920 100644 --- a/features/v3.1.0-alpha1/003-platform-auth-session/design.md +++ b/features/v3.1.0-alpha1/003-platform-auth-session/design.md @@ -149,7 +149,7 @@ flowchart LR | 事实(基线已核实,除注明计划) | 忽略后果 | 处理位置 | | --- | --- | --- | | DSH typ/aud、9 字段与 600 秒上限写死 | 直接发 30 天 Token 会被拒;全局放宽又混淆模型凭证用途 | `DshAccessService.decode` 保留;新 Platform codec 独立 | -| 旧 DSH 浏览器 Cookie 用旧网页封装但带可验证的 `dsh_web_session` | 一刀切拒绝所有旧封装会破坏旧桌面聊天/网页 | AuthJwt 旧桥接适配 → `validate_web_session` → 原 DSH Session,只有此分支保留 | +| DSH 浏览器 Cookie 保留旧网页封装;Redis 绑定的原凭证可能来自旧 DSH 或新平台 Desktop Session | 统一使用旧 DSH 活跃续期会把新平台 sid 查到旧表,出现查询正常、发消息 403/26107 | `validate_web_session` 先验证原凭证,再按 `platform_reference` 绑定 `DesktopPlatformActivity` 或 `DshSessionActivity`;不能放行任意旧网页 JWT | | 网关后端响应只有一个 token | 新网页没有 Refresh;不能靠“登录成功”证明续期可用 | SSO Sync 签发 + §6.4 Web 绑定 | | OAuth2 自动授权直接读 AuthJwt | 新平台登录后第三方仍被当未登录,形成回跳循环 | `oidc.py:_try_browser_user` 和 consent 的 UserPayload 接入新身份 façade;协议不变 | | 旧平台 JWT 的 sub 是 JSON,DSH 的 sub 是用户ID | 只替换 Cookie 签发会使 /user/info、WS 报错 | AuthJwt / LoginUser 统一结果适配,业务只读规范身份 | @@ -237,7 +237,7 @@ WebView consume 的 ticket 不承载 Access Token;响应 `Referrer-Policy:no-r | --- | --- | --- | | 旧桌面安装包、`/dsh/authorizations`、identity_ticket+PKCE | 保持请求、响应、客户端登记规则与授权交互 | 授权身份交给平台签发入口 | | 旧 `/dsh/token`、issuer/typ/kid/audience、DSH表 | 保持原期限与错误语义;兼容适配可复用通用算法,不改变线协议 | 新客户端用平台Token;旧版本的双读有明确退场版本后再删 | -| `/dsh/web-session` 与 `dsh_web_session` Cookie | 原换证和绑定继续有效;只接受经原DSH签名和Session验证的定向桥接,不能让任意旧网页JWT混入 | 使用平台受约束 Web 会话机制,删除专用换证 | +| `/dsh/web-session` 与 `dsh_web_session` Cookie | 原换证和绑定继续有效;原凭证由旧 DSH 或已适配的平台 Desktop 验证器校验,业务活动续期必须回到同一会话服务,不能让任意旧网页 JWT 混入 | 使用平台受约束 Web 会话机制,删除专用换证 | | DSH 模型访问/配额、插件 Broker、手机桌面绑定 | 原专用认证入口保持;不因平台Token上线就默认放行新Token | 按注册路由适配平台Principal,权限/配额仍由原业务判断 | | 全部退出、平台单点配置 | 不宣称覆盖历史DSH Session | 正式迁入平台Session后才纳入;不能首期提前改变其登录策略 | @@ -380,3 +380,7 @@ WebView consume 的 ticket 不承载 Access Token;响应 `Referrer-Policy:no-r ### 2026-11-30 Vibe 入口热修复 生产 `/apps/*` 与 `/admin` 循环跳转暴露了网页导航消费端遗漏。app-proxy 与正式/预览入口现按新平台会话选择和校验,不回退旧单登录记录;平台认证故障返回 unavailable。HTTP/WebSocket 上游均移除平台 Access、Refresh、选择标记及旧 Cookie,仅注入原有应用作用域身份。回归与基线对照见 `docs/reviews/vibe-platform-session-hotfix-20261130.md`。 + +### 2026-12-02 Desktop 内嵌聊天热修复 + +`validate_web_session` 与原生 `desktop_principal` 使用相同的会话类型分支:新平台 Desktop 绑定 `DesktopPlatformActivity`,旧 DSH 绑定 `DshSessionActivity`。普通查询不计业务活动;聊天在原凭证校验通过后仅续期当前设备,撤销后的 Cookie 仍拒绝。回归 `test/dsh/test_web_session_platform_activity.py` 保留真实 JWT、SQL 会话仓储、Cookie 换证和 `ScopedEndpoint` 准入;省略统一准入层会遗漏线上 403 的异常映射。 diff --git a/scripts/tests/test_helm_package.py b/scripts/tests/test_helm_package.py index 6a52b5be64..2945c15126 100644 --- a/scripts/tests/test_helm_package.py +++ b/scripts/tests/test_helm_package.py @@ -57,12 +57,12 @@ def artifacts(): ).encode() lock = { "schema_version": 1, - "release": "3.1.0-alpha1-fix", + "release": "3.1.0-alpha1-fix2", "catalog_sha256": hashlib.sha256(raw).hexdigest(), } image_set = { "schema_version": 1, - "release": "3.1.0-alpha1-fix", + "release": "3.1.0-alpha1-fix2", "source_revision": source, "runtime_contract": 2, "gateway_sql_contract": "1.8.0", @@ -74,7 +74,7 @@ def artifacts(): def test_complete_metadata_accepts_all_workloads_jobs_and_helpers(): image_set, raw, lock = artifacts() - assert len(mod.validate(image_set, raw, lock, version="3.1.0-alpha1-fix")) == 20 + assert len(mod.validate(image_set, raw, lock, version="3.1.0-alpha1-fix2")) == 20 @pytest.mark.parametrize( @@ -103,7 +103,7 @@ def test_incomplete_or_mixed_release_refused(change): raw = json.dumps(document).encode() lock["catalog_sha256"] = hashlib.sha256(raw).hexdigest() with pytest.raises(ValueError): - mod.validate(image_set, raw, lock, version="3.1.0-alpha1-fix") + mod.validate(image_set, raw, lock, version="3.1.0-alpha1-fix2") def test_package_stages_locked_sources_and_catalog_without_image_build( diff --git a/src/app-proxy/app_proxy/__init__.py b/src/app-proxy/app_proxy/__init__.py index f97b3e2de0..d0b72d6a89 100644 --- a/src/app-proxy/app_proxy/__init__.py +++ b/src/app-proxy/app_proxy/__init__.py @@ -14,4 +14,4 @@ it. """ -__version__ = "3.1.0-alpha1-fix" +__version__ = "3.1.0-alpha1-fix2" diff --git a/src/app-proxy/pyproject.toml b/src/app-proxy/pyproject.toml index fd96d89b12..db42d3ac9e 100644 --- a/src/app-proxy/pyproject.toml +++ b/src/app-proxy/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "bisheng-app-proxy" -version = "3.1.0a1+fix" +version = "3.1.0a1+fix2" description = "BiSheng hosted-app entry proxy — session check, header normalisation/injection, fallback pages and HTTP reverse proxy for /apps/{slug}" requires-python = ">=3.11" license = { text = "Apache-2.0" } diff --git a/src/app-proxy/uv.lock b/src/app-proxy/uv.lock index 95a90979ff..b80ae3afa0 100644 --- a/src/app-proxy/uv.lock +++ b/src/app-proxy/uv.lock @@ -35,7 +35,7 @@ wheels = [ [[package]] name = "bisheng-app-proxy" -version = "3.1.0a1+fix" +version = "3.1.0a1+fix2" source = { editable = "." } dependencies = [ { name = "fastapi" }, diff --git a/src/backend/bisheng/__init__.py b/src/backend/bisheng/__init__.py index 6f328b5f0c..1105153289 100644 --- a/src/backend/bisheng/__init__.py +++ b/src/backend/bisheng/__init__.py @@ -4,7 +4,7 @@ try: # SetujuciGo to automatic modification - __version__ = "3.1.0-alpha1-fix" + __version__ = "3.1.0-alpha1-fix2" except metadata.PackageNotFoundError: # Case where package metadata is not available. __version__ = "" diff --git a/src/backend/bisheng/dev_toolkit/artifacts/manifest.json b/src/backend/bisheng/dev_toolkit/artifacts/manifest.json index 92b092aeb6..eb509eae29 100644 --- a/src/backend/bisheng/dev_toolkit/artifacts/manifest.json +++ b/src/backend/bisheng/dev_toolkit/artifacts/manifest.json @@ -6,7 +6,7 @@ "sha256": "6fac8457ad951ebdb3725ac9cc795eb074daad31209ddee286879b7e92bb221b" }, "platform": { - "version": "3.1.0-alpha1-fix" + "version": "3.1.0-alpha1-fix2" }, "_note": "Generated by scripts/pack_cli_wheel.sh and scripts/pack_sdk_wheel.sh. Commit this file and the wheels beside it; the backend image cannot see src/bisheng-cli/ or src/bisheng-sdk/.", "sdk": { diff --git a/src/backend/bisheng/dsh/api/dependencies.py b/src/backend/bisheng/dsh/api/dependencies.py index 181cf92e94..ac1720ac80 100644 --- a/src/backend/bisheng/dsh/api/dependencies.py +++ b/src/backend/bisheng/dsh/api/dependencies.py @@ -7,6 +7,8 @@ from bisheng.dsh.access_runtime import DshRuntime, get_runtime, get_settings from bisheng.dsh.application.session_activity import DshSessionActivity from bisheng.dsh.domain.services.access import DshPrincipal +from bisheng.user.application.dsh_session import desktop_auth_error +from bisheng.user.application.platform_authentication import bind_platform_activity async def desktop_principal(request: Request, runtime: DshRuntime = Depends(get_runtime)) -> DshPrincipal: @@ -14,10 +16,8 @@ async def desktop_principal(request: Request, runtime: DshRuntime = Depends(get_ raise DshInvalidAccessTokenError() principal = await runtime.access.authenticate(request.headers["authorization"]) if principal.platform_reference is not None: - from bisheng.dsh.application.session_activity import DesktopPlatformActivity - - request.state.authenticated_activity = DesktopPlatformActivity( - runtime.platform_sessions, request.headers["authorization"][7:] + bind_platform_activity( + request, runtime.platform_sessions, request.headers["authorization"][7:], error_mapper=desktop_auth_error ) else: request.state.authenticated_activity = DshSessionActivity(runtime.sessions, principal) diff --git a/src/backend/bisheng/dsh/api/endpoints/local_auth.py b/src/backend/bisheng/dsh/api/endpoints/local_auth.py index 5657289e0a..3705018b56 100644 --- a/src/backend/bisheng/dsh/api/endpoints/local_auth.py +++ b/src/backend/bisheng/dsh/api/endpoints/local_auth.py @@ -47,7 +47,11 @@ async def authorization(body: AuthorizationRequest, request: Request, runtime=De return await runtime.authorizations.create(body, origin=await resolve_client_origin(request, runtime.settings)) -@router.post("/token") +@router.post( + "/token", + deprecated=True, + description="Legacy Desktop ticket/refresh adapter. Platform sessions refresh through POST /api/v1/auth/refresh; the browser ticket handoff remains supported during migration.", +) async def token(body: TokenRequest, request: Request, response: Response, runtime=Depends(get_runtime)): response.headers["Cache-Control"] = "no-store" await runtime.authorizations.rate("token", request.client.host if request.client else "unknown") @@ -73,7 +77,12 @@ async def token(body: TokenRequest, request: Request, response: Response, runtim return await issue_desktop_session(request, identity, binding) -@router.post("/logout", status_code=204) +@router.post( + "/logout", + status_code=204, + deprecated=True, + description="Legacy Desktop logout adapter. Platform sessions use POST /api/v1/auth/logout.", +) async def logout(request: Request, body: LogoutRequest | None = None, runtime=Depends(get_logout_runtime)): headers = request.headers.getlist("authorization") refresh = body.refresh_token if body else None diff --git a/src/backend/bisheng/dsh/api/endpoints/web_session.py b/src/backend/bisheng/dsh/api/endpoints/web_session.py index fd8d8d4a22..8c88619c56 100644 --- a/src/backend/bisheng/dsh/api/endpoints/web_session.py +++ b/src/backend/bisheng/dsh/api/endpoints/web_session.py @@ -10,7 +10,11 @@ router = APIRouter(route_class=DshRoute) -@router.post("/dsh/web-session") +@router.post( + "/dsh/web-session", + deprecated=True, + description="Deprecated Desktop bridge. Existing DSH and platform Desktop credentials remain supported during migration. New clients use POST /api/v1/auth/web-session and consume its one-time ticket.", +) async def web_session(request: Request, runtime: DshRuntime = Depends(get_runtime)): if len(request.headers.getlist("authorization")) != 1: raise DshInvalidAccessTokenError() diff --git a/src/backend/bisheng/dsh/api/responses.py b/src/backend/bisheng/dsh/api/responses.py index af0006f7eb..cab99f7d54 100644 --- a/src/backend/bisheng/dsh/api/responses.py +++ b/src/backend/bisheng/dsh/api/responses.py @@ -43,6 +43,8 @@ async def route(request: Request): response.headers["Cache-Control"] = "no-store" response.headers["Referrer-Policy"] = "no-referrer" response.headers["X-Request-ID"] = request.state.request_id + if self.deprecated: + response.headers["Deprecation"] = "@1796194800" capture = getattr(request.state, "audit_capture", None) if capture is not None: response = AuditObservedResponse(response, capture) diff --git a/src/backend/bisheng/dsh/application/session_activity.py b/src/backend/bisheng/dsh/application/session_activity.py index a7508fe2df..419a853004 100644 --- a/src/backend/bisheng/dsh/application/session_activity.py +++ b/src/backend/bisheng/dsh/application/session_activity.py @@ -5,6 +5,8 @@ from bisheng.core.session_activity import AuthenticatedActivity from bisheng.dsh.domain.services.access import DshPrincipal from bisheng.dsh.domain.services.local_session import DshLocalSessionService +from bisheng.user.application.dsh_session import desktop_auth_error +from bisheng.user.application.platform_authentication import PlatformActivity @dataclass(frozen=True) @@ -16,10 +18,8 @@ async def record(self) -> None: await self.sessions.record_activity(self.principal) -@dataclass(frozen=True) -class DesktopPlatformActivity(AuthenticatedActivity): - sessions: object - token: str +class DesktopPlatformActivity(PlatformActivity): + """Compatibility adapter preserving the Desktop error envelope.""" - async def record(self) -> None: - await self.sessions.activity(self.token) + def __init__(self, sessions, token): + super().__init__(sessions, token, error_mapper=desktop_auth_error) diff --git a/src/backend/bisheng/dsh/domain/services/access.py b/src/backend/bisheng/dsh/domain/services/access.py index 17188d211c..c4b6acd202 100644 --- a/src/backend/bisheng/dsh/domain/services/access.py +++ b/src/backend/bisheng/dsh/domain/services/access.py @@ -14,6 +14,7 @@ from bisheng.core.context import tenant as tenant_context from bisheng.dsh.domain.schemas.contracts import DshContract, SubjectId from bisheng.user.application.dsh_session import desktop_auth_error +from bisheng.user.application.platform_authentication import authenticate_platform_token, is_platform_token class DshPrincipal(DshContract): @@ -60,27 +61,19 @@ async def decode(self, authorization: str) -> DshPrincipal: token = authorization[7:] try: header = jwt.get_unverified_header(token) - if header.get("typ") == "bisheng-platform-access+jwt": + if is_platform_token(token): if self.platform_auth is None: raise DshInvalidAccessTokenError() - metadata = await self.platform_auth.inspect(token) - claims = self.platform_auth.decode(token) - if claims["client_id"] != "bisheng-desktop": - raise DshInvalidAccessTokenError() + authenticated = await authenticate_platform_token( + self.platform_auth, token, client_id="bisheng-desktop" + ) + claims = authenticated.claims return DshPrincipal( tenant_id=str(claims["tenant_id"]), user_id=str(claims["sub"]), session_id=claims["session_id"], session_version=claims["session_version"], - platform_reference={ - "kind": "platform_session", - "user_id": int(claims["sub"]), - "tenant_id": int(claims["tenant_id"]), - "token_version": claims["token_version"], - "expires_at": metadata["access_expires_at"], - "session_id": claims["session_id"], - "session_version": claims["session_version"], - }, + platform_reference=authenticated.reference, ) if ( header.get("alg") != "HS256" diff --git a/src/backend/bisheng/dsh/domain/services/web_session.py b/src/backend/bisheng/dsh/domain/services/web_session.py index f1e9180ac9..5befaf1b6c 100644 --- a/src/backend/bisheng/dsh/domain/services/web_session.py +++ b/src/backend/bisheng/dsh/domain/services/web_session.py @@ -7,6 +7,7 @@ from bisheng.common.errcode.dsh import DshInvalidAccessTokenError from bisheng.dsh.domain.services.access import principal_scope +from bisheng.user.application.platform_authentication import bind_platform_activity PREFIX = "dsh:web-session:" @@ -21,6 +22,8 @@ async def create_web_session(runtime, authorization: str) -> dict: from bisheng.user.domain.models.user import UserDao from bisheng.user.domain.services.auth import AuthJwt + # Keep the wire contract for installed clients; platform credentials still + # undergo the same auth verification as the new bridge, without fallback. principal = await runtime.access.authenticate(authorization) # authenticate verified this exact JWT, including its expiration and grant. claims = jwt.decode(authorization[7:], options={"verify_signature": False}) @@ -66,5 +69,11 @@ async def validate_web_session(connection, subject: dict) -> None: state = getattr(connection, "state", None) if state is not None: from bisheng.dsh.application.session_activity import DshSessionActivity + from bisheng.user.application.dsh_session import desktop_auth_error - state.authenticated_activity = DshSessionActivity(runtime.sessions, principal) + if principal.platform_reference is not None: + bind_platform_activity( + connection, runtime.platform_sessions, authorization[7:], error_mapper=desktop_auth_error + ) + else: + state.authenticated_activity = DshSessionActivity(runtime.sessions, principal) diff --git a/src/backend/bisheng/user/api/endpoints/platform_auth.py b/src/backend/bisheng/user/api/endpoints/platform_auth.py index 5dd9eb030b..7593ccc837 100644 --- a/src/backend/bisheng/user/api/endpoints/platform_auth.py +++ b/src/backend/bisheng/user/api/endpoints/platform_auth.py @@ -246,5 +246,15 @@ async def consume(ticket: str, request: Request): data = await get_platform_auth(request).consume_ticket(ticket, public_origin(request)) response = RedirectResponse("/workspace", status_code=303) deliver(response, request, data) + # The selector is not a credential; auth always verifies the selected access cookie. + response.set_cookie( + "platform_session_hint", + data["session_id"], + max_age=data["expires_in"], + path="/", + secure=public_origin(request).startswith("https://"), + httponly=False, + samesite="lax", + ) response.headers["Referrer-Policy"] = "no-referrer" return response diff --git a/src/backend/bisheng/user/api/user.py b/src/backend/bisheng/user/api/user.py index 50ed403a6a..5c328520e1 100644 --- a/src/backend/bisheng/user/api/user.py +++ b/src/backend/bisheng/user/api/user.py @@ -76,7 +76,11 @@ def clear_error_password_key(user_id: int): get_redis_client_sync().delete(error_key) -@router.post("/user/login") +@router.post( + "/user/login", + deprecated=True, + description="Legacy password login adapter. Use POST /api/v1/auth/login for platform sessions.", +) async def login(*, request: Request, user: UserLogin, auth_jwt: AuthJwt = Depends()): return await UserService.user_login(request, user=user, auth_jwt=auth_jwt) @@ -191,7 +195,12 @@ async def get_info(login_user: LoginUser = Depends(LoginUser.get_login_user)): ) -@router.post("/user/logout", status_code=201) +@router.post( + "/user/logout", + status_code=201, + deprecated=True, + description="Legacy logout adapter. Platform sessions use POST /api/v1/auth/logout.", +) async def logout(auth_jwt: AuthJwt = Depends()): from bisheng.user.domain.services.platform_identity import is_platform_token from bisheng.user.domain.services.platform_transport import require_csrf, selected_sid diff --git a/src/backend/bisheng/user/application/oauth_exchange.py b/src/backend/bisheng/user/application/oauth_exchange.py index da6d623cb5..104faf8ab7 100644 --- a/src/backend/bisheng/user/application/oauth_exchange.py +++ b/src/backend/bisheng/user/application/oauth_exchange.py @@ -4,6 +4,7 @@ from datetime import datetime from bisheng.common.errcode.platform_auth import PlatformAuthError +from bisheng.user.application.platform_authentication import authenticate_platform_token from bisheng.user.domain.const import FIRST_PARTY_CLIENT_IDS from bisheng.user.domain.services.platform_transport import access_credential, require_csrf, require_origin from bisheng.user.platform_auth_runtime import get_platform_auth, platform_auth_service @@ -37,22 +38,15 @@ async def read_platform_exchange_subject(request, subject_token: str | None = No require_origin(request) service = get_platform_auth(request) - metadata = await service.inspect(token) - claims = service.decode(token) + authenticated = await authenticate_platform_token(service, token) + metadata = authenticated.metadata + claims = authenticated.claims if claims["client_id"] not in FIRST_PARTY_CLIENT_IDS: raise PlatformAuthError() if "cookie" in request.headers: require_csrf(request, metadata) - reference = { - "kind": "platform_session", - "user_id": int(claims["sub"]), - "tenant_id": int(claims["tenant_id"]), - "token_version": claims["token_version"], - "expires_at": metadata["access_expires_at"], - "session_id": claims["session_id"], - "session_version": claims["session_version"], - } + reference = authenticated.reference return { "user_id": reference["user_id"], "tenant_id": reference["tenant_id"], diff --git a/src/backend/bisheng/user/application/platform_authentication.py b/src/backend/bisheng/user/application/platform_authentication.py new file mode 100644 index 0000000000..be9938a0c5 --- /dev/null +++ b/src/backend/bisheng/user/application/platform_authentication.py @@ -0,0 +1,64 @@ +"""Shared platform credential verification, references and authenticated activity.""" + +from dataclasses import dataclass + +import jwt + +from bisheng.common.errcode.platform_auth import PlatformAuthError +from bisheng.core.session_activity import AuthenticatedActivity + + +@dataclass(frozen=True) +class VerifiedPlatformAuthentication: + claims: dict + metadata: dict + reference: dict + + +async def authenticate_platform_token(service, token, *, client_id=None): + """Verify exactly one platform authority and expose a credential-free reference.""" + metadata = await service.inspect(token) + claims = service.decode(token) + if client_id is not None and claims["client_id"] != client_id: + raise PlatformAuthError("invalid_access_token") + reference = { + "kind": "platform_session", + "session_id": claims["session_id"], + "session_version": claims["session_version"], + "user_id": int(claims["sub"]), + "tenant_id": int(claims["tenant_id"]), + "token_version": claims["token_version"], + "expires_at": metadata["access_expires_at"], + } + return VerifiedPlatformAuthentication(claims, metadata, reference) + + +class PlatformActivity(AuthenticatedActivity): + def __init__(self, service, token, *, error_mapper=None): + self.service = service + self.token = token + self.error_mapper = error_mapper + + async def record(self): + try: + await self.service.activity(self.token) + except PlatformAuthError as exc: + if self.error_mapper is None: + raise + raise self.error_mapper(exc) from exc + + def policy_for(self, endpoint): + return getattr(endpoint, "__platform_session_activity_policy__", None) or super().policy_for(endpoint) + + +def bind_platform_activity(connection, service, token, *, error_mapper=None): + connection.state.authenticated_activity = PlatformActivity(service, token, error_mapper=error_mapper) + + +def is_platform_token(token): + """Select the platform validator by ownership markers; never authenticate here.""" + try: + header = jwt.get_unverified_header(token) + return header.get("typ") == "bisheng-platform-access+jwt" or header.get("kid") == "platform-access-v1" + except (jwt.PyJWTError, TypeError): + return False diff --git a/src/backend/bisheng/user/domain/services/platform_identity.py b/src/backend/bisheng/user/domain/services/platform_identity.py index 19d24ca8dc..7ba144d054 100644 --- a/src/backend/bisheng/user/domain/services/platform_identity.py +++ b/src/backend/bisheng/user/domain/services/platform_identity.py @@ -1,53 +1,34 @@ -"""Normalize verified platform identity without changing management-scope semantics.""" - -from bisheng.core.session_activity import AuthenticatedActivity +"""Map shared verified platform authentication to the current Web identity.""" + +from bisheng.user.application.platform_authentication import ( + PlatformActivity, + authenticate_platform_token, + bind_platform_activity, + is_platform_token, +) from bisheng.user.domain.services.platform_transport import access_credential from bisheng.user.platform_auth_runtime import get_platform_auth - -class PlatformActivity(AuthenticatedActivity): - def __init__(self, service, token): - self.service, self.token = service, token - - async def record(self): - await self.service.activity(self.token) - - def policy_for(self, endpoint): - return getattr(endpoint, "__platform_session_activity_policy__", None) or super().policy_for(endpoint) +# Preserve the legacy import path while authentication uses the shared adapter. +__all__ = ["PlatformActivity", "authenticate_platform", "is_platform_token"] async def authenticate_platform(connection, *, identity_class=None, token=None): from bisheng.user.domain.services.auth import LoginUser service = get_platform_auth(connection) - token = token or access_credential(connection) - data = await service.inspect(token) - claims = service.decode(token) + if token is None: + token = access_credential(connection) + authentication = await authenticate_platform_token(service, token) + claims = authentication.claims cls = identity_class or LoginUser user = await cls.init_login_user( user_id=int(claims["sub"]), - user_name=data["user"]["user_name"], + user_name=authentication.metadata["user"]["user_name"], tenant_id=int(claims["tenant_id"]), token_version=claims["token_version"], **({"require_current_super": True} if getattr(connection.state, "require_current_super", False) else {}), ) - user._runtime_credential_reference = { - "kind": "platform_session", - "session_id": claims["session_id"], - "session_version": claims["session_version"], - "user_id": int(claims["sub"]), - "tenant_id": int(claims["tenant_id"]), - "token_version": claims["token_version"], - "expires_at": data["access_expires_at"], - } - connection.state.authenticated_activity = PlatformActivity(service, token) + user._runtime_credential_reference = authentication.reference + bind_platform_activity(connection, service, token) return user - - -def is_platform_token(token): - import jwt - - try: - return jwt.get_unverified_header(token).get("typ") == "bisheng-platform-access+jwt" - except (jwt.PyJWTError, TypeError): - return False diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index 937a8b8f28..90a63c00d6 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "backend" -version = "3.1.0a1+fix" +version = "3.1.0a1+fix2" description = "BISHENG backend service" readme = "README.md" license = "Apache 2.0" diff --git a/src/backend/test/dsh/test_web_session.py b/src/backend/test/dsh/test_web_session.py index 8e5a4f3178..29b2c6d75a 100644 --- a/src/backend/test/dsh/test_web_session.py +++ b/src/backend/test/dsh/test_web_session.py @@ -11,6 +11,9 @@ from bisheng.core.config.dsh import DshSettings from bisheng.dsh.domain.services import web_session from bisheng.dsh.domain.services.access import DshPrincipal +from test.platform_auth.test_platform_session import runtime as _platform_runtime + +platform_runtime = _platform_runtime @pytest.fixture(autouse=True) @@ -232,3 +235,62 @@ async def test_exchange_uses_real_jwt_signer_with_bounded_lifetime(monkeypatch): assert json.loads(claims["sub"])["tenant_id"] == 2 browser_claims = jwt.decode(signer.create_access_token({"user_id": 42}), secret, algorithms=["HS256"]) assert now + 86400 <= browser_claims["exp"] <= int(time.time()) + 86400 + + +@pytest.mark.parametrize("client_id", ["bisheng-desktop", "bisheng-mobile", "bisheng-web"]) +async def test_legacy_bridge_never_bypasses_desktop_authentication(platform_runtime, monkeypatch, client_id): + """Even platform-shaped tokens cannot mint a cookie if the authoritative validator rejects them.""" + from fastapi import FastAPI + from httpx import ASGITransport, AsyncClient + + from bisheng.dsh.api.dependencies import get_runtime + from bisheng.dsh.api.endpoints.web_session import router + + service, _, _ = platform_runtime + issued = await service.issue(7, 9, client_id) + authenticate = AsyncMock(side_effect=DshInvalidAccessTokenError()) + redis = SimpleNamespace(set=AsyncMock()) + monkeypatch.setattr(web_session, "session_store", AsyncMock(return_value=redis)) + runtime = SimpleNamespace(access=SimpleNamespace(authenticate=authenticate), settings=DshSettings()) + app = FastAPI() + app.include_router(router, prefix="/api/v1") + app.dependency_overrides[get_runtime] = lambda: runtime + async with AsyncClient(transport=ASGITransport(app), base_url="https://platform.test") as client: + rejected = await client.post( + "/api/v1/dsh/web-session", headers={"Authorization": f"Bearer {issued['access_token']}"} + ) + assert rejected.status_code == 401 + assert rejected.json()["error"]["code"] == "invalid_access_token" + assert rejected.headers["deprecation"] == "@1796194800" + assert rejected.headers["cache-control"] == "no-store" + assert not rejected.headers.get_list("set-cookie") + authenticate.assert_awaited_once_with("Bearer " + issued["access_token"]) + redis.set.assert_not_awaited() + assert (await service.inspect(issued["access_token"]))["session_id"] == issued["session_id"] + + +async def test_legacy_bridge_preserves_verified_platform_principal_compatibility(monkeypatch): + """The deprecated wire protocol remains usable after authoritative platform authentication.""" + verified = principal().model_copy( + update={"platform_reference": {"kind": "platform_session", "session_id": "session"}} + ) + authenticate = AsyncMock(return_value=verified) + redis = SimpleNamespace(set=AsyncMock()) + monkeypatch.setattr(web_session, "session_store", AsyncMock(return_value=redis)) + runtime = SimpleNamespace(access=SimpleNamespace(authenticate=authenticate), settings=DshSettings()) + legacy_shaped = "Bearer " + jwt.encode( + {"exp": int(time.time()) + 300}, "fixture-signing-key-long-enough-32", algorithm="HS256" + ) + with ( + patch( + "bisheng.user.domain.models.user.UserDao.aget_user", + AsyncMock(return_value=SimpleNamespace(user_name="Alice", token_version=0, delete=0)), + ), + patch("bisheng.user.domain.services.auth.AuthJwt") as auth, + ): + auth.return_value.create_access_token.return_value = "compatibility-cookie" + result = await web_session.create_web_session(runtime, legacy_shaped) + authenticate.assert_awaited_once_with(legacy_shaped) + assert result["cookie"] == "compatibility-cookie" + assert 30 <= result["expires_in"] <= 300 + assert redis.set.call_args.args[1] == legacy_shaped diff --git a/src/backend/test/dsh/test_web_session_platform_activity.py b/src/backend/test/dsh/test_web_session_platform_activity.py new file mode 100644 index 0000000000..87f7efc3d6 --- /dev/null +++ b/src/backend/test/dsh/test_web_session_platform_activity.py @@ -0,0 +1,140 @@ +"""Desktop cookie chat keeps the issuing device alive through real route admission.""" + +from datetime import timedelta +from types import SimpleNamespace +from unittest.mock import AsyncMock + +import httpx +import pytest +from fastapi import Depends, FastAPI, HTTPException + +from bisheng.admin.application.request_admission import install_request_admission +from bisheng.common.dependencies.user_deps import UserPayload +from bisheng.common.request_scope import RequestScope, inherit_scope, request_scope +from bisheng.dsh.api.dependencies import get_runtime +from bisheng.dsh.api.endpoints import web_session as exchange_http +from bisheng.dsh.domain.services import web_session +from bisheng.dsh.domain.services.access import DshPrincipal, principal_scope +from bisheng.user.domain.models.user import UserDao +from bisheng.utils import http_middleware +from bisheng.workstation.api.endpoints import chat +from test.dsh.test_platform_consumers import desktop as desktop +from test.dsh.test_platform_consumers import legacy_login + + +@pytest.fixture +def cookie_chat(desktop, monkeypatch): + runtime = desktop.runtime + runtime.settings.web_session_cookie_name = "access_token_cookie" + storage = {} + + async def store(key, value, **kwargs): + storage[key] = value + + redis = SimpleNamespace(set=AsyncMock(side_effect=store), get=AsyncMock(side_effect=storage.get)) + monkeypatch.setattr(web_session, "session_store", AsyncMock(return_value=redis)) + monkeypatch.setattr("bisheng.dsh.access_runtime.get_runtime", AsyncMock(return_value=runtime)) + monkeypatch.setattr( + "bisheng.user.domain.services.jwt_secret.resolve_jwt_secret", lambda: "isolated-desktop-cookie-test-signing-key" + ) + monkeypatch.setattr( + UserDao, "aget_user", AsyncMock(return_value=SimpleNamespace(user_name="alice", token_version=0, delete=0)) + ) + monkeypatch.setattr( + UserPayload, + "init_login_user", + AsyncMock(side_effect=lambda **kwargs: UserPayload.model_construct(user_id=7, tenant_id=9, token_version=0)), + ) + monkeypatch.setattr(http_middleware, "_validate_token_version", AsyncMock(return_value=True)) + monkeypatch.setattr(http_middleware, "_check_is_global_super", AsyncMock(return_value=False)) + business = AsyncMock(return_value={"ok": True}) + monkeypatch.setattr(chat, "stream_chat_completion", business) + + app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None) + app.add_middleware(http_middleware.CustomMiddleware) + app.dependency_overrides[get_runtime] = lambda: runtime + inherit_scope(exchange_http.router, RequestScope.CREDENTIAL) + inherit_scope(chat.router, RequestScope.TENANT) + app.include_router(exchange_http.router, prefix="/api/v1") + app.include_router(chat.router, prefix="/api/v1/workstation") + + @app.get("/api/v1/unit-info") + @request_scope(RequestScope.IDENTITY) + async def info(user=Depends(UserPayload.get_login_user)): + return {"user_id": user.user_id} + + # Admission catches activity failures before FastAPI resolves the endpoint. + # Omitting it hides the production 403 behind a different exception handler. + install_request_admission(app) + return SimpleNamespace(app=app, business=business) + + +async def issue(desktop, kind): + if kind == "platform": + return await desktop.platform.issue(7, 9, "bisheng-desktop") + return await legacy_login(desktop) + + +async def last_activity(desktop, kind, issued): + sid = issued["session_id"] + if kind == "platform": + return await desktop.platform.run(lambda repo: repo.get(sid).last_activity_at, read_only=True) + with principal_scope(DshPrincipal(tenant_id="9", user_id="7", session_id=sid)): + return await desktop.runtime.sessions.run(lambda repo: repo.get(sid).last_activity_at) + + +async def exchange_cookie(client, issued): + response = await client.post( + "/api/v1/dsh/web-session", headers={"Authorization": "Bearer " + issued["access_token"]}, json={} + ) + assert response.status_code == 200, response.text + cookie = response.json() + client.cookies.set(cookie["cookie_name"], cookie["cookie"]) + + +@pytest.mark.parametrize("kind", ["platform", "legacy"]) +@pytest.mark.parametrize("business_status", [200, 403]) +async def test_cookie_chat_renews_only_its_issuing_device(cookie_chat, desktop, kind, business_status): + issued, other = await issue(desktop, kind), await issue(desktop, kind) + start = desktop.clock[0] + if business_status == 403: + cookie_chat.business.side_effect = HTTPException(status_code=403, detail="Business permission denied") + + async with httpx.AsyncClient( + transport=httpx.ASGITransport(cookie_chat.app), base_url="https://platform.example" + ) as client: + await exchange_cookie(client, issued) + desktop.clock[0] += timedelta(seconds=60) + assert (await client.get("/api/v1/unit-info")).status_code == 200 + assert await last_activity(desktop, kind, issued) == start + response = await client.post( + "/api/v1/workstation/chat/completions", + json={"clientTimestamp": "fixture", "model": "42", "text": "hello"}, + ) + assert response.status_code == business_status, response.text + cookie_chat.business.assert_awaited_once() + assert response.headers["X-Auth-Activity-Recorded"] == "1" + assert await last_activity(desktop, kind, issued) == desktop.clock[0] + assert await last_activity(desktop, kind, other) == start + + +@pytest.mark.parametrize("kind", ["platform", "legacy"]) +async def test_revoked_desktop_cookie_never_renews_or_enters_chat(cookie_chat, desktop, kind): + issued = await issue(desktop, kind) + start = desktop.clock[0] + async with httpx.AsyncClient( + transport=httpx.ASGITransport(cookie_chat.app), base_url="https://platform.example" + ) as client: + await exchange_cookie(client, issued) + if kind == "platform": + await desktop.platform.logout(issued["access_token"]) + else: + await desktop.runtime.sessions.revoke(9, 7, issued["session_id"]) + desktop.clock[0] += timedelta(seconds=60) + response = await client.post( + "/api/v1/workstation/chat/completions", + json={"clientTimestamp": "fixture", "model": "42", "text": "hello"}, + ) + assert response.status_code == 401, response.text + cookie_chat.business.assert_not_awaited() + assert await last_activity(desktop, kind, issued) == start diff --git a/src/backend/test/platform_auth/test_platform_api.py b/src/backend/test/platform_auth/test_platform_api.py index 399cda15bf..67d20a56f0 100644 --- a/src/backend/test/platform_auth/test_platform_api.py +++ b/src/backend/test/platform_auth/test_platform_api.py @@ -104,9 +104,24 @@ async def test_ticket_is_single_use_and_parent_revocation_applies(runtime, nativ ).json()["data"] consumed = await client.get(ticket["consume_url"]) assert consumed.status_code == 303 and consumed.headers["location"] == "/workspace" - assert len(consumed.headers.get_list("set-cookie")) == 1 - assert (await client.get(ticket["consume_url"])).status_code == 401 - client.cookies.set("platform_session_hint", ticket["session_id"]) + cookies = consumed.headers.get_list("set-cookie") + assert len(cookies) == 2 + sid = ticket["session_id"] + access_cookie = next(c for c in cookies if c.startswith(f"platform_access_{sid}=")) + hint_cookie = next(c for c in cookies if c.startswith("platform_session_hint=")) + assert "HttpOnly" in access_cookie and "Secure" in access_cookie + assert "Path=/" in access_cookie and "SameSite=lax" in access_cookie + assert hint_cookie.startswith(f"platform_session_hint={sid};") + assert "HttpOnly" not in hint_cookie and "Secure" in hint_cookie + assert "Path=/" in hint_cookie and "SameSite=lax" in hint_cookie + assert client.cookies.get("platform_session_hint") == sid + assert client.cookies.get(f"platform_access_{sid}") + assert not any("platform_refresh_" in c or "access_token_cookie=" in c for c in cookies) + assert consumed.headers["cache-control"] == "no-store" + assert consumed.headers["referrer-policy"] == "no-referrer" + replay = await client.get(ticket["consume_url"]) + assert replay.status_code == 401 + assert not replay.headers.get_list("set-cookie") state = await client.get("/api/v1/auth/session") assert state.json()["data"]["refresh_mode"] == "host" await service.logout(parent["access_token"]) diff --git a/src/backend/test/platform_auth/test_work_mcp_auth.py b/src/backend/test/platform_auth/test_work_mcp_auth.py new file mode 100644 index 0000000000..a6fc65a419 --- /dev/null +++ b/src/backend/test/platform_auth/test_work_mcp_auth.py @@ -0,0 +1,212 @@ +"""Desktop platform ticket -> browser cookies -> real Work MCP transport and SQL activity.""" + +from datetime import timedelta +from types import SimpleNamespace +from unittest.mock import AsyncMock + +import pytest +from fastapi import HTTPException +from httpx import ASGITransport, AsyncClient +from starlette.responses import JSONResponse + +from bisheng.common.dependencies.user_deps import UserPayload +from bisheng.common.exceptions.auth import AuthJWTException +from bisheng.dsh.api.endpoints.work import router as work_router +from bisheng.dsh.work_mcp import create_work_mcp_runtime, work_transport_security +from test.platform_auth.test_platform_api import app_for +from test.platform_auth.test_platform_session import runtime as _runtime + +runtime = _runtime +MCP_PATH = "/api/v1/dsh/work/mcp" +MCP_HEADERS = { + "accept": "application/json, text/event-stream", + "mcp-protocol-version": "2025-11-25", + "origin": "https://platform.test", +} + + +@pytest.fixture +def work_app(runtime, monkeypatch): + service, _, _ = runtime + app = app_for(service) + app.include_router(work_router, prefix="/api/v1") + + # Match main.create_app: absent credentials take the legacy JWT error path. + @app.exception_handler(AuthJWTException) + async def jwt_error(request, exc): + return JSONResponse(status_code=401, content={"detail": str(exc)}) + + # Only external role/identity hydration is stubbed. Credential selection, signed + # token verification, session checks and activity use the production dependency. + user = UserPayload(user_id=7, user_name="test", tenant_id=9, user_role=[], token_version=0) + assert not user.is_admin() and not user.is_global_super + hydrate = AsyncMock(return_value=user) + monkeypatch.setattr(UserPayload, "init_login_user", hydrate) + monkeypatch.setattr( + "bisheng.user.domain.services.jwt_secret.resolve_jwt_secret", lambda: "test-secret-not-production" + ) + + async def execute(name, arguments): + if arguments.get("deny"): + raise HTTPException(status_code=403, detail="Fixture tool permission denied") + return {"echo": arguments["query"], "user_id": user.user_id, "tenant_id": user.tenant_id} + + provider = SimpleNamespace() + provider.list_tools = AsyncMock( + return_value=[ + { + "name": "fixture_echo", + "description": "Test-only tool provider", + "inputSchema": { + "type": "object", + "properties": {"query": {"type": "string"}, "deny": {"type": "boolean"}}, + "required": ["query"], + }, + } + ] + ) + provider.call_tool = AsyncMock(side_effect=execute) + + def tool_provider(authenticated_user): + assert authenticated_user is user + assert not authenticated_user.is_admin() + reference = authenticated_user._runtime_credential_reference + assert reference["kind"] == "platform_session" + assert (reference["user_id"], reference["tenant_id"]) == (7, 9) + assert "access_token" not in reference and "refresh_token" not in reference + return provider + + monkeypatch.setattr("bisheng.dsh.work_mcp.WorkCapabilitiesService", tool_provider) + manager = create_work_mcp_runtime(work_transport_security("https://platform.test")) + app.state.work_mcp_runtime = manager + return app, manager, provider, hydrate + + +def activity_snapshot(service, sid): + with service.repository_scope() as repo: + row = repo.get(sid) + return row.last_activity_at, row.expires_at + + +async def rpc(client, method, params=None, *, headers=None): + return await client.post( + MCP_PATH, + headers={**MCP_HEADERS, **(headers or {})}, + json={"jsonrpc": "2.0", "id": 1, "method": method, "params": params or {}}, + ) + + +async def test_desktop_ticket_work_tools_call_renews_exact_family_and_logout_rejects(runtime, work_app): + """Real SQL and SDK: discovery is passive, tool calls renew parent and child, logout stops execution.""" + service, clock, _ = runtime + app, manager, provider, hydrate = work_app + parent = await service.issue(7, 9, "bisheng-desktop") + unrelated = await service.issue(7, 9, "bisheng-desktop") + unrelated_before = activity_snapshot(service, unrelated["session_id"]) + async with ( + manager.run(), + AsyncClient(transport=ASGITransport(app), base_url="https://platform.test") as host, + AsyncClient(transport=ASGITransport(app), base_url="https://platform.test") as browser, + ): + issued = await host.post( + "/api/v1/auth/web-session", headers={"Authorization": f"Bearer {parent['access_token']}"} + ) + assert issued.status_code == 200 + ticket = issued.json()["data"] + consumed = await browser.get(ticket["consume_url"]) + assert consumed.status_code == 303 + sid = ticket["session_id"] + assert sid != parent["session_id"] + assert browser.cookies.get("platform_session_hint") == sid + access = browser.cookies.get(f"platform_access_{sid}") + assert access and access != parent["access_token"] + assert not any( + c.name.startswith("platform_refresh_") or c.name == "access_token_cookie" for c in browser.cookies.jar + ) + assert (await browser.get(ticket["consume_url"])).status_code == 401 + with service.repository_scope() as repo: + child = repo.get(sid) + assert child.parent_session_id == parent["session_id"] + assert child.client_id == "bisheng-web" + assert (child.user_id, child.tenant_id) == (7, 9) + + before_parent = activity_snapshot(service, parent["session_id"]) + before_child = activity_snapshot(service, sid) + clock[0] += timedelta(days=1) + initialized = await rpc( + browser, + "initialize", + { + "protocolVersion": "2025-11-25", + "capabilities": {}, + "clientInfo": {"name": "desktop-platform-regression", "version": "1"}, + }, + ) + assert initialized.status_code == 200, initialized.text + assert initialized.json()["result"]["serverInfo"]["name"] == "bisheng-enterprise-work" + listed = await rpc(browser, "tools/list") + assert listed.status_code == 200, listed.text + assert listed.json()["result"]["tools"][0]["name"] == "fixture_echo" + assert activity_snapshot(service, parent["session_id"]) == before_parent + assert activity_snapshot(service, sid) == before_child + provider.call_tool.assert_not_awaited() + + result = await rpc(browser, "tools/call", {"name": "fixture_echo", "arguments": {"query": "hello"}}) + assert result.status_code == 200, result.text + assert result.json()["result"]["structuredContent"]["result"] == {"echo": "hello", "user_id": 7, "tenant_id": 9} + for family_sid in (parent["session_id"], sid): + assert activity_snapshot(service, family_sid) == (clock[0], clock[0] + timedelta(days=90)) + hydrate.assert_awaited_with(user_id=7, user_name="test", tenant_id=9, token_version=0) + + # Admission failures occur after authenticated business activity. + clock[0] += timedelta(days=1) + denied_tool = await rpc( + browser, "tools/call", {"name": "fixture_echo", "arguments": {"query": "hello", "deny": True}} + ) + assert denied_tool.status_code == 200, denied_tool.text + assert denied_tool.json()["result"]["isError"] is True + assert activity_snapshot(service, sid)[0] == clock[0] + assert activity_snapshot(service, parent["session_id"])[0] == clock[0] + assert activity_snapshot(service, unrelated["session_id"]) == unrelated_before + + logged_out = await host.post( + "/api/v1/auth/logout", headers={"Authorization": f"Bearer {parent['access_token']}"} + ) + assert logged_out.status_code == 200 + calls_before = provider.call_tool.await_count + hydration_before = hydrate.await_count + child_before = activity_snapshot(service, sid) + clock[0] += timedelta(seconds=1) + rejected = await rpc(browser, "tools/call", {"name": "fixture_echo", "arguments": {"query": "after logout"}}) + assert rejected.status_code == 401, rejected.text + assert rejected.json()["data"]["auth_reason"] == "session_revoked" + assert provider.call_tool.await_count == calls_before + assert hydrate.await_count == hydration_before + assert activity_snapshot(service, sid) == child_before + + +@pytest.mark.parametrize("hint", [None, "invalid", "0" * 32]) +async def test_work_cookie_requires_matching_hint(runtime, work_app, hint): + """A host access cookie or a selector alone cannot select another session.""" + service, _, _ = runtime + app, manager, provider, hydrate = work_app + parent = await service.issue(7, 9, "bisheng-desktop") + ticket = await service.create_ticket(parent["access_token"], "https://platform.test") + async with manager.run(), AsyncClient(transport=ASGITransport(app), base_url="https://platform.test") as browser: + assert (await browser.get(ticket["consume_url"])).status_code == 303 + sid = ticket["session_id"] + cookie = f"platform_access_{sid}={browser.cookies.get(f'platform_access_{sid}')}" + if hint is not None: + cookie += f"; platform_session_hint={hint}" + # Auth metadata uses the same selector as Work, and fails before hydration. + state = await browser.get("/api/v1/auth/session", headers={"Cookie": cookie}) + assert state.status_code == 401 + response = await rpc( + browser, + "tools/call", + {"name": "fixture_echo", "arguments": {"query": "unselected"}}, + headers={"Cookie": cookie}, + ) + assert response.status_code == 401, response.text + provider.call_tool.assert_not_awaited() + hydrate.assert_not_awaited() diff --git a/src/backend/uv.lock b/src/backend/uv.lock index 18dbde1568..e100f43679 100644 --- a/src/backend/uv.lock +++ b/src/backend/uv.lock @@ -398,7 +398,7 @@ wheels = [ [[package]] name = "backend" -version = "3.1.0a1+fix" +version = "3.1.0a1+fix2" source = { virtual = "." } dependencies = [ { name = "aiofiles" }, diff --git a/src/frontend/client/package.json b/src/frontend/client/package.json index 3bf2f6ee53..d394d4eea2 100644 --- a/src/frontend/client/package.json +++ b/src/frontend/client/package.json @@ -1,6 +1,6 @@ { "name": "bishengchat", - "version": "3.1.0-alpha1-fix", + "version": "3.1.0-alpha1-fix2", "description": "", "type": "module", "scripts": { diff --git a/src/frontend/client/src/hooks/useSessionPresence.test.ts b/src/frontend/client/src/hooks/useSessionPresence.test.ts new file mode 100644 index 0000000000..5a748a7b3a --- /dev/null +++ b/src/frontend/client/src/hooks/useSessionPresence.test.ts @@ -0,0 +1,63 @@ +import { act, renderHook, waitFor } from '@testing-library/react'; + +jest.mock('axios', () => { + const actual = jest.requireActual('axios'); + const instance = actual.create(); + return { __esModule: true, ...actual, default: { ...actual, create: () => instance } }; +}); +jest.mock('react-activation', () => ({ useActivate: jest.fn(), useUnactivate: jest.fn() })); +jest.mock('~/hooks', () => ({ + useLocalize: () => (key: string) => key, + useToast: () => ({ showToast: jest.fn() }), +})); +jest.mock('~/utils', () => ({ generateUUID: () => 'page-lease' })); +jest.mock('~/utils/loginRedirect', () => ({ redirectToLogin: jest.fn() })); + +const previousAppBase = __APP_ENV__.BASE_URL; +Object.assign(__APP_ENV__, { BASE_URL: '/workspace' }); +const { useSessionPresence } = jest.requireActual('./useSessionPresence'); +const transport = (jest.requireMock('axios') as typeof import('axios')).default.create(); +const previousAdapter = transport.defaults.adapter; +const previousTransportBase = transport.defaults.baseURL; +const previousBeacon = Object.getOwnPropertyDescriptor(navigator, 'sendBeacon'); +const urls: string[] = []; +const sendBeacon = jest.fn(() => true); + +beforeEach(() => { + jest.useFakeTimers(); + urls.length = 0; + Object.defineProperty(navigator, 'sendBeacon', { configurable: true, value: sendBeacon }); + transport.defaults.adapter = async config => { + if (config.url?.includes('/department-flow/presence/')) urls.push(transport.getUri(config)); + return { + config, status: 200, statusText: 'OK', headers: {}, + data: { status_code: 200, data: { outcome: 'held', department_id: 7, scope_tenant_id: 7, source: 'own' } }, + }; + }; +}); + +afterEach(() => { + jest.useRealTimers(); + transport.defaults.adapter = previousAdapter; + transport.defaults.baseURL = previousTransportBase; + if (previousBeacon) Object.defineProperty(navigator, 'sendBeacon', previousBeacon); + else Reflect.deleteProperty(navigator, 'sendBeacon'); +}); + +afterAll(() => { Object.assign(__APP_ENV__, { BASE_URL: previousAppBase }); }); + +it.each(['/workspace', '/workspace/'])('uses one workspace prefix for leases and unload with base %s', async base => { + transport.defaults.baseURL = base; + const { unmount } = renderHook(() => useSessionPresence('conversation')); + await waitFor(() => expect(urls).toEqual(['/workspace/api/v1/department-flow/presence/ensure'])); + + await act(async () => { jest.advanceTimersByTime(30_000); }); + await waitFor(() => expect(urls).toHaveLength(2)); + expect(urls[1]).toBe('/workspace/api/v1/department-flow/presence/ensure'); + + act(() => { window.dispatchEvent(new Event('pagehide')); }); + expect(sendBeacon).toHaveBeenCalledWith('/workspace/api/v1/department-flow/presence/release', expect.any(Blob)); + + await act(async () => { unmount(); }); + await waitFor(() => expect(urls[2]).toBe('/workspace/api/v1/department-flow/presence/release')); +}); diff --git a/src/frontend/client/src/hooks/useSessionPresence.ts b/src/frontend/client/src/hooks/useSessionPresence.ts index 0b24c4e697..9cee18319c 100644 --- a/src/frontend/client/src/hooks/useSessionPresence.ts +++ b/src/frontend/client/src/hooks/useSessionPresence.ts @@ -19,7 +19,8 @@ import { useLocalize, useToast } from '~/hooks' import { generateUUID } from '~/utils' const RENEW_INTERVAL_MS = 30_000 -const PRESENCE_BASE = `${__APP_ENV__.BASE_URL}/api/v1/department-flow/presence` +// The request wrapper already supplies the workspace base; native beacons do not. +const PRESENCE_BASE = '/api/v1/department-flow/presence' type PresenceOutcome = 'held' | 'rejected' | 'skipped' @@ -246,7 +247,7 @@ export function useSessionPresence( const body = new Blob([JSON.stringify({ lease_id: id, department_id: departmentId })], { type: 'application/json', }) - navigator.sendBeacon(`${PRESENCE_BASE}/release`, body) + navigator.sendBeacon(`${__APP_ENV__.BASE_URL}${PRESENCE_BASE}/release`, body) } catch { // Best effort: the lease expires after LEASE_TTL_MS. } diff --git a/src/frontend/platform/package.json b/src/frontend/platform/package.json index 4444cfe057..ab12c45dfa 100644 --- a/src/frontend/platform/package.json +++ b/src/frontend/platform/package.json @@ -1,6 +1,6 @@ { "name": "bisheng", - "version": "3.1.0-alpha1-fix", + "version": "3.1.0-alpha1-fix2", "private": true, "dependencies": { "@bisheng/identity": "workspace:*", diff --git a/src/runtime-manager/pyproject.toml b/src/runtime-manager/pyproject.toml index 5b6415aec7..deb1c30d78 100644 --- a/src/runtime-manager/pyproject.toml +++ b/src/runtime-manager/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "bisheng-runtime-manager" -version = "3.1.0a1+fix" +version = "3.1.0a1+fix2" description = "BiSheng hosted-app runtime manager — build / lifecycle / probe / routing / capacity admission for the compose form" requires-python = ">=3.11" license = { text = "Apache-2.0" } diff --git a/src/runtime-manager/runtime_manager/__init__.py b/src/runtime-manager/runtime_manager/__init__.py index 74a385e744..9941e5f17b 100644 --- a/src/runtime-manager/runtime_manager/__init__.py +++ b/src/runtime-manager/runtime_manager/__init__.py @@ -12,4 +12,4 @@ ``compose`` word appears in a request or response field name (INV-33). """ -__version__ = "3.1.0-alpha1-fix" +__version__ = "3.1.0-alpha1-fix2" diff --git a/src/runtime-manager/runtime_manager/image_catalog.py b/src/runtime-manager/runtime_manager/image_catalog.py index 21e6860fff..f12e6beca6 100644 --- a/src/runtime-manager/runtime_manager/image_catalog.py +++ b/src/runtime-manager/runtime_manager/image_catalog.py @@ -65,7 +65,7 @@ def create_inventory(metadata, *, platform, release, source_revision, published, tools = ( { "python-abi": "3.11", - "runtime-package": "3.1.0-alpha1-fix", + "runtime-package": "3.1.0-alpha1-fix2", "python-packages": "/usr/share/licenses/bisheng/python-packages.json", } if name in {"runtime-helper", "runtime-assembler"} diff --git a/src/runtime-manager/uv.lock b/src/runtime-manager/uv.lock index 50ddf597a1..a4b960f26c 100644 --- a/src/runtime-manager/uv.lock +++ b/src/runtime-manager/uv.lock @@ -98,7 +98,7 @@ wheels = [ [[package]] name = "bisheng-runtime-manager" -version = "3.1.0a1+fix" +version = "3.1.0a1+fix2" source = { editable = "." } dependencies = [ { name = "cryptography" }, diff --git a/update.sh b/update.sh index 20888d6bbf..8a0c29ce35 100644 --- a/update.sh +++ b/update.sh @@ -2,8 +2,8 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" -old_version="3.1.0-alpha1" -new_version="3.1.0-alpha1-fix" +old_version="3.1.0-alpha1-fix" +new_version="3.1.0-alpha1-fix2" old_pattern=${old_version//./\\.} normalized_version=${new_version/-alpha/a} normalized_version=${normalized_version/-beta/b}