更新若干功能

This commit is contained in:
2026-08-19 08:16:49 +08:00
parent 4979bb83d2
commit 72bc6502eb
56 changed files with 3627 additions and 343 deletions

View File

@@ -111,8 +111,8 @@ class OssRuntimeConfigService extends BaseService
'id' => (int) $row->id,
'driver' => (string) $row->driver,
'name' => (string) $row->name,
'access_key' => $enc->decryptFromStorage((string) ($row->access_key ?? ''), true),
'secret_key' => $enc->decryptFromStorage((string) ($row->secret_key ?? ''), true),
'access_key' => $this->decryptSecret($enc, (string) ($row->access_key ?? ''), 'AccessKey'),
'secret_key' => $this->decryptSecret($enc, (string) ($row->secret_key ?? ''), 'SecretKey'),
'endpoint' => (string) ($row->endpoint ?? ''),
'region' => (string) ($row->region ?? ''),
'bucket' => (string) ($row->bucket ?? ''),
@@ -121,4 +121,21 @@ class OssRuntimeConfigService extends BaseService
'extra_json' => $extra,
];
}
/**
* 解密库内密钥;密文在但解不开时必须说清楚,不能静默变空串
*
* 以前 silentFail=true,解密失败后驱动只看到空 AccessKey
* 素材拉取就会报「七牛云配置不完整」,运营以为没填,其实是 ENCRYPT_KEY 对不上。
*/
private function decryptSecret(FieldEncryptService $enc, string $raw, string $label): string
{
$plain = $enc->decryptFromStorage($raw, true);
if ($raw !== '' && $plain === '' && $enc->isEncrypted($raw)) {
$this->utils->errorThrow(
'存储配置的' . $label . '解密失败,请到「系统配置 → 存储」重新填写密钥后保存'
);
}
return $plain;
}
}

View File

@@ -38,7 +38,7 @@ interface OssStorageInterface
* 素材库靠 marker 一页一页往回补bucket 上万对象时一次拉全量必然打穿
* PHP 的执行时限,所以约定「调用方拿着 next_marker 继续要下一页」。
*
* @param string $prefix 只列举该前缀,留空时退回配置里的 path_prefix
* @param string $prefix 只列举该前缀,留空表示整个 Bucket不套 path_prefix
* @param string $marker 上一页返回的 next_marker首页传空串
* @param int $limit 单页条数
* @return array{items: array<int, array{key:string,size:int,hash:string,last_modified:int,url:string}>, next_marker: string, finished: bool}
@@ -48,7 +48,7 @@ interface OssStorageInterface
/**
* 删除对象
*
* @param string $key 对象键( path_prefix 时由实现补齐
* @param string $key 对象键(素材库存的是列举/上传后的真实路径,不再补 path_prefix
*/
public function deleteObject(string $key): bool;
}