Skip to content

Commit

Permalink
Ignore API Key when accessing healthcheck endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Jul 16, 2024
1 parent dac0162 commit 43d573c
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 43d573c

Please sign in to comment.