Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/http/plugins/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const jwtPlugin = fastifyPlugin<JWTPluginOptions>(
return
}

if (!request.jwt) {
request.jwtPayload = { role: 'anon' }
request.isAuthenticated = false
throw ERRORS.AccessDenied('Missing authorization header')
}

const { secret, jwks } = await getJwtSecret(request.tenantId)

try {
Expand Down
5 changes: 4 additions & 1 deletion src/http/routes/tus/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export async function onIncomingRequest(rawReq: Request, id: string, datastore:
req.upload.resources = [`${uploadID.bucket}/${uploadID.objectName}`]

// Handle signed url requests
if (req.url?.startsWith(`/upload/resumable/sign`)) {
if (
req.url?.startsWith(`${tusPath}${SIGNED_URL_SUFFIX}`) ||
req.url?.startsWith(`/upload/resumable${SIGNED_URL_SUFFIX}`)
) {
const signature = req.headers['x-signature']
if (!signature || (signature && typeof signature !== 'string')) {
throw ERRORS.InvalidSignature('Missing x-signature header')
Expand Down