🐛 device: 设备流补上自报显示名,回退不再切在 sha256: 前缀里 - #18
Merged
Conversation
设备流此前没有任何途径接收设备名:授权请求只收 device_kind / fingerprint / platform / version,换取 token 时只能 flow.ClientFingerprint[:8] 当名字。而 daemon 与桌面端的规范指纹是 sha256:<64 位 hex>,切出来恒为 "sha256:" 加一个十六进制字符 ——整个账号下的机器最多只有 16 种名字,等于没有名字。 授权请求补上可选的 name,落进 device_flow_codes.client_name,换取 token 时由 device_entity.DisplayName 决定 devices.name:自报优先,缺省回退到**剥掉 sha256: 前缀后**的指纹缩写。老客户端不带 name 照常授权。 回退规则放在实体层而不是 service:它是「这台设备叫什么」的业务判据。按符文而不是 按字节截 —— 端点按 binding `min=8` 收而 validator 数的是符文,八个多字节符文的指纹 过得了校验,按字节切却会切在符文中间,落库是一段非法 UTF-8。 迁移编号取 202608150002:202608150001 已被同日的「浏览器改用短效中继凭据」占用。 gormigrate 按 ID 记账,同 ID 的两条只会跑一条、另一条被当成已执行,client_name 列 会在已记录该 ID 的库上永远不被创建且不报错。 客户端侧(agentred 与桌面端上报主机名)在 agentre 仓库的 #55。
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.
用户报告设备在控制台显示的名字是
sha256:4—— 而且每台机器都长这样。根因
设备流没有任何途径接收设备名。授权端点
DeviceAuthorizeRequest只收device_kind/fingerprint/platform/version,所以ExchangeToken只能:而 daemon 与桌面端的规范指纹是
sha256:<64 位 hex>,前 8 个字符恒为sha256:加一个十六进制字符 —— 整个账号下的机器最多只有 16 种名字,等于没有名字。实测该账号下两台设备分别叫sha256:4和sha256:0。改动
name(binding:"max=128"),不带它的老客户端照常授权device_flow_codes.client_name(迁移202608150002)—— 授权与换取 token 是两次独立请求,中间只有这一行 flow 记录能承载它ExchangeToken改由device_entity.DisplayName(reported, fingerprint)决定devices.name:自报优先,缺省回退到剥掉sha256:前缀后的指纹缩写回退规则放在实体层而不是 service —— 它是「这台设备叫什么」的业务判据。按符文而不是按字节截:端点按
min=8收而 validator 数的是符文,八个多字节符文的指纹过得了校验,按字节切却会切在符文中间,落库是一段非法 UTF-8。客户端侧(agentred 与桌面端登录时上报
os.Hostname())在 agentre-hub/agentre#55迁移编号说明
取
202608150002而不是...0001:同日的「浏览器改用短效中继凭据」已经占了202608150001。gormigrate 按 ID 记账,同 ID 的两条只会跑一条、另一条被当成已执行 ——client_name列会在已记录该 ID 的库上永远不被创建,且不报任何错。验证
go test ./internal/... ./migrations/...全绿golangci-lint run0 问题actual: "sha256:4"注意
devices.name只在换取 token 时写入,所以既有设备要重新登录一次才会变成主机名。本 PR 不含数据回填。