KEYCLOAK-9825: keep existing refresh token on token exchange requiring refresh if new one not provided in response
This commit is contained in:
parent
2aeda71e16
commit
1bf19ada7e
1 changed files with 7 additions and 1 deletions
|
@ -248,8 +248,14 @@ public class OIDCIdentityProvider extends AbstractOAuth2IdentityProvider<OIDCIde
|
||||||
if (newResponse.getExpiresIn() > 0) {
|
if (newResponse.getExpiresIn() > 0) {
|
||||||
int accessTokenExpiration = Time.currentTime() + (int) newResponse.getExpiresIn();
|
int accessTokenExpiration = Time.currentTime() + (int) newResponse.getExpiresIn();
|
||||||
newResponse.getOtherClaims().put(ACCESS_TOKEN_EXPIRATION, accessTokenExpiration);
|
newResponse.getOtherClaims().put(ACCESS_TOKEN_EXPIRATION, accessTokenExpiration);
|
||||||
response = JsonSerialization.writeValueAsString(newResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newResponse.getRefreshToken() == null && tokenResponse.getRefreshToken() != null) {
|
||||||
|
newResponse.setRefreshToken(tokenResponse.getRefreshToken());
|
||||||
|
newResponse.setRefreshExpiresIn(tokenResponse.getRefreshExpiresIn());
|
||||||
|
}
|
||||||
|
response = JsonSerialization.writeValueAsString(newResponse);
|
||||||
|
|
||||||
String oldToken = tokenUserSession.getNote(FEDERATED_ACCESS_TOKEN);
|
String oldToken = tokenUserSession.getNote(FEDERATED_ACCESS_TOKEN);
|
||||||
if (oldToken != null && oldToken.equals(tokenResponse.getToken())) {
|
if (oldToken != null && oldToken.equals(tokenResponse.getToken())) {
|
||||||
int accessTokenExpiration = newResponse.getExpiresIn() > 0 ? Time.currentTime() + (int) newResponse.getExpiresIn() : 0;
|
int accessTokenExpiration = newResponse.getExpiresIn() > 0 ? Time.currentTime() + (int) newResponse.getExpiresIn() : 0;
|
||||||
|
|
Loading…
Reference in a new issue