diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2019-03-18 21:13:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-18 21:13:51 -0400 |
| commit | fc796595494c71938946967b9e00f3db25c8a9af (patch) | |
| tree | 049d624d2603f1904510ccd2ce7bb74c38b9abb1 | |
| parent | e81a6adb9503161708af5b659f60c6b8df5032a0 (diff) | |
| parent | 80aedcd7e24a7708f44491e3cd359f911a124c8f (diff) | |
Merge pull request #1127 from LogicalPhallacy/lockoutfix
Add configurable user lockout
| -rw-r--r-- | Emby.Server.Implementations/Library/UserManager.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Model/Users/UserPolicy.cs | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index ee90b3558..4cf703add 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -448,11 +448,19 @@ namespace Emby.Server.Implementations.Library user.Policy.InvalidLoginAttemptCount = newValue; - var maxCount = user.Policy.IsAdministrator ? 3 : 5; + // Check for users without a value here and then fill in the default value + // also protect from an always lockout if misconfigured + if (user.Policy.LoginAttemptsBeforeLockout == null || user.Policy.LoginAttemptsBeforeLockout == 0) + { + user.Policy.LoginAttemptsBeforeLockout = user.Policy.IsAdministrator ? 5 : 3; + } + + var maxCount = user.Policy.LoginAttemptsBeforeLockout; var fireLockout = false; - if (newValue >= maxCount) + // -1 can be used to specify no lockout value + if (maxCount != -1 && newValue >= maxCount) { _logger.LogDebug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue); user.Policy.IsDisabled = true; diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index 27ce23778..5415fd5e8 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -66,6 +66,7 @@ namespace MediaBrowser.Model.Users public bool EnableAllFolders { get; set; } public int InvalidLoginAttemptCount { get; set; } + public int? LoginAttemptsBeforeLockout { get; set; } public bool EnablePublicSharing { get; set; } @@ -104,6 +105,8 @@ namespace MediaBrowser.Model.Users AccessSchedules = Array.Empty<AccessSchedule>(); + LoginAttemptsBeforeLockout = -1; + EnableAllChannels = true; EnabledChannels = Array.Empty<string>(); |
