Remove expiresAt constructor-arg in OAuth2RefreshToken

Fixes gh-5854
This commit is contained in:
Joe Grandja
2018-09-19 09:47:00 -04:00
parent ece5de3f99
commit 2c078c5dd9
5 changed files with 13 additions and 25 deletions

View File

@@ -38,9 +38,8 @@ public class OAuth2RefreshToken extends AbstractOAuth2Token {
*
* @param tokenValue the token value
* @param issuedAt the time at which the token was issued
* @param expiresAt the expiration time on or after which the token MUST NOT be accepted
*/
public OAuth2RefreshToken(String tokenValue, Instant issuedAt, Instant expiresAt) {
super(tokenValue, issuedAt, expiresAt);
public OAuth2RefreshToken(String tokenValue, Instant issuedAt) {
super(tokenValue, issuedAt, null);
}
}

View File

@@ -189,12 +189,7 @@ public final class OAuth2AccessTokenResponse {
accessTokenResponse.accessToken = new OAuth2AccessToken(
this.tokenType, this.tokenValue, issuedAt, expiresAt, this.scopes);
if (StringUtils.hasText(this.refreshToken)) {
// The Access Token response does not return an expires_in for the Refresh Token,
// therefore, we'll default to +1 second from issuedAt time.
// NOTE:
// The expiry or invalidity of a Refresh Token can only be determined by performing
// the refresh_token grant and if it fails than likely it has expired or has been invalidated.
accessTokenResponse.refreshToken = new OAuth2RefreshToken(this.refreshToken, issuedAt, issuedAt.plusSeconds(1));
accessTokenResponse.refreshToken = new OAuth2RefreshToken(this.refreshToken, issuedAt);
}
accessTokenResponse.additionalParameters = Collections.unmodifiableMap(
CollectionUtils.isEmpty(this.additionalParameters) ? Collections.emptyMap() : this.additionalParameters);

View File

@@ -16,7 +16,6 @@
package org.springframework.security.oauth2.core;
import java.time.Duration;
import java.time.Instant;
/**
@@ -25,7 +24,6 @@ import java.time.Instant;
*/
public class TestOAuth2RefreshTokens {
public static OAuth2RefreshToken refreshToken() {
return new OAuth2RefreshToken("refresh-token", Instant.now(),
Instant.now().plus(Duration.ofDays(1)));
return new OAuth2RefreshToken("refresh-token", Instant.now());
}
}