Skip to content

Commit

Permalink
Ignore API Key when accessing healthcheck endpoint (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl authored Jul 24, 2024
1 parent 2b9f713 commit 58ee71c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion TramsDataApi/Middleware/ApiKeyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public ApiKeyMiddleware(RequestDelegate next, ILogger<ApiKeyMiddleware> logger)
}
public async Task InvokeAsync(HttpContext context, IUseCase<string, ApiUser> apiKeyService)
{
// Bypass API Key requirement for health check route
if (context.Request.Path == "/HealthCheck") {
await _next(context);
return;
}

if (!context.Request.Headers.TryGetValue(APIKEYNAME, out var extractedApiKey))
{
context.Response.StatusCode = 401;
Expand All @@ -43,4 +49,4 @@ public async Task InvokeAsync(HttpContext context, IUseCase<string, ApiUser> api
}
}
}
}
}

0 comments on commit 58ee71c

Please sign in to comment.