check access token expiration on read. closes #983

pull/990/head
Justin Richer 2015-12-16 22:46:42 -05:00
parent e1800b5fd6
commit 698feb49cd
1 changed files with 8 additions and 7 deletions

View File

@ -335,15 +335,13 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
if (accessToken == null) {
throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
}
if (accessToken.isExpired()) {
} else if (accessToken.isExpired()) {
//tokenRepository.removeAccessToken(accessToken);
revokeAccessToken(accessToken);
throw new InvalidTokenException("Expired access token: " + accessTokenValue);
} else {
return accessToken.getAuthenticationHolder().getAuthentication();
}
return accessToken.getAuthenticationHolder().getAuthentication();
}
@ -355,8 +353,11 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
OAuth2AccessTokenEntity accessToken = tokenRepository.getAccessTokenByValue(accessTokenValue);
if (accessToken == null) {
throw new InvalidTokenException("Access token for value " + accessTokenValue + " was not found");
}
else {
} else if (accessToken.isExpired()) {
// immediately revoke the expired token
revokeAccessToken(accessToken);
throw new InvalidTokenException("Access token for value " + accessTokenValue + " is expired");
} else {
return accessToken;
}
}