Skip to content

Commit

Permalink
fix: accept forwarded header on signature, increase migrations timeou…
Browse files Browse the repository at this point in the history
…t, disable host validation on queue
  • Loading branch information
fenos committed Apr 13, 2024
1 parent 6af2407 commit 37b424d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/database/migrations/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function connectAndMigrate(options: {

const dbConfig: ClientConfig = {
connectionString: databaseUrl,
connectionTimeoutMillis: 10_000,
connectionTimeoutMillis: 60_000,
options: `-c search_path=${searchPath}`,
ssl,
}
Expand Down
1 change: 1 addition & 0 deletions src/queue/events/base-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export abstract class BaseEvent<T extends Omit<BasePayload, '$version'>> {
superUser: adminUser,
host: payload.tenant.host,
tenantId: payload.tenant.ref,
disableHostCheck: true,
})

const db = new StorageKnexDB(client, {
Expand Down
8 changes: 8 additions & 0 deletions src/storage/protocols/s3/signature-v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ export class SignatureV4 {
if (xForwardedHost) {
return `host:${xForwardedHost.toLowerCase()}`
}

const forwarded = this.getHeader(request, 'forwarded')
if (forwarded) {
const extractedHost = /host="?([^";]+)/.exec(forwarded)?.[1]
if (extractedHost) {
return `host:${extractedHost.toLowerCase()}`
}
}
}

return `${header.toLowerCase()}:${
Expand Down

0 comments on commit 37b424d

Please sign in to comment.