Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请求支持123云盘直链 #4924

Closed
4 tasks done
Bashir-1 opened this issue Aug 4, 2023 · 1 comment
Closed
4 tasks done

请求支持123云盘直链 #4924

Bashir-1 opened this issue Aug 4, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@Bashir-1
Copy link

Bashir-1 commented Aug 4, 2023

Please make sure of the following things

  • I have read the documentation.
  • I'm sure there are no duplicate issues or discussions.
  • I'm sure this feature is not implemented.
  • I'm sure it's a reasonable and popular requirement.

Description of the feature / 需求描述

123网盘最近上线会员功能,直链,请求支持。会员也比较便宜。

Suggested solution / 实现思路

直链鉴权开发指引

123云盘分发的直链下载内容默认为公开资源,用户拿到URL后均可访问,为防止站点资源被恶意下载盗用,您可以采用URL鉴权,自行配置校验鉴权URL中的加密串和时间戳,以达到一定的防止被盗链的目的。本文主要作用是介绍鉴权URL的逻辑、开启或关闭鉴权的方法。
鉴权逻辑
URL鉴权功能通过与用户站点配合,形成了更为安全可靠的资源防盗链方法。主要由以下几个部分配合:
用户站点:根据鉴权规则(包括鉴权算法、云盘上设置的密钥)生成带鉴权参数的下载资源链接返回给下载用户。
下载用户:使用资源链接发起下载请求。
123云盘:验证请求的有效性。(包括:鉴权字符串、时间戳等)
490a09b8faf5153055afb670b6ac4179_pic_stright db7359d7

图⾯说明:

  1. 云盘直链⽤户在⾃⼰的⽹站和123云盘中配置鉴权秘钥。
  2. 直链⽤户的⽹站被访问时,⽹站应⽤程序将根据123云盘提供的秘钥和鉴权算法对下载资源进⾏签名。
  3. 下载⽤户获取到带签名的资源,并执⾏下载请求。
  4. 123云盘对下载资源进⾏签名验证,判断请求的合法性。
    鉴权失败,拒绝访问请求。
    鉴权通过,正常响应合法请求。
    配置鉴权URL并开启鉴权
重要
请确保您已经在123云盘和您的应⽤服务器中配置了鉴权秘钥,并根据123云盘鉴权规则开发签名算法。
您的应⽤服务器签名逻辑需要与123云盘直链的鉴权规则保持⼀致。
  1. 登录123云盘直链管理。
  2. 在页面右下角,找到鉴权管理,点击开启。
  3. 修改并配置对应的鉴权密钥。
    关闭URL鉴权
  4. 在123云盘直链管理的鉴权设置区域,单击关闭URL鉴权开关。
  5. 在您的应用服务器中去掉请求URL的鉴权参数。
    鉴权⽅式说明
    URL鉴权功能主要⽤于保护⽤户站点资源不被恶意盗⽤。
    原理说明
  6. 签名算法构成
    http://vip.123pan.cn/$uid/$path?auth_key=$timestamp-$rand-$uid-$md5hash
  7. 鉴权字段说明
    93b0c40a2a42b814cb699ecc3fb1b57c_pic_list 2ac80e87

鉴权URL示例:
通过以下示例说明,您可以准确理解鉴权的实现⽅式。
【示例条件】
在123云盘中设置密钥为:289ds32418bxdba
该链接您想 1 分钟以后失效,假设⼀分钟后的unix时间戳为:1689220731
您的云盘UID为:13
您在您的⽹站程序中⽣成的随机数为:123
原始URL:
http://vip.123pan.cn/13/files/1.txt
计算过程如下:
http://vip.123pan.cn/13/files/1.txt?auth_key=1689220731-123-13-md5函数(/13/files/1.txt-1689220731-123-13-289ds32418bxdba)
鉴权后URL:
http://vip.123pan.cn/13/files/1.txt?auth_key=1689220731-123-13-3bdacc0e031fd67fe829152f37c8fbad
当资源下载请求⾄123云盘时,云盘将分析签名中的时间戳是否过期,并判断签名是否有效。
开发代码示例(多种语言)
为了开发者更好的理解鉴权的开发,我们准备了多种语言的开发示例,可以参考以下网址。
https://gitee.com/pan123-git/123pan-link

Additional context / 附件

https://www.123pan.com/faq?problem=dev_guide#a1

@Bashir-1 Bashir-1 added the enhancement New feature or request label Aug 4, 2023
@welcome
Copy link

welcome bot commented Aug 4, 2023

Thanks for opening your first issue here! Be sure to follow the issue template!

@xhofe xhofe reopened this Sep 10, 2023
@xhofe xhofe added the working In process label Sep 10, 2023
@xhofe xhofe added this to the v3.28.0 milestone Sep 10, 2023
@xhofe xhofe closed this as completed in 9e0fa77 Sep 10, 2023
@github-actions github-actions bot removed the working In process label Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants