Hello to all. Screwed the remember-me, if not ticked (remember-me), it works fine.
If you put a tick (remember-me) and then go to the logout page, the system throws it onto the authorization page, but if you go to any closed page, then I log in as an authorized user, i.e. there was virtually no way out and the browser will remember me until the cookies expire.
In the settings I registered to delete "JSESSIONID" and "remember-me", but did not bring any result. How should I describe to exit?
Security Settings
@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true) public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired @Qualifier("userDetailsService") public UserDetailsService userDetailsService; @Autowired public DataSource dataSource; @Autowired public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(getShaPasswordEncoder()); } @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable().authorizeRequests().antMatchers("/static/**", "/**").permitAll() .anyRequest().permitAll().and(); http.formLogin().loginPage("/login").usernameParameter("login") .passwordParameter("password").and().rememberMe().rememberMeParameter("remember-me") .tokenRepository(persistentTokenRepository()).tokenValiditySeconds(86400).and() .csrf().and().exceptionHandling().accessDeniedPage("/403"); http.logout().permitAll().logoutUrl("/logout").logoutSuccessUrl("/login?logout") .invalidateHttpSession(true).deleteCookies("JSESSIONID"); /* http.exceptionHandling().accessDeniedPage("/403"); */ } @Bean public PersistentTokenRepository persistentTokenRepository() { JdbcTokenRepositoryImpl tokenRepositoryImpl = new JdbcTokenRepositoryImpl(); tokenRepositoryImpl.setDataSource(dataSource); return tokenRepositoryImpl; } @Bean public ShaPasswordEncoder getShaPasswordEncoder() { return new ShaPasswordEncoder(); } } Service
@Service public class UserDetailsServiceImpl implements UserDetailsService { @Autowired private UserService userService; @Override @Transactional(readOnly = true) public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException { User user = userService.getUser(login); if (user == null) throw new UsernameNotFoundException("Username not found"); return new org.springframework.security.core.userdetails.User(user.getLogin(), user.getPassword(), true, true, true, true, getGrantedAuthorities(user)); } private List<GrantedAuthority> getGrantedAuthorities(User user) { Set<UserRole> userRols = user.getRols(); List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); for (UserRole userRole : userRols) authorities.add(new SimpleGrantedAuthority("ROLE_" + userRole.getRole())); return authorities; } } Controller part
@RequestMapping(value = "/login", method = RequestMethod.GET) public String loginPage() { return "login"; } @RequestMapping(value = "/logout", method = RequestMethod.GET) public String logoutPage(HttpServletRequest request, HttpServletResponse response) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth != null) new SecurityContextLogoutHandler().logout(request, response, auth); return "redirect:/login?logout"; }