Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Spring Security accept multiple passwords for the same user?

I have Spring Security working within my application to authenticate a user with one password. I'm trying to meet a requirement that an override password will also authenticate that same user.

How can I do this with Spring Security?

like image 372
Tom Avatar asked Feb 22 '13 14:02

Tom


People also ask

Does Spring Security support password hashing?

The BCryptPasswordEncoder implementation uses the widely supported bcrypt algorithm to hash the passwords.

How should passwords be stored in spring?

The passwords are stored in the relational database. To keep it simple in this example we send the user credentials with every HTTP request. It means the application must start authentication whenever the client wants to access the API.

Does Spring Security support password hashing salting?

Fortunately, Spring Security includes password hashing out of the box. What's more, since version 3.1, Spring Security automatically takes care of salting too. The following example is available to download from GitHub in version 3.4 of the Spanners app.

How does Spring Security know password?

To verify the user entered the correct password, use the same one way hash against their entered value and then compare it with the previously hashed value - if they are the same, then the entered password is correct.


1 Answers

It is possible, you will have to implement your own AuthenticationProvider possibly by extending the existing DaoAuthenticationProvider (see additionalAuthenticationChecks() in there).
Also the user is only associated with a single password by default (UserDetails.getPassword()), so you will need to have an extension of that class holding multiple passwords, and a corresponding implementation of UserDetailsService that knows how to load the user along with its passwords.

like image 75
zagyi Avatar answered Oct 11 '22 01:10

zagyi