Skip to content

Commit

Permalink
Fix: Reorder whitelist checks for brute force protection.
Browse files Browse the repository at this point in the history
Swapped the order of IPWhitelist and SoftWhitelist checks in the brute force logic. This change prioritizes the evaluation of soft whitelisting over IP whitelisting, ensuring that users in the soft whitelist are handled first. This reordering aims to potentially improve performance and logical flow in specific scenarios.

Signed-off-by: Christian Roessner <[email protected]>
  • Loading branch information
Christian Roessner committed Dec 3, 2024
1 parent 136e6b5 commit a4cb884
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/core/bruteforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,19 +1010,19 @@ func (a *AuthState) CheckBruteForce() (blockClientIP bool) {
return false
}

if len(config.LoadableConfig.BruteForce.IPWhitelist) > 0 {
if a.IsInNetwork(config.LoadableConfig.BruteForce.IPWhitelist) {
if config.LoadableConfig.BruteForce.HasSoftWhitelist() {
if util.IsSoftWhitelisted(a.Username, a.ClientIP, *a.GUID, config.LoadableConfig.BruteForce.SoftWhitelist) {
a.AdditionalLogs = append(a.AdditionalLogs, definitions.LogKeyBruteForce)
a.AdditionalLogs = append(a.AdditionalLogs, definitions.Whitelisted)
a.AdditionalLogs = append(a.AdditionalLogs, definitions.SoftWhitelisted)

return false
}
}

if config.LoadableConfig.BruteForce.HasSoftWhitelist() {
if util.IsSoftWhitelisted(a.Username, a.ClientIP, *a.GUID, config.LoadableConfig.BruteForce.SoftWhitelist) {
if len(config.LoadableConfig.BruteForce.IPWhitelist) > 0 {
if a.IsInNetwork(config.LoadableConfig.BruteForce.IPWhitelist) {
a.AdditionalLogs = append(a.AdditionalLogs, definitions.LogKeyBruteForce)
a.AdditionalLogs = append(a.AdditionalLogs, definitions.SoftWhitelisted)
a.AdditionalLogs = append(a.AdditionalLogs, definitions.Whitelisted)

return false
}
Expand Down

0 comments on commit a4cb884

Please sign in to comment.