You can access /health without a api key now. #3

Merged
jtom38 merged 2 commits from features/health-no-auth into master 2023-06-13 21:39:59 -07:00
2 changed files with 12 additions and 1 deletions

View File

@ -14,7 +14,11 @@ steps:
- latest - latest
trigger: trigger:
branch: branch:
- master include:
- master
event:
exclude:
- pull_request
--- ---
kind: pipeline kind: pipeline

View File

@ -13,6 +13,13 @@ public class ApiKeyAuthAuthentication
public async Task InvokeAsync(HttpContext context) public async Task InvokeAsync(HttpContext context)
{ {
// allow access to /health without auth
if (context.Request.Path == "/health")
{
await _next(context);
return;
}
if (!context.Request.Headers.TryGetValue(HeaderApiKey, out var extractedApiKey)) if (!context.Request.Headers.TryGetValue(HeaderApiKey, out var extractedApiKey))
{ {
context.Response.StatusCode = 401; context.Response.StatusCode = 401;