prevent brute force improve

This commit is contained in:
DOHA 2015-12-12 13:19:57 +02:00
parent ffd0759d5a
commit 418be41d9c
1 changed files with 7 additions and 1 deletions

View File

@ -45,7 +45,7 @@ public class MyUserDetailsService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException {
final String ip = request.getRemoteAddr();
final String ip = getClientIP();
if (loginAttemptService.isBlocked(ip)) {
throw new RuntimeException("blocked");
}
@ -88,4 +88,10 @@ public class MyUserDetailsService implements UserDetailsService {
return authorities;
}
private String getClientIP() {
final String xfHeader = request.getHeader("X-Forwarded-For");
if (xfHeader == null)
return request.getRemoteAddr();
return xfHeader.split(",")[0];
}
}