mihirdilip/aspnetcore-authentication-basic

IgnoreAuthenticationIfAllowAnonymous in HandleAuthenticateAsync specifically doesn't ignore

hcshmk opened this issue · 1 comments

Code in question:

if (IgnoreAuthenticationIfAllowAnonymous())
{
Logger.LogInformation("AllowAnonymous found on the endpoint so request was not authenticated.");
return AuthenticateResult.NoResult();
}

Problem:

The log statement at line 56 breaks the promise to ignore authentication if the endpoint is annotated with [AllowAnonymous].

Expected behavior:

When querying an endpoint annotated with [AllowAnonymous], authentication logic should be ignored.

Actual behavior:

When querying an endpoint annotated with [AllowAnonymous], two lines of log output are produced, stating that nothing is going on. (logspam)

Example:

info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.
info: AspNetCore.Authentication.Basic.BasicHandler[0]
No 'Authorization' header found in the request.

Pull request:

#8

Hi @hcshmk, your request is updated with 6.0.1 release just published. Sorry it took a while as I was waiting for .net6.0 release and then got busy with other stuff.