From 33b220ae1098f9ddcca37931671e0aba3421a38c Mon Sep 17 00:00:00 2001 From: yml2213 Date: Thu, 22 Oct 2026 10:04:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(dcauth):=20order=5Fsite=20=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95=E8=A1=A5=E5=85=85=E7=94=9F=E4=BA=A7=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=20ks.khhao.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/dcauth/README.md | 8 +++---- apps/dcauth/main.go | 3 ++- apps/dcauth/main_test.go | 25 ++++++++++++++++++--- apps/dcauth/versioninfo.rc | 8 +++---- apps/dcauth/versioninfo_windows_amd64.syso | Bin 924 -> 924 bytes docs/设备认证-dcauth协议.md | 2 +- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/apps/dcauth/README.md b/apps/dcauth/README.md index dbb4978d..bbd4235e 100644 --- a/apps/dcauth/README.md +++ b/apps/dcauth/README.md @@ -18,10 +18,10 @@ x86_64-w64-mingw32-windres --codepage=65001 versioninfo.rc \ CGO_ENABLED=0 GOOS=windows GOARCH=amd64 \ go build -trimpath -ldflags "-H windowsgui -s -w" \ -o dist/DCAuth.exe . -cp dist/DCAuth.exe dist/DCAuth-2.0.0.exe +cp dist/DCAuth.exe dist/DCAuth-2.0.1.exe ``` -版本号统一在 `main.go` 的 `clientVersion` 和 `versioninfo.rc` 中维护。`DCAuth.exe` 右键“属性 → 详细信息”会显示文件版本 `2.0.0.0` 和产品版本 `2.0.0`,托盘菜单、设备信息及确认窗口也会显示当前版本。 +版本号统一在 `main.go` 的 `clientVersion` 和 `versioninfo.rc` 中维护。`DCAuth.exe` 右键“属性 → 详细信息”会显示文件版本 `2.0.1.0` 和产品版本 `2.0.1`,托盘菜单、设备信息及确认窗口也会显示当前版本。 Windows ARM64: @@ -114,7 +114,7 @@ macOS 当前仍是开发版:私钥明文保存在 `~/Library/Application Suppo 登录页创建 challenge 后跳转: ```text -dcauth://authorize?app=order_site&challenge_id=...&challenge=...&api=https%3A%2F%2Forder.khhao.com +dcauth://authorize?app=order_site&challenge_id=...&challenge=...&api=https%3A%2F%2Fks.khhao.com ``` 客户端校验 app 和 api 白名单后,弹出一次确认框,签名并提交到: @@ -129,7 +129,7 @@ POST /api/dcauth/authorize | app | 生产入口 | |---|---| -| `order_site` | `https://order.khhao.com` | +| `order_site` | `https://ks.khhao.com`(历史入口 `https://order.khhao.com` 仍放行) | | `live_hub` | `https://live.khhao.com` | | `affiliate_dash` | `https://skin.khhao.com` | diff --git a/apps/dcauth/main.go b/apps/dcauth/main.go index db9b3af2..8e150548 100644 --- a/apps/dcauth/main.go +++ b/apps/dcauth/main.go @@ -15,7 +15,7 @@ import ( "time" ) -const clientVersion = "2.0.0" +const clientVersion = "2.0.1" type appConfig struct { DisplayName string @@ -26,6 +26,7 @@ var appRegistry = map[string]appConfig{ "order_site": { DisplayName: "订单后台", AllowedAPIs: []string{ + "https://ks.khhao.com", "https://order.khhao.com", "http://localhost", "http://127.0.0.1", diff --git a/apps/dcauth/main_test.go b/apps/dcauth/main_test.go index 732c6e36..36289450 100644 --- a/apps/dcauth/main_test.go +++ b/apps/dcauth/main_test.go @@ -14,6 +14,9 @@ func TestParseAuthorizeURLAllowedOrigins(t *testing.T) { {name: "localhost", api: "http%3A%2F%2Flocalhost", expected: "http://localhost"}, {name: "localhost trailing slash", api: "http%3A%2F%2Flocalhost%2F", expected: "http://localhost"}, {name: "lan address", api: "http%3A%2F%2F192.168.10.6", expected: "http://192.168.10.6"}, + {name: "production ks.khhao.com", api: "https%3A%2F%2Fks.khhao.com", expected: "https://ks.khhao.com"}, + {name: "production uppercase host", api: "https%3A%2F%2FKS.KHHAO.COM", expected: "https://ks.khhao.com"}, + {name: "legacy production order.khhao.com", api: "https%3A%2F%2Forder.khhao.com", expected: "https://order.khhao.com"}, } for _, tt := range tests { @@ -31,9 +34,25 @@ func TestParseAuthorizeURLAllowedOrigins(t *testing.T) { } func TestParseAuthorizeURLRejectsUnknownOrigin(t *testing.T) { - raw := "dcauth://authorize?app=order_site&challenge_id=challenge-id&challenge=challenge-value&api=http%3A%2F%2Fexample.com" - if _, err := parseAuthorizeURL(raw); err == nil { - t.Fatal("parseAuthorizeURL() accepted an unknown origin") + tests := []struct { + name string + api string + }{ + {name: "unknown host", api: "http%3A%2F%2Fexample.com"}, + {name: "lookalike suffix", api: "https%3A%2F%2Fks.khhao.com.evil.com"}, + {name: "lookalike prefix", api: "https%3A%2F%2Fevil-ks.khhao.com"}, + {name: "unexpected port", api: "https%3A%2F%2Fks.khhao.com%3A8443"}, + {name: "plain http production host", api: "http%3A%2F%2Fks.khhao.com"}, + {name: "userinfo trick", api: "https%3A%2F%2Fks.khhao.com%40evil.com"}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + raw := "dcauth://authorize?app=order_site&challenge_id=challenge-id&challenge=challenge-value&api=" + tt.api + if _, err := parseAuthorizeURL(raw); err == nil { + t.Fatalf("parseAuthorizeURL() accepted %q", tt.api) + } + }) } } diff --git a/apps/dcauth/versioninfo.rc b/apps/dcauth/versioninfo.rc index 8420a08c..b321bb7e 100644 --- a/apps/dcauth/versioninfo.rc +++ b/apps/dcauth/versioninfo.rc @@ -1,6 +1,6 @@ 1 VERSIONINFO -FILEVERSION 2,0,0,0 -PRODUCTVERSION 2,0,0,0 +FILEVERSION 2,0,1,0 +PRODUCTVERSION 2,0,1,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -13,12 +13,12 @@ BEGIN BEGIN VALUE "CompanyName", "Order Site" VALUE "FileDescription", "DCAuth device authentication client" - VALUE "FileVersion", "2.0.0.0" + VALUE "FileVersion", "2.0.1.0" VALUE "InternalName", "DCAuth" VALUE "LegalCopyright", "Copyright (C) 2026 Order Site" VALUE "OriginalFilename", "DCAuth.exe" VALUE "ProductName", "DCAuth" - VALUE "ProductVersion", "2.0.0" + VALUE "ProductVersion", "2.0.1" END END BLOCK "VarFileInfo" diff --git a/apps/dcauth/versioninfo_windows_amd64.syso b/apps/dcauth/versioninfo_windows_amd64.syso index 19aaaef5fab3cfc50cec77cc10b48001ea4686ca..3ca78af1b7a1308d2ff623f6364aa933911edca0 100644 GIT binary patch delta 33 mcmbQkK8Jn6DNaTP1_mY|X54sLlabMI^It||AT`;LIU4|l%Lms0 delta 33 kcmbQkK8Jn6DNY6;U;+^vFKaR~8f^Z{Xbhw#8!~4D0ELbR(*OVf diff --git a/docs/设备认证-dcauth协议.md b/docs/设备认证-dcauth协议.md index 514f88b0..614e9e0e 100644 --- a/docs/设备认证-dcauth协议.md +++ b/docs/设备认证-dcauth协议.md @@ -6,7 +6,7 @@ | app | 系统 | 生产入口 | |---|---|---| -| `order_site` | 订单后台 | `https://order.khhao.com` | +| `order_site` | 订单后台 | `https://ks.khhao.com`(兼容历史域名 `https://order.khhao.com`) | | `live_hub` | 直播运营后台 | `https://live.khhao.com` | | `affiliate_dash` | 皮肤分销后台 | `https://skin.khhao.com` |