You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/11/30 01:50:36 UTC

[GitHub] [james-project] chibenwa commented on a diff in pull request #1340: James 3755 OIDC check token by user info

chibenwa commented on code in PR #1340:
URL: https://github.com/apache/james-project/pull/1340#discussion_r1035451291


##########
server/protocols/jwt/src/main/java/org/apache/james/jwt/OidcJwtTokenVerifier.java:
##########
@@ -65,17 +63,19 @@ public static <T> Optional<T> getClaimWithoutSignatureVerification(String token,
         }
     }
 
-    public static Publisher<String> verifyWithMaybeIntrospection(String jwtToken, URL jwksURL, String claimName, Optional<IntrospectionEndpoint> introspectionEndpoint) {
+    public static Publisher<String> verifyWithIntrospection(String jwtToken, URL jwksURL, String claimName, IntrospectionEndpoint introspectionEndpoint) {
         return Mono.fromCallable(() -> verifySignatureAndExtractClaim(jwtToken, jwksURL, claimName))
             .flatMap(optional -> optional.map(Mono::just).orElseGet(Mono::empty))
-            .flatMap(claimResult -> {
-                if (introspectionEndpoint.isEmpty()) {
-                    return Mono.just(claimResult);
-                }
-                return Mono.justOrEmpty(introspectionEndpoint)
-                    .flatMap(endpoint -> Mono.from(INTROSPECTION_CLIENT.introspect(endpoint, jwtToken)))
-                    .filter(TokenIntrospectionResponse::active)
-                    .map(activeToken -> claimResult);
-            });
+            .flatMap(claimResult -> Mono.from(CHECK_TOKEN_CLIENT.introspect(introspectionEndpoint, jwtToken))
+                .filter(TokenIntrospectionResponse::active)
+                .map(activeResponse -> claimResult));
+    }
+
+    public static Publisher<String> verifyWithUserinfo(String jwtToken, URL jwksURL, String claimName, URL userinfoEndpoint) {
+        return Mono.fromCallable(() -> verifySignatureAndExtractClaim(jwtToken, jwksURL, claimName))
+            .flatMap(optional -> optional.map(Mono::just).orElseGet(Mono::empty))
+            .flatMap(claimResult -> Mono.from(CHECK_TOKEN_CLIENT.useInfo(userinfoEndpoint, jwtToken))
+                // .filter(userinfoResponse -> userinfoResponse.getPreferredUsername().equals(claimResult))

Review Comment:
   Why not use `imapservers.imapserver.auth.oidc.claim` ?



-- 
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-unsubscribe@james.apache.org

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


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