dotnet-starter-kit icon indicating copy to clipboard operation
dotnet-starter-kit copied to clipboard

Fix hangfire authentication filter

Open snax4a opened this issue 3 years ago • 0 comments

When we open the hangfire dashboard and it is asking for basic authentication we can see these log messages.

[15:00:52 ERR] StatusCode cannot be set because the response has already started. Request failed with Status Code 401 and Error Id 3d280b05-922c-4a8f-9cb7-0355a132be1b.
[15:00:52 WRN] Can't write error response. Response has already started.

After the successful authentication, the errors are gone. This happens because of this line in currently used authentication filter https://github.com/StoneAgeTechnologies/HangfireBasicAuthenticationFilter/blob/2a40ac62dc317bb156a02ea1ca3f7847358bb12b/source/HangfireBasicAuthenticationFilter/HangfireCustomBasicAuthenticationFilter.cs#L93

This issue is also reported in this package issues https://github.com/StoneAgeTechnologies/HangfireBasicAuthenticationFilter/issues/3 Also there is a fix PR for that https://github.com/StoneAgeTechnologies/HangfireBasicAuthenticationFilter/pull/5 but it looks like the package is abandoned, the issues and PRs are open for months so I decided fix this issue by move their implementation with some minor changes to FSH boilerplate.

This might be related to #526

snax4a avatar May 10 '22 15:05 snax4a