2

i found that in my app the security with spring security does not check the case of my usernames at loging.

I have this code:

        authBuilder
                .jdbcAuthentication()
                .dataSource(dataSource)
                .usersByUsernameQuery("SELECT username, password, enabled FROM Utenti WHERE username = ?")
                .authoritiesByUsernameQuery("SELECT username, role FROM Utenti WHERE username = ?");

I dont know why when i use different particular cases for the username, the authentication of spring permits all. Can someone help me?

Thanks

luker74
  • 113
  • 9

1 Answers1

0

It is probably caused by your DB schema definition. Please check the types of your database columns. By default, Spring provides a schema for H2 which uses type VARCHAR_IGNORECASE. The schema can be adapted though, depending on your requirements and your specific database.

  • I use Mysql and my table is created with: username varchar(100) not null, password varchar(100) not null, What should I change? – luker74 Feb 06 '22 at 21:53