Add download link expiration time
This commit is contained in:
parent
56963834b1
commit
4c0255bb25
@ -14,11 +14,12 @@ export async function downloadDispatcher(request, env, ctx) {
|
|||||||
|
|
||||||
if (!signature && request.headers.get('x-access-token') !== adminSecret)
|
if (!signature && request.headers.get('x-access-token') !== adminSecret)
|
||||||
return new Response(null, { status: 403, statusText: 'Forbidden' });
|
return new Response(null, { status: 403, statusText: 'Forbidden' });
|
||||||
else {
|
|
||||||
const hash = await getHashString(`${key}${timestamp}${signatureBase}`, 'SHA-1');
|
const hash = await getHashString(`${key}${timestamp}${signatureBase}`, 'SHA-1');
|
||||||
if (signature !== hash)
|
if (signature !== hash)
|
||||||
return new Response(null, { status: 403, statusText: 'Forbidden' });
|
return new Response(null, { status: 403, statusText: 'Forbidden' });
|
||||||
}
|
if (Date.now() - Number(timestamp) > 1000 * 60 * 5) // 5 minutes
|
||||||
|
return new Response(null, { status: 403, statusText: 'Signature Expired' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const object = await bucket.get(key);
|
const object = await bucket.get(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user