Merge pull request #305 from Doha2012/master
prevent brute force improve
This commit is contained in:
		
						commit
						50cd7009c5
					
				| @ -45,7 +45,7 @@ public class MyUserDetailsService implements UserDetailsService { | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { |     public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { | ||||||
|         final String ip = request.getRemoteAddr(); |         final String ip = getClientIP(); | ||||||
|         if (loginAttemptService.isBlocked(ip)) { |         if (loginAttemptService.isBlocked(ip)) { | ||||||
|             throw new RuntimeException("blocked"); |             throw new RuntimeException("blocked"); | ||||||
|         } |         } | ||||||
| @ -88,4 +88,10 @@ public class MyUserDetailsService implements UserDetailsService { | |||||||
|         return authorities; |         return authorities; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     private String getClientIP() { | ||||||
|  |         final String xfHeader = request.getHeader("X-Forwarded-For"); | ||||||
|  |         if (xfHeader == null) | ||||||
|  |             return request.getRemoteAddr(); | ||||||
|  |         return xfHeader.split(",")[0]; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user