1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-21 22:05:43 -04:00

New: Added Auth-* log entries for fail2ban purposes

This commit is contained in:
Taloth Saldono
2019-08-27 23:29:16 +02:00
committed by Qstick
parent 1368c7c6e3
commit 6c4e3b1fd5
4 changed files with 128 additions and 7 deletions
@@ -3,6 +3,8 @@ using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Extensions;
using Nancy.ModelBinding;
using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
@@ -10,12 +12,12 @@ namespace Radarr.Http.Authentication
{
public class AuthenticationModule : NancyModule
{
private readonly IUserService _userService;
private readonly IAuthenticationService _authService;
private readonly IConfigFileProvider _configFileProvider;
public AuthenticationModule(IUserService userService, IConfigFileProvider configFileProvider)
public AuthenticationModule(IAuthenticationService authService, IConfigFileProvider configFileProvider)
{
_userService = userService;
_authService = authService;
_configFileProvider = configFileProvider;
Post["/login"] = x => Login(this.Bind<LoginResource>());
Get["/logout"] = x => Logout();
@@ -23,7 +25,7 @@ namespace Radarr.Http.Authentication
private Response Login(LoginResource resource)
{
var user = _userService.FindUser(resource.Username, resource.Password);
var user = _authService.Login(Context, resource.Username, resource.Password);
if (user == null)
{
@@ -43,6 +45,8 @@ namespace Radarr.Http.Authentication
private Response Logout()
{
_authService.Logout(Context);
return this.LogoutAndRedirect(_configFileProvider.UrlBase + "/");
}
}