File tree Expand file tree Collapse file tree 4 files changed +4
-18
lines changed Expand file tree Collapse file tree 4 files changed +4
-18
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ const booleanSchema = z.string().transform((v) => v.toLowerCase() === 'true')
4
4
5
5
const envSchema = z . object ( {
6
6
ENABLE_DIRECT_DOWNLOADS : booleanSchema . default ( 'false' ) ,
7
- DOWNLOAD_SECRET_KEY : z . string ( ) ,
8
7
URL_ACCESS_TOKEN : z . string ( ) . min ( 1 ) ,
9
8
CLEANUP_OLDER_THAN_DAYS : z . coerce . number ( ) . int ( ) . min ( 0 ) . default ( 90 ) ,
10
9
API_BASE_URL : z . string ( ) . url ( ) ,
Original file line number Diff line number Diff line change 1
- import { createHash , randomInt } from 'node:crypto'
1
+ import { randomBytes , randomInt } from 'node:crypto'
2
2
3
3
import consola from 'consola'
4
4
@@ -266,11 +266,7 @@ export async function initializeStorage() {
266
266
}
267
267
268
268
function createLocalDownloadUrl ( objectName : string ) {
269
- const hashedKey = createHash ( 'sha256' )
270
- . update ( objectName + ENV . DOWNLOAD_SECRET_KEY )
271
- . digest ( 'base64url' )
272
-
273
- return `${ ENV . API_BASE_URL } /download/${ hashedKey } /${ objectName } `
269
+ return `${ ENV . API_BASE_URL } /download/${ randomBytes ( 64 ) . toString ( 'base64' ) } /${ objectName } `
274
270
}
275
271
276
272
export function useStorageAdapter ( ) {
Original file line number Diff line number Diff line change 1
- import { createHash } from 'node:crypto'
2
-
3
1
import { z } from 'zod'
4
2
5
- import { ENV } from '~/lib/env'
6
3
import { useStorageAdapter } from '~/lib/storage'
7
4
8
5
const pathParamsSchema = z . object ( {
@@ -18,12 +15,7 @@ export default defineEventHandler(async (event) => {
18
15
statusMessage : `Invalid path parameters: ${ parsedPathParams . error . message } ` ,
19
16
} )
20
17
21
- const { objectName, hash } = parsedPathParams . data
22
-
23
- const hashedCacheId = createHash ( 'sha256' )
24
- . update ( objectName + ENV . DOWNLOAD_SECRET_KEY )
25
- . digest ( 'base64url' )
26
- if ( hashedCacheId !== hash ) throw createError ( { statusCode : 403 , statusMessage : 'Forbidden' } )
18
+ const { objectName } = parsedPathParams . data
27
19
28
20
const stream = await useStorageAdapter ( ) . download ( objectName )
29
21
Original file line number Diff line number Diff line change @@ -2,5 +2,4 @@ URL_ACCESS_TOKEN=test_token
2
2
API_BASE_URL=http://localhost:3000
3
3
NODE_ENV=development
4
4
RUNNER_TEMP=tests/temp/runner
5
- ACTIONS_CACHE_URL=http://localhost:3000/test_token/
6
- DOWNLOAD_SECRET_KEY=test_key
5
+ ACTIONS_CACHE_URL=http://localhost:3000/test_token/
You can’t perform that action at this time.
0 commit comments