Keep GEO available before ingestion setup
Build and deploy Docker image / build (push) Successful in 34s
Build and deploy Docker image / build (push) Successful in 34s
This commit is contained in:
+6
-2
@@ -32,7 +32,12 @@ function secureTokenMatch(supplied: string, configured: string): boolean {
|
||||
&& timingSafeEqual(suppliedBuffer, configuredBuffer)
|
||||
}
|
||||
|
||||
function requireIngestionToken(request: FastifyRequest, configuredToken: string): void {
|
||||
function requireIngestionToken(request: FastifyRequest, configuredToken: string | undefined): void {
|
||||
if (!configuredToken) {
|
||||
const error = new Error('GEO ingestion is not configured') as Error & { statusCode: number }
|
||||
error.statusCode = 503
|
||||
throw error
|
||||
}
|
||||
const suppliedToken = request.headers['x-ingestion-token']
|
||||
if (typeof suppliedToken !== 'string' || !secureTokenMatch(suppliedToken, configuredToken)) {
|
||||
const error = new Error('Unauthorized GEO ingestion request') as Error & { statusCode: number }
|
||||
@@ -250,7 +255,6 @@ async function upsertReference(payload: ReferencePayload): Promise<IngestionResu
|
||||
|
||||
export async function registerIngestionRoutes(app: FastifyInstance): Promise<void> {
|
||||
const configuredToken = process.env.GEO_INGESTION_TOKEN
|
||||
if (!configuredToken) throw new Error('GEO_INGESTION_TOKEN is required')
|
||||
|
||||
app.post('/internal/ingest/catalog', async (request) => {
|
||||
requireIngestionToken(request, configuredToken)
|
||||
|
||||
Reference in New Issue
Block a user