Support for a custom schema
It’s common for new users of Spring Security to begin their experience by adapting the JDBC user, group, or role mapping to an existing schema. Even though a legacy database doesn’t conform to the expected Spring Security schema, we can still configure JdbcDaoImpl
to map to it.
We will now update Spring Security’s JDBC support to use our existing CalendarUser
database along with a new calendar_authorities
table.
We can easily change the configuration of JdbcUserDetailsManager
to utilize this schema and override Spring Security’s expected table definitions and columns, which we’re using for the JBCP calendar application.
In the following subsections, we will update the SQL user and authorities scripts to insert custom roles. At the end, we will configure JdbcUserDetailsManager
to use this custom SQL queries.
Determining the correct JDBC SQL queries
The JdbcUserDetailsManager
class has three SQL queries that...