If you are using DaoAuthenticationProvider, then I assume that you are using it JdbcDaoImpl, which loads users from the JDBC database.
If so, you can override the SQL query that you JdbcDaoImpluse to search for users by manually creating a bean yourself. The default query used by Spring Security:
select username,password,enabled from users where username = ?
You can use the bottom SQL function to ignore the case:
select username,password,enabled from users where lower(username) = lower(?)
Corresponding Spring XML security configuration:
<bean id="org.springframework.security.authenticationManager" class="org.springframework.security.authentication.ProviderManager">
<property name="providers">
<list>
<ref bean="daoAuthenticationProvider"/>
</list>
</property>
</bean>
<bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="caseInsensitiveUserDetailsService"/>
</bean>
<bean id="caseInsensitiveUserDetailsService" class="org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl">
<property name="usersByUsernameQuery" value="select username, password, enabled from users where lower(username) = lower(?)" />
</bean>
source
share