My linux world » Java Spring Security – Remember me

Java Spring Security - Remember me


Prerequistes

Please read Java Spring Security – Database User

Configuration

SecurityConfiguration.java

Update ‘configure(HttpSecurity http)’ method, add this :

  http
   . (...)
   .and()
            .rememberMe()
            .tokenRepository(persistentTokenRepository())
            .tokenValiditySeconds(1209600)
            .key("remember me")
            .rememberMeParameter("j_spring_security_remember_me")

where persistentTokenRepository() :

@Bean
	public PersistentTokenRepository persistentTokenRepository() {
		JdbcTokenRepositoryImpl db = new JdbcTokenRepositoryImpl();
		db.setDataSource(dataSource);
		return db;
	}

Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.