简体   繁体   中英

authentication in spring security case insensitive

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

Seems similar to Spring boot security consider case insensitive username check for login

I think this will solve your problem Can you please mention your column type too

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM