vttranlina commented on code in PR #2450:
URL: https://github.com/apache/james-project/pull/2450#discussion_r1799111790


##########
server/protocols/jmap/src/main/java/org/apache/james/jmap/http/XUserAuthenticationStrategy.java:
##########
@@ -69,4 +100,18 @@ private Mono<MailboxSession> createMailboxSession(Username 
username) {
     public AuthenticationChallenge correspondingChallenge() {
         return X_USER_CHALLENGE;
     }
+
+    private Function<HttpServerRequest, Optional<Username>> 
createUsernameExtractorWithoutSecretValidation() {
+        return httpRequest -> 
Optional.ofNullable(httpRequest.requestHeaders().get(X_USER_HEADER_NAME))
+            .map(String::trim)
+            .filter(s -> !s.isEmpty())
+            .map(Username::of);
+    }
+
+    private Function<HttpServerRequest, Optional<Username>> 
createUsernameExtractorWithSecretValidation(String secret) {
+        return httpRequest -> 
createUsernameExtractorWithoutSecretValidation().apply(httpRequest)
+            .filter(username -> 
Optional.ofNullable(httpRequest.requestHeaders().get(X_USER_SECRET_HEADER_NAME))
+                .map(secret::equals)
+                .orElse(false));
+    }

Review Comment:
   With this code
   we don't need one more class `XUserWithSecretAuthenticationStrategy` (it 
will quiet verbose while it is simple logic)
   This code still don't any breaking changes. 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to