This is how I solved my problem thanks to all the answers above.
1. Add a special filter to my spring security: <custom-filter position="FORM_LOGIN_FILTER" ref="loginFilter" />
2. A random string is formed in the login controller and place it in an http session
String random = UUID.randomUUID().toString().toLowerCase().replaceAll("-", ""); request.getSession().setAttribute("userKeyInSession", random);
3. Also passed this random key to the login page so that the jsp login can present this as a hidden parameter along with the submit form.
model.addAttribute("userKey", random); return "login";
4. In LoginFilter, I now do a simple string comparison between the request parameter and the random value in the session. If they do not match, I reject and do not authenticate.
Read more: Captcha, etc. to prevent attacks from the user interface.
Supra source share