This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 72240aaaa2db19d1782154ba89389bb5243ad366 Author: Benoit Tellier <[email protected]> AuthorDate: Fri May 7 18:39:37 2021 +0700 [REFACTORING] Wrap blocking calls in JWTAuthenticationStrategy It was forcing to schedule the whole chain on an elastic scheduler... --- .../java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java index 4314c31..55352af 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/jwt/JWTAuthenticationStrategy.java @@ -36,6 +36,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import reactor.netty.http.server.HttpServerRequest; public class JWTAuthenticationStrategy implements AuthenticationStrategy { @@ -61,7 +62,7 @@ public class JWTAuthenticationStrategy implements AuthenticationStrategy { return Mono.fromCallable(() -> authHeaders(httpRequest)) .filter(header -> header.startsWith(AUTHORIZATION_HEADER_PREFIX)) .map(header -> header.substring(AUTHORIZATION_HEADER_PREFIX.length())) - .map(userJWTToken -> { + .flatMap(userJWTToken -> Mono.fromCallable(() -> { if (!tokenManager.verify(userJWTToken)) { throw new UnauthorizedException("Failed Jwt verification"); } @@ -74,7 +75,7 @@ public class JWTAuthenticationStrategy implements AuthenticationStrategy { } return username; - }) + }).subscribeOn(Schedulers.elastic())) .map(mailboxManager::createSystemSession); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
