I'm using Spring security with JSESSION
cookie so every user gets that cookie after its login with credentials:
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().httpBasic()
return http.build();
}
I created a UserService
to create, retrieve, update and delete users and UserDetailsServiceImpl
(which uses UserService
) to implement UserDetailsService
:
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserService userService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return userService.findByUsername(username);
}
}
So users can be deleted. Maybe the delete command is executed by other user rather than him so I don't have the session context.
I want to invalidate all cookies related to a user when I delete him so he cannot enter the app again using his old cookies.
Is there any way?
Thanks in advance.