mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-12-04 02:23:59 +00:00
fix: isolate server-side donation credentials and rotate auth defaults (#320)
This commit is contained in:
19 files changed
+190
-125
No files matched your search
@@ -33,8 +33,8 @@ URL解码 → Base64解码 → AES解密 → JSON对象
|
||||
### 加密配置
|
||||
|
||||
- **加密算法**: AES/ECB/PKCS5Padding
|
||||
- **密钥长度**: 16位(128位)
|
||||
- **默认密钥**: `nfd_auth_key2026`(可在 `app-dev.yml` 中通过 `server.authEncryptKey` 配置)
|
||||
- **密钥长度**: 16、24 或 32 个 UTF-8 字节
|
||||
- **密钥**: 没有公共默认值。需要对接的可信客户端应使用自建服务显式配置的 `server.authEncryptKey`。
|
||||
|
||||
### 密钥作用说明(重要)
|
||||
|
||||
@@ -43,7 +43,7 @@ URL解码 → Base64解码 → AES解密 → JSON对象
|
||||
1. `server.authEncryptKey`
|
||||
- 用途:加解密 `auth` 参数(前端/调用方传入的认证信息)
|
||||
- 影响范围:`/parser`、`/json/parser`、`/v2/linkInfo` 等接口中的 `auth` 参数
|
||||
- 注意:这是 **AES 对称加密密钥**,要求 16 位
|
||||
- 注意:这是 **AES 对称加密密钥**,要求 16、24 或 32 字节
|
||||
|
||||
2. `server.donatedAccountFailureTokenSignKey`
|
||||
- 用途:签名和验签“捐赠账号失败计数 token”(用于防伪造、失败计数)
|
||||
@@ -194,7 +194,7 @@ AuthParam decoded = AuthParamCodec.decode(encrypted);
|
||||
// 使用 CryptoJS 库
|
||||
const CryptoJS = require('crypto-js');
|
||||
|
||||
const AUTH_KEY = 'nfd_auth_key2026';
|
||||
const AUTH_KEY = process.env.NFD_AUTH_ENCRYPT_KEY;
|
||||
|
||||
// 加密
|
||||
function encodeAuthParam(authObj) {
|
||||
@@ -234,7 +234,8 @@ from urllib.parse import quote, unquote
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
|
||||
AUTH_KEY = b'nfd_auth_key2026'
|
||||
import os
|
||||
AUTH_KEY = os.environ['NFD_AUTH_ENCRYPT_KEY'].encode('utf-8')
|
||||
|
||||
def encode_auth_param(auth_obj):
|
||||
"""加密认证参数"""
|
||||
@@ -323,8 +324,8 @@ if (auths != null) {
|
||||
|
||||
```yaml
|
||||
server:
|
||||
# auth参数加密密钥(16位AES密钥)
|
||||
authEncryptKey: 'your_custom_key16'
|
||||
# auth参数加密密钥(16、24 或 32 字节)
|
||||
# authEncryptKey: "" # 仅在可信客户端或多实例需共享密钥时显式配置
|
||||
|
||||
# 捐赠账号失败计数token签名密钥(HMAC)
|
||||
# 建议使用较长随机字符串,并与 authEncryptKey 不同
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
## 使用说明
|
||||
|
||||
1. **编码流程**: JSON对象 → AES加密 → Base64编码 → URL编码
|
||||
2. **加密配置**: AES/ECB/PKCS5Padding, 密钥: `nfd_auth_key2026` (16位)
|
||||
2. **加密配置**: AES/ECB/PKCS5Padding, 密钥: 自建服务配置值(无公共默认值)
|
||||
3. **接口调用**: `GET /parser?url={分享链接}&pwd={提取码}&auth={加密认证参数}`
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user