Skip to content

Commit

Permalink
optimize naming apikey middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Sep 28, 2022
1 parent cd46776 commit a010b87
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Nager.FirewallManagement/Middlewares/ApiKeyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public async Task InvokeAsync(HttpContext context)
return;
}

if (!context.Request.Headers.TryGetValue(ApiKeyHeaderName, out var potentialApiKey))
if (!context.Request.Headers.TryGetValue(ApiKeyHeaderName, out var receivedApiKey))
{
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
return;
}

var configuration = context.RequestServices.GetRequiredService<IConfiguration>();
var apiKey = configuration.GetValue<string>("ApiKey");
var expectedApiKey = configuration.GetValue<string>("ApiKey");

if (!apiKey.Equals(potentialApiKey))
if (!expectedApiKey.Equals(receivedApiKey))
{
var remoteIpAddress = context.Connection.RemoteIpAddress;
if (remoteIpAddress != null)
Expand Down

0 comments on commit a010b87

Please sign in to comment.