fix(media): 资源访问 - 签名地址有效期跟随后台策略并放开服务器访问地址限制
平台展示与厂商读取的签名地址有效期改为读取「资源与请求策略」,默认均为 4 小时,不再硬编码 5 分钟。服务器访问地址只校验 http/https 格式,允许本机、局域网或 HTTP 地址,模型读取平台资源不再强制 HTTPS 公网地址。
This commit is contained in:
1 parent
4957f8bc22
commit
4272b0e499
9 files changed
+40
-14
No files matched your search
@@ -102,9 +102,11 @@ func ResolveAccess(resource *model.Resource, setting storage.Settings, options A
|
||||
if resource.Status != model.ResourceStatusReady {
|
||||
return nil, AccessError(http.StatusConflict, "resource_not_ready", "资源尚未上传完成")
|
||||
}
|
||||
ttl := 5 * time.Minute
|
||||
// 有效期来自后台「资源与请求策略」;未注入运行时策略时回落到存储层默认值(均为 4 小时)。
|
||||
runtime := storage.NormalizeSettings(storage.Settings{Runtime: setting.Runtime}).Runtime
|
||||
ttl := runtime.AccessURLTTL
|
||||
if options.Purpose == PurposeProvider {
|
||||
ttl = 4 * time.Hour
|
||||
ttl = runtime.ProviderAccessURLTTL
|
||||
}
|
||||
expires := now.Add(ttl)
|
||||
if !options.ExpiresAt.IsZero() && options.ExpiresAt.Before(expires) {
|
||||
|
||||
Reference in new issue
Block a user