Skip to content

Commit 0b1f900

Browse files
committed
check for missing refresh token value on refresh, closes mitreid-connect#1242
1 parent 705ac98 commit 0b1f900

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ProviderTokenService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.springframework.stereotype.Service;
6666
import org.springframework.transaction.annotation.Transactional;
6767

68+
import com.google.common.base.Strings;
6869
import com.google.common.collect.Sets;
6970
import com.nimbusds.jose.util.Base64URL;
7071
import com.nimbusds.jwt.JWTClaimsSet;
@@ -315,10 +316,16 @@ private OAuth2RefreshTokenEntity createRefreshToken(ClientDetailsEntity client,
315316
@Override
316317
@Transactional(value="defaultTransactionManager")
317318
public OAuth2AccessTokenEntity refreshAccessToken(String refreshTokenValue, TokenRequest authRequest) throws AuthenticationException {
319+
320+
if (Strings.isNullOrEmpty(refreshTokenValue)) {
321+
// throw an invalid token exception if there's no refresh token value at all
322+
throw new InvalidTokenException("Invalid refresh token: " + refreshTokenValue);
323+
}
318324

319325
OAuth2RefreshTokenEntity refreshToken = clearExpiredRefreshToken(tokenRepository.getRefreshTokenByValue(refreshTokenValue));
320326

321327
if (refreshToken == null) {
328+
// throw an invalid token exception if we couldn't find the token
322329
throw new InvalidTokenException("Invalid refresh token: " + refreshTokenValue);
323330
}
324331

0 commit comments

Comments
 (0)