Skip to content

Conversation

@xrgzs
Copy link
Member

@xrgzs xrgzs commented Aug 27, 2025

Description / 描述

对 Cloudreve V4 驱动的令牌管理进行了增强,具体包括:

  • CloudreveV4 结构体中新增了 AccessExpiresRefreshExpires 字段,用于记录访问令牌和刷新令牌的过期时间。
  • 优化了初始化和认证流程,增加了令牌过期检查和刷新逻辑,确保在令牌过期前自动刷新或重新登录。
  • Token 结构体的过期时间字段类型由 time.Time 改为 string,以便更好地处理时间格式和时区问题。
  • 新增了 isTokenExpired 方法,支持判断令牌是否过期,并在过期前自动处理刷新或重新登录。
  • 对请求流程进行了调整,确保每次请求前都检查令牌有效性,并在必要时刷新令牌或重新登录。
  • 增加了错误处理和状态提示,提升了异常情况下的用户体验。

整体提升了 Cloudreve V4 驱动的令牌有效性管理和自动恢复能力。

Motivation and Context / 背景

容易报错 failed get objs: failed to list objs: Failed to issue token pair

ac1118bf8fa67c8c3d2f3a0eefb86df0

How Has This Been Tested? / 测试

  1. 每次 Init 自动刷新 Token
image
  1. 如果登录失败,错误信息输出到 Status,同时下线该驱动,避免一直登录错误 CC 源站导致 IP 被封

F5 测试,仅请求一次

  1. 增加 JWT 校验,避免用户没复制完整
image
  1. 处理填写为空的情况
image

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@xrgzs xrgzs force-pushed the fix/cloudreve-refreshtoken branch 6 times, most recently from 509648d to 5652fe6 Compare August 28, 2025 04:43
@xrgzs xrgzs changed the title feat(cloudreve-v4): enhance token management feat(cloudreve_v4): enhance token management Aug 28, 2025
@xrgzs xrgzs force-pushed the fix/cloudreve-refreshtoken branch from 5652fe6 to e5acb8f Compare August 28, 2025 04:52
xrgzs added 2 commits August 28, 2025 13:37
Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
…nd refresh logic

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
@xrgzs xrgzs force-pushed the fix/cloudreve-refreshtoken branch from e5acb8f to 4f60222 Compare August 28, 2025 05:37
xrgzs added 2 commits August 28, 2025 13:44
… validate access token on initialization

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
@xrgzs xrgzs marked this pull request as ready for review August 28, 2025 09:01
@xrgzs xrgzs requested a review from ILoveScratch2 August 28, 2025 09:03
@PIKACHUIM PIKACHUIM merged commit e97f0a2 into OpenListTeam:main Sep 4, 2025
12 checks passed
ForSourceCodeAnalysis pushed a commit to ForSourceCodeAnalysis/OpenList that referenced this pull request Oct 4, 2025
* fix(cloudreve_v4): improve error handling in request method

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* feat(cloudreve_v4): enhance token management with expiration checks and refresh logic

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* feat(cloudreve_v4): add JWT structures for access and refresh tokens; validate access token on initialization

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

* fix(cloudreve_v4): improve error messages

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>

---------

Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants