From cc817764366ef269310bfe7143dcda62bad56333 Mon Sep 17 00:00:00 2001 From: "hoang.le" Date: Mon, 29 Apr 2024 10:12:13 -0700 Subject: [PATCH] add empty string validation to apikeymiddle --- OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs b/OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs index 3504aca1..702f72ad 100644 --- a/OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs +++ b/OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs @@ -48,7 +48,7 @@ public async Task InvokeAsync(HttpContext context, return; } - _logger.LogError(CustomLogEvent.API, "Attempted Key: [x-ofm-apikey:{extractedApiKey}]", extractedApiKey); + _logger.LogError(CustomLogEvent.API, "Attempted Key: [x-ofm-apikey:{extractedApiKey}]", string.IsNullOrEmpty(extractedApiKey) ? "NA" : extractedApiKey); context.Response.StatusCode = StatusCodes.Status401Unauthorized; await context.Response.WriteAsync(options.Value.Schemes.ApiKeyScheme.ApiKeyErrorMesssage);