Skip to content

Commit 66affad

Browse files
committed
Protect Against Any Token Parsing Failure
Previously, we only protected against the possibility that a parsed token wasn't really a JWT token at all. This lead us into the situation where debug logging a token that was invalid (e.g. had already expired) would crash the entire system. Since logging (especially debug logging), should never be terminal this change updates the code to protect against all parsing failures and simply truncate logging instead of crashing the system. [#569]
1 parent 3e4cad0 commit 66affad

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/tokenprovider/AbstractUaaTokenProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import io.jsonwebtoken.Claims;
2020
import io.jsonwebtoken.Jwts;
21-
import io.jsonwebtoken.UnsupportedJwtException;
2221
import io.netty.util.AsciiString;
2322
import org.cloudfoundry.reactor.ConnectionContext;
2423
import org.cloudfoundry.reactor.TokenProvider;
@@ -145,7 +144,7 @@ private static Optional<Claims> parseToken(String token) {
145144
try {
146145
String jws = token.substring(0, token.lastIndexOf('.') + 1);
147146
return Optional.of(Jwts.parser().parseClaimsJwt(jws).getBody());
148-
} catch (UnsupportedJwtException e) {
147+
} catch (Exception e) {
149148
return Optional.empty();
150149
}
151150
}

0 commit comments

Comments
 (0)