Skip to content

Commit c679a9f

Browse files
authored
Fixed token expiry bug with cache (#2025)
1 parent 8538cb1 commit c679a9f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -408,16 +408,10 @@ static SqlFedAuthToken getMSIAuthToken(String resource, String msiClientId) thro
408408

409409
int startIndex_ATX;
410410

411-
// Fetch expires_on
412-
if (isAzureFunction) {
413-
startIndex_ATX = result
414-
.indexOf(ActiveDirectoryAuthentication.ACCESS_TOKEN_EXPIRES_ON_IDENTIFIER)
415-
+ ActiveDirectoryAuthentication.ACCESS_TOKEN_EXPIRES_ON_IDENTIFIER.length();
416-
} else {
417-
startIndex_ATX = result
418-
.indexOf(ActiveDirectoryAuthentication.ACCESS_TOKEN_EXPIRES_IN_IDENTIFIER)
419-
+ ActiveDirectoryAuthentication.ACCESS_TOKEN_EXPIRES_IN_IDENTIFIER.length();
420-
}
411+
// Fetch expires_in (this is in seconds)
412+
startIndex_ATX = result
413+
.indexOf(ActiveDirectoryAuthentication.ACCESS_TOKEN_EXPIRES_IN_IDENTIFIER)
414+
+ ActiveDirectoryAuthentication.ACCESS_TOKEN_EXPIRES_IN_IDENTIFIER.length();
421415

422416
String accessTokenExpiry = result.substring(startIndex_ATX,
423417
result.indexOf("\"", startIndex_ATX + 1));

0 commit comments

Comments
 (0)