prevent brute force improve
This commit is contained in:
parent
ffd0759d5a
commit
418be41d9c
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue