File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
openid-connect-server/src/main/java/org/mitre/oauth2/service/impl Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -335,15 +335,13 @@ public OAuth2Authentication loadAuthentication(String accessTokenValue) throws A
335
335
336
336
if (accessToken == null ) {
337
337
throw new InvalidTokenException ("Invalid access token: " + accessTokenValue );
338
- }
339
-
340
- if (accessToken .isExpired ()) {
338
+ } else if (accessToken .isExpired ()) {
341
339
//tokenRepository.removeAccessToken(accessToken);
342
340
revokeAccessToken (accessToken );
343
341
throw new InvalidTokenException ("Expired access token: " + accessTokenValue );
342
+ } else {
343
+ return accessToken .getAuthenticationHolder ().getAuthentication ();
344
344
}
345
-
346
- return accessToken .getAuthenticationHolder ().getAuthentication ();
347
345
}
348
346
349
347
@@ -355,8 +353,11 @@ public OAuth2AccessTokenEntity readAccessToken(String accessTokenValue) throws A
355
353
OAuth2AccessTokenEntity accessToken = tokenRepository .getAccessTokenByValue (accessTokenValue );
356
354
if (accessToken == null ) {
357
355
throw new InvalidTokenException ("Access token for value " + accessTokenValue + " was not found" );
358
- }
359
- else {
356
+ } else if (accessToken .isExpired ()) {
357
+ // immediately revoke the expired token
358
+ revokeAccessToken (accessToken );
359
+ throw new InvalidTokenException ("Access token for value " + accessTokenValue + " is expired" );
360
+ } else {
360
361
return accessToken ;
361
362
}
362
363
}
You can’t perform that action at this time.
0 commit comments