Skip to content

Commit 586bb9c

Browse files
author
yuguo.dtpe
committed
fix(sso): shorten access token refresh window
Reduce the SSO access token refresh window from 15 minutes to 5 minutes for one-hour tokens, avoiding unnecessarily early refresh attempts during normal business commands.
1 parent c1e06bc commit 586bb9c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cmd/sso.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/volcengine/volcengine-cli/util"
1818
)
1919

20-
const ssoAccessTokenRefreshWindow = 15 * time.Minute
20+
const ssoAccessTokenRefreshWindow = 5 * time.Minute
2121

2222
var (
2323
// getSsoConfigFileDir 是 SSO 缓存目录的注入点,生产环境固定使用 util.GetConfigFileDir。
@@ -261,7 +261,7 @@ func tokenExpired(expiresAt string) bool {
261261
}
262262

263263
// tokenNeedsRefresh 判断 access token 是否需要刷新。
264-
// 与 AWS 新式 sso-session 语义保持一致:业务命令不会等到完全过期才刷新,而是在过期前窗口内提前静默续期。
264+
// 业务命令不会等到完全过期才刷新,而是在过期前窗口内提前静默续期。
265265
func tokenNeedsRefresh(expiresAt string) bool {
266266
if expiresAt == "" {
267267
return true
@@ -722,7 +722,7 @@ func (f *DeviceCodeFetcher) GetToken() (*SsoTokenCache, error) {
722722
}
723723

724724
// GetFreshTokenForLogin 执行显式登录授权。
725-
// 对齐 AWS sso login:无论缓存 access token 是否有效,也不会用 refresh_token 静默完成登录。
725+
// 无论缓存 access token 是否有效,也不会用 refresh_token 静默完成登录。
726726
func (f *DeviceCodeFetcher) GetFreshTokenForLogin() (*SsoTokenCache, error) {
727727
ctx := context.Background()
728728
cached, err := f.loadCachedToken()

0 commit comments

Comments
 (0)