feat(settings): 新增 DWS 设备登录与目录连接检查
build / build (push) Successful in 1m52s

数据源配置可发起钉钉官方设备授权、重新授权和取消,完成后刷新共享账号状态并独立检查目录权限。
授权会话限定发起的管理员登录会话,令牌由现有 CLI 存储,取消等待子进程退出。

验证:完整 make verify 通过;前端 582 项、Go 1545 项通过,487 项声明的可选集成未运行。
授权处理器与 HTTP 边界通过 race 检查;本人钉钉授权仍由管理员在官方页面完成。
This commit is contained in:
姚章浩
2026-11-17 16:59:47 +08:00
parent 6c10f71c28
commit b2cea6ed84
20 changed files with 1291 additions and 46 deletions
+7 -1
View File
@@ -12,6 +12,9 @@ type CredentialStatus struct {
RefreshTokenValid bool `json:"refresh_token_valid"`
ExpiresAt string `json:"expires_at,omitempty"`
RefreshExpiresAt string `json:"refresh_expires_at,omitempty"`
CorpName string `json:"corp_name,omitempty"`
UserName string `json:"user_name,omitempty"`
StatusKnown bool `json:"status_known"`
}
func ReadCredentialStatus(ctx context.Context, runner Runner) (CredentialStatus, error) {
@@ -24,9 +27,12 @@ func ReadCredentialStatus(ctx context.Context, runner Runner) (CredentialStatus,
RefreshTokenValid bool `json:"refresh_token_valid"`
ExpiresAt string `json:"expires_at"`
RefreshExpiresAt string `json:"refresh_expires_at"`
CorpName string `json:"corp_name"`
UserName string `json:"user_name"`
Reason string `json:"reason"`
}
if json.Unmarshal(raw, &decoded) != nil || decoded.Authenticated == nil {
return CredentialStatus{}, errors.New("invalid DWS credential status")
}
return CredentialStatus{*decoded.Authenticated, decoded.RefreshTokenValid, decoded.ExpiresAt, decoded.RefreshExpiresAt}, nil
return CredentialStatus{Authenticated: *decoded.Authenticated, RefreshTokenValid: decoded.RefreshTokenValid, ExpiresAt: decoded.ExpiresAt, RefreshExpiresAt: decoded.RefreshExpiresAt, CorpName: decoded.CorpName, UserName: decoded.UserName, StatusKnown: decoded.Reason == ""}, nil
}