mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-23 22:45:06 -04:00
New: Added Auth-* log entries for fail2ban purposes
This commit is contained in:
@@ -43,18 +43,28 @@ namespace Radarr.Http.Authentication
|
||||
else if (_configFileProvider.AuthenticationMethod == AuthenticationType.Basic)
|
||||
{
|
||||
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(_authenticationService, "Radarr"));
|
||||
pipelines.BeforeRequest.AddItemToStartOfPipeline(CaptureContext);
|
||||
}
|
||||
|
||||
pipelines.BeforeRequest.AddItemToEndOfPipeline((Func<NancyContext, Response>)RequiresAuthentication);
|
||||
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>)RemoveLoginHooksForApiCalls);
|
||||
}
|
||||
|
||||
private Response CaptureContext(NancyContext context)
|
||||
{
|
||||
_authenticationService.SetContext(context);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Response RequiresAuthentication(NancyContext context)
|
||||
{
|
||||
Response response = null;
|
||||
|
||||
if (!_authenticationService.IsAuthenticated(context))
|
||||
{
|
||||
_authenticationService.LogUnauthorized(context);
|
||||
response = new Response { StatusCode = HttpStatusCode.Unauthorized };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user