Skip to content

Commit

Permalink
add empty string validation to apikeymiddle
Browse files Browse the repository at this point in the history
  • Loading branch information
bcgov-hl committed Apr 29, 2024
1 parent 980418d commit cc81776
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cc81776

Please sign in to comment.