gnodet-bot commented on code in PR #30151:
URL: https://github.com/apache/camel/pull/30151#discussion_r4583356673


##########
components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/authentication/JWTAuthenticationConfigurer.java:
##########
@@ -29,9 +38,17 @@
 import org.apache.camel.main.HttpManagementServerConfigurationProperties;
 import org.apache.camel.main.HttpServerConfigurationProperties;
 import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class JWTAuthenticationConfigurer implements 
MainAuthenticationConfigurer {
 
+    private static final Logger LOG = 
LoggerFactory.getLogger(JWTAuthenticationConfigurer.class);
+
+    // the aliases Vert.x looks up in a JWT keystore, one per algorithm 
(io.vertx.ext.auth.impl.jose.JWK#load)

Review Comment:
   💡 **Suggestion:** The comment references 
`io.vertx.ext.auth.impl.jose.JWK#load` by class name but doesn't pin a Vert.x 
version. If the set of recognised aliases ever changes in a Vert.x upgrade, 
this list could silently drift. Consider adding the Vert.x dependency version 
here (e.g. `// as of vertx-auth-jwt 4.5.x`) so future maintainers know which 
release to check against.



##########
components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/authentication/JWTAuthenticationConfigurer.java:
##########
@@ -112,6 +135,52 @@ public <T extends AuthenticationProvider> 
AuthenticationHandler createAuthentica
         authenticationConfig.setEnabled(true);
     }
 
+    /**
+     * Vert.x only uses the keys whose alias is the name of a JWT algorithm, 
such as RS256. A keystore without such an
+     * alias loads fine, but then every signed token fails, so warn at startup.
+     */
+    private static void warnIfNoJwtAlias(String type, String path, String 
password, String configPrefix) {
+        try (InputStream is = openKeystore(path)) {
+            if (is == null) {
+                // Vert.x reports a keystore it cannot read
+                return;
+            }
+            KeyStore keyStore = KeyStore.getInstance(type);
+            keyStore.load(is, password != null ? password.toCharArray() : 
null);
+            String warning = checkJwtKeystoreAliases(keyStore, configPrefix);

Review Comment:
   💡 **Suggestion:** `warnIfNoJwtAlias` has the resolved `path` value but only 
passes `configPrefix` to `checkJwtKeystoreAliases`. The resulting warning 
message therefore reads e.g.
   
   > The JWT keystore camel.server.jwtKeystorePath has no key…
   
   An operator looking at the log won't know *which file* to fix without going 
back to the config. Consider including the actual path in the warning, either 
by passing `path` into `checkJwtKeystoreAliases` or by appending it in 
`warnIfNoJwtAlias` before logging:
   
   ```suggestion
               String warning = checkJwtKeystoreAliases(keyStore, configPrefix, 
path);
   ```
   
   And update `checkJwtKeystoreAliases` to accept and embed `path` in the 
returned message.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to