I am using jwt token with spring security tuto .
After successfully generating the token on login and passing it to my angular application in localStorage object. I have one problem that on logout I delete the token but still using the same token I can hit secured api through Postman.
How can i delete the user token when he goes to logout url of the front application ?
Updated: I created this logout function in my service:
public void logout(HttpServletRequest request){
if(request != null){
String authHeader = request.getHeader("Authorization");
if (authHeader != null) {
String tokenValue = authHeader.replaceFirst("(?i)" + "bearer", "").trim();
log.info("Token to remove value = {}", tokenValue);
OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
if (accessToken != null) {
tokenStore.removeAccessToken(accessToken);
log.info("Token has been removed");
}
else{
log.info("accessToken not found");
}
log.info("logging ");
}
}
}
The logic thing to happen is that the token provided to the logout url gets deleted from my mongo database but when i login again i get the same token generated.