Spring Security with multiple input authentications
In this section, we will demonstrate multiple input authentications. This is also called two factor authentications. So far, in all our examples, we are authenticating against username and password. In this example, we will provide another field for phone number along with username. It is the same horrormovie
application with hibernate and derby database.
Getting ready
- Create a custom filter to handle the new login form
- Configure the custom filter in your
Springsecurity.xml
file - Update the
UserDetailsService
implementation class to handle the additional input - Add an extra column named
MOBILE_NO
in your database - Update the
login.jsp
file to takeMOBILE_NO
as input
How to do it...
The following are the steps to implement multiple input authentications with Spring Security:
- Create a custom filter named
MultipleInputAuthenticationFilter
to extract the extra mobile number parameter.public class MultipleInputAuthenticationFilter extends UsernamePasswordAuthenticationFilter...