Configuring the persistent-based remember-me feature
Finally, we'll need to make some brief configuration changes to the rememberMe
declaration to point it to the data source we're using, as shown in the following code snippet:
//src/main/java/com/packtpub/springsecurity/configuration/SecurityConfig.java @Autowired @SuppressWarnings("SpringJavaAutowiringInspection") private DataSource dataSource; @Autowired private PersistentTokenRepository persistentTokenRepository; @Override protected void configure(HttpSecurity http) throws Exception { ... http.rememberMe() .key("jbcpCalendar") .tokenRepository(persistentTokenRepository) ... } @Bean public PersistentTokenRepository persistentTokenRepository() { JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl(); db.setDataSource(dataSource); return db; }
This is all we need to do to switch over to using persistent-based remember-me authentication...