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

Explain why quarkus-smallrye-jwt may need to run in blocking mode #34575

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

sberyozkin
Copy link
Member

JWT doc updates (sub section about the blocking calls, new properties, minor fixes), follow up to #34564

@sberyozkin
Copy link
Member Author

Thanks @gastaldi @geoand


In such cases, if the connections are slow, for example, it may take more than 3 seconds to get a response from the key endpoint, the current event loop thread will most likely block.

To prevent it, set `quarkus.smallrye-jwt.blocking-authentication=true`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AdamBien FYI - it may not be necessary, please check. Quarkus is super fast either way, but smallrye-jwt-reactive is on the map, just not sure yet when it will happen, but it will eventually

Copy link
Contributor

@AdamBien AdamBien Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the key retrieval / resolution could be too slow / cause the timeout:

(vertx-blocked-thread-checker) Thread Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 2557 ms, time limit is 2000 ms: io.vertx.core.VertxException: Thread blocked
	at [email protected]/java.lang.Thread.sleep(Native Method)
	at org.jose4j.http.Get.get(Get.java:111)
	at io.smallrye.jwt.auth.principal.AwsAlbKeyResolver.retrieveKey(AwsAlbKeyResolver.java:62)
	at io.smallrye.jwt.auth.principal.AwsAlbKeyResolver.resolveKey(AwsAlbKeyResolver.java:49)
	at org.jose4j.jwt.consumer.JwtConsumer.processContext(JwtConsumer.java:213)
	at org.jose4j.jwt.consumer.JwtConsumer.process(JwtConsumer.java:426)
	at io.smallrye.jwt.auth.principal.DefaultJWTTokenParser.parseClaims(DefaultJWTTokenParser.java:157)
	at io.smallrye.jwt.auth.principal.DefaultJWTTokenParser.parse(DefaultJWTTokenParser.java:60)
	at io.smallrye.jwt.auth.principal.DefaultJWTCallerPrincipalFactory.parse(DefaultJWTCallerPrincipalFactory.java:31)
	at io.smallrye.jwt.auth.principal.DefaultJWTParser.parse(DefaultJWTParser.java:71)
	at io.smallrye.jwt.auth.principal.DefaultJWTParser_ClientProxy.parse(Unknown Source)
	at io.quarkus.smallrye.jwt.runtime.auth.MpJwtValidator.createSecurityIdentity(MpJwtValidator.java:76)

The configuration:

quarkus.smallrye-jwt.blocking-authentication=true

solved the problem.

@sberyozkin sberyozkin merged commit 6fde192 into quarkusio:main Jul 6, 2023
@sberyozkin sberyozkin deleted the jwt_doc_updates branch July 6, 2023 13:33
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 6, 2023
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

🙈 The PR is closed and the preview is expired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants