Skip to content

Commit 8e97eda

Browse files
committed
feat!: remove url token auth
1 parent 0d42977 commit 8e97eda

File tree

15 files changed

+144
-181
lines changed

15 files changed

+144
-181
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
URL_ACCESS_TOKEN=test_token
21
API_BASE_URL=http://localhost:3000
32
DEBUG=true
43

lib/auth.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/env.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const booleanSchema = z.string().transform((v) => v.toLowerCase() === 'true')
44

55
const envSchema = z.object({
66
ENABLE_DIRECT_DOWNLOADS: booleanSchema.default('false'),
7-
URL_ACCESS_TOKEN: z.string().min(1),
87
CLEANUP_OLDER_THAN_DAYS: z.coerce.number().int().min(0).default(90),
98
API_BASE_URL: z.string().url(),
109
STORAGE_DRIVER: z.string().toLowerCase().default('filesystem'),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"lint:ci": "eslint --cache --cache-strategy content . && prettier --check --cache --cache-strategy content .",
1717
"lint:fix": "eslint --fix --cache . && prettier --write --cache .",
1818
"type-check": "tsc -p tsconfig.json --noEmit",
19-
"action": "act -v --env ACTIONS_CACHE_URL=http://host.docker.internal:3000/test_token/ --container-architecture linux/amd64 -W tests",
19+
"action": "act -v --env ACTIONS_CACHE_URL=http://host.docker.internal:3000/ --container-architecture linux/amd64 -W tests",
2020
"test:watch": "DEBUG=true VITEST_DB_DRIVER=sqlite VITEST_STORAGE_DRIVER=filesystem vitest --watch --ui",
2121
"test:run": "vitest run"
2222
},

plugins/setup.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,17 @@ export default defineNitroPlugin(async (nitro) => {
1919
}
2020

2121
logger.error(
22-
`Response: ${event.method} ${obfuscateTokenFromPath(event.path)} > ${error instanceof H3Error ? error.statusCode : '[no status code]'}\n`,
22+
`Response: ${event.method} ${event.path} > ${error instanceof H3Error ? error.statusCode : '[no status code]'}\n`,
2323
error,
2424
)
2525
})
2626

2727
if (ENV.DEBUG) {
2828
nitro.hooks.hook('request', (event) => {
29-
logger.debug(`Request: ${event.method} ${obfuscateTokenFromPath(event.path)}`)
29+
logger.debug(`Request: ${event.method} ${event.path}`)
3030
})
3131
nitro.hooks.hook('afterResponse', (event) => {
32-
logger.debug(
33-
`Response: ${event.method} ${obfuscateTokenFromPath(event.path)} > ${getResponseStatus(event)}`,
34-
)
32+
logger.debug(`Response: ${event.method} ${event.path} > ${getResponseStatus(event)}`)
3533
})
3634
}
3735

@@ -60,9 +58,3 @@ export default defineNitroPlugin(async (nitro) => {
6058

6159
if (process.send) process.send('nitro:ready')
6260
})
63-
64-
function obfuscateTokenFromPath(path: string) {
65-
const split = path.split('/_apis')
66-
if (split.length <= 1) return path
67-
return `/<secret_token>/_apis${split[1]}`
68-
}

routes/[token]/_apis/artifactcache/cache.get.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

routes/[token]/_apis/artifactcache/caches/[cacheId].patch.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

routes/[token]/_apis/artifactcache/caches/[cacheId].post.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

routes/[token]/_apis/artifactcache/caches/index.post.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { z } from 'zod'
2+
3+
import { useStorageAdapter } from '~/lib/storage'
4+
5+
const queryParamSchema = z.object({
6+
keys: z
7+
.string()
8+
.min(1)
9+
.transform((value) => value.split(',')),
10+
version: z.string().min(1),
11+
})
12+
13+
export default defineEventHandler(async (event) => {
14+
const parsedQuery = queryParamSchema.safeParse(getQuery(event))
15+
if (!parsedQuery.success)
16+
throw createError({
17+
statusCode: 400,
18+
statusMessage: `Invalid query parameters: ${parsedQuery.error.message}`,
19+
})
20+
21+
const { keys, version } = parsedQuery.data
22+
23+
const adapter = await useStorageAdapter()
24+
const storageEntry = await adapter.getCacheEntry(keys, version)
25+
26+
if (!storageEntry) {
27+
setResponseStatus(event, 204)
28+
return
29+
}
30+
31+
return storageEntry
32+
})

0 commit comments

Comments
 (0)