Let's say we have an admin that wants to invalidate all user tokens (effectively logging the user out everywhere), but without blocking his account. The user should still be able to log in normally.
Example:
clientIds.forEach(clientId -> {
Collection<OAuth2AccessToken> accessTokens = tokenStore.findTokensByClientIdAndUserName(clientId, username);
accessTokens.forEach(accessToken -> tokenServices.revokeToken(accessToken.getValue()));
});
This works fine ONLY IF access tokens are still valid (not expired), because access tokens are found and based on them, revokeToken
invalidates both access and refresh tokens. However, if access token is expired, findTokensByClientIdAndUserName
does not find anything, thus nothing is invalidated and refresh token is still valid and ready to be used.
I've looked everywhere, and it looks like everyone revokes refresh tokens either by using access token or by passing refresh token value as request parameter.
Is it possible to find refresh token without using access token?