diff --git a/core/trino-main/src/main/java/io/trino/server/security/oauth2/JweTokenSerializer.java b/core/trino-main/src/main/java/io/trino/server/security/oauth2/JweTokenSerializer.java index 4a981e8256a1..68469303c613 100644 --- a/core/trino-main/src/main/java/io/trino/server/security/oauth2/JweTokenSerializer.java +++ b/core/trino-main/src/main/java/io/trino/server/security/oauth2/JweTokenSerializer.java @@ -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); diff --git a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestJweTokenSerializer.java b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestJweTokenSerializer.java index 6d3c18ab576e..489891b983ff 100644 --- a/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestJweTokenSerializer.java +++ b/core/trino-main/src/test/java/io/trino/server/security/oauth2/TestJweTokenSerializer.java @@ -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 {