Skip to content

Commit

Permalink
Fix: Remove redundant password history checks in cache loading
Browse files Browse the repository at this point in the history
Eliminated the unnecessary verification steps related to password history within the cache loading process. This streamlines the function and avoids redundant password lookups for already known wrong passwords.

Signed-off-by: Christian Roessner <c@roessner.co>
  • Loading branch information
Christian Roessner committed Nov 14, 2024
1 parent d36f508 commit ca5a322
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions server/core/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func cachePassDB(auth *AuthState) (passDBResult *PassDBResult, err error) {
ppc = &backend.PositivePasswordCache{}

isRedisErr := false

if isRedisErr, err = backend.LoadCacheFromRedis(auth.HTTPClientContext, redisPosUserKey, ppc); err != nil {
return
}
Expand All @@ -78,19 +77,5 @@ func cachePassDB(auth *AuthState) (passDBResult *PassDBResult, err error) {
}
}

if !passDBResult.Authenticated {
if key := auth.getPasswordHistoryRedisHashKey(true); key != "" {
auth.loadPasswordHistoryFromRedis(key)
}

// Prevent password lookups for already known wrong passwords (And the user is unknown in the entire system)
if auth.PasswordHistory != nil {
passwordHash := util.GetHash(util.PreparePassword(auth.Password))
if _, foundPassword := (*auth.PasswordHistory)[passwordHash]; foundPassword {
passDBResult.UserFound = true
}
}
}

return
}

0 comments on commit ca5a322

Please sign in to comment.