Skip to content

Commit a2121dc

Browse files
committed
fix bug in HandleAuthenticateAsync
1 parent 6f3c203 commit a2121dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/AspNetCore.SecurityKey/SecurityKeyAuthenticationHandler.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ public SecurityKeyAuthenticationHandler(
5252
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
5353
{
5454
var securityKey = _securityKeyExtractor.GetKey(Context);
55-
var identity = await _securityKeyValidator.Authenticate(securityKey);
5655

56+
// If no security key is provided, return no result
57+
if (string.IsNullOrEmpty(securityKey))
58+
return AuthenticateResult.NoResult();
59+
60+
var identity = await _securityKeyValidator.Authenticate(securityKey);
5761
if (!identity.IsAuthenticated)
5862
return AuthenticateResult.Fail("Invalid Security Key");
5963

0 commit comments

Comments
 (0)