You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/05/14 06:42:37 UTC
[james-project] 05/15: [REFACTORING] Wrap blocking calls in
JWTAuthenticationStrategy
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 <bt...@linagora.com>
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: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org