mirror of
https://github.com/cloudreve/Cloudreve.git
synced 2025-12-26 00:12:50 +00:00
fix(oss): change default expire ttl and sign param to adapt SDK v2 (#2979)
* fix(oss): change default expire ttl and sign param to adapt SDK v2 * fix(oss): add expire ttl limit
This commit is contained in:
parent
21cdafb2af
commit
6bd30a8af7
|
|
@ -67,6 +67,7 @@ type key int
|
||||||
const (
|
const (
|
||||||
chunkRetrySleep = time.Duration(5) * time.Second
|
chunkRetrySleep = time.Duration(5) * time.Second
|
||||||
maxDeleteBatch = 1000
|
maxDeleteBatch = 1000
|
||||||
|
maxSignTTL = time.Duration(24) * time.Hour * 7
|
||||||
completeAllHeader = "x-oss-complete-all"
|
completeAllHeader = "x-oss-complete-all"
|
||||||
forbidOverwriteHeader = "x-oss-forbid-overwrite"
|
forbidOverwriteHeader = "x-oss-forbid-overwrite"
|
||||||
trafficLimitHeader = "x-oss-traffic-limit"
|
trafficLimitHeader = "x-oss-traffic-limit"
|
||||||
|
|
@ -439,9 +440,13 @@ func (handler *Driver) Source(ctx context.Context, e fs.Entity, args *driver.Get
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler *Driver) signSourceURL(ctx context.Context, path string, expire *time.Time, req *oss.GetObjectRequest, forceSign bool) (string, error) {
|
func (handler *Driver) signSourceURL(ctx context.Context, path string, expire *time.Time, req *oss.GetObjectRequest, forceSign bool) (string, error) {
|
||||||
ttl := time.Duration(24) * time.Hour * 365 * 20
|
// V4 Sign 最大过期时间为7天
|
||||||
|
ttl := maxSignTTL
|
||||||
if expire != nil {
|
if expire != nil {
|
||||||
ttl = time.Until(*expire)
|
ttl = time.Until(*expire)
|
||||||
|
if ttl > maxSignTTL {
|
||||||
|
ttl = maxSignTTL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req == nil {
|
if req == nil {
|
||||||
|
|
@ -466,10 +471,12 @@ func (handler *Driver) signSourceURL(ctx context.Context, path string, expire *t
|
||||||
// 公有空间替换掉Key及不支持的头
|
// 公有空间替换掉Key及不支持的头
|
||||||
if !handler.policy.IsPrivate && !forceSign {
|
if !handler.policy.IsPrivate && !forceSign {
|
||||||
query := finalURL.Query()
|
query := finalURL.Query()
|
||||||
query.Del("OSSAccessKeyId")
|
query.Del("x-oss-credential")
|
||||||
query.Del("Signature")
|
query.Del("x-oss-date")
|
||||||
|
query.Del("x-oss-expires")
|
||||||
|
query.Del("x-oss-signature")
|
||||||
|
query.Del("x-oss-signature-version")
|
||||||
query.Del("response-content-disposition")
|
query.Del("response-content-disposition")
|
||||||
query.Del(trafficLimitHeader)
|
|
||||||
finalURL.RawQuery = query.Encode()
|
finalURL.RawQuery = query.Encode()
|
||||||
}
|
}
|
||||||
return finalURL.String(), nil
|
return finalURL.String(), nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue