Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failover to accessToken for OAuth2 with refresh token #14949

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public TokenPair deserialize(String token)
claims.get(REFRESH_TOKEN_KEY, String.class));
}
catch (ParseException ex) {
throw new IllegalArgumentException("Malformed jwt token", ex);
return TokenPair.accessToken(token);
}
catch (JOSEException ex) {
throw new IllegalArgumentException("Decryption failed", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ public void testTokenDeserializationAfterTimeoutAndExpirationExtension()
.isExactlyInstanceOf(ExpiredJwtException.class);
}

@Test
public void testTokenDeserializationWhenNonJWETokenIsPassed()
throws Exception
{
JweTokenSerializer serializer = tokenSerializer(new TestingClock(), succinctDuration(12, MINUTES));
String nonJWEToken = "non_jwe_token";

TokenPair tokenPair = serializer.deserialize(nonJWEToken);

assertThat(tokenPair.getAccessToken()).isEqualTo(nonJWEToken);
assertThat(tokenPair.getRefreshToken()).isEmpty();
}

private JweTokenSerializer tokenSerializer(Clock clock, Duration tokenExpiration)
throws GeneralSecurityException, KeyLengthException
{
Expand Down