You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "CCH0124 (via GitHub)" <gi...@apache.org> on 2023/07/20 03:37:24 UTC

[GitHub] [camel-quarkus] CCH0124 opened a new issue, #5107: Camel Paho 5 integrates EMQX JWKS

CCH0124 opened a new issue, #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107

   ### Bug description
   
   My routed defined below
   
   ```java
   @Override
       public void configure() throws UnknownHostException {
   
           final PahoMqtt5EndpointBuilderFactory.PahoMqtt5EndpointBuilder endpoint = pahoMqtt5("test/1/2")
                   .brokerUrl(brokerUrl)
                   .sslClientProps(properties)
                   .clientId(InetAddress.getLocalHost().getHostName())
                   .userName("123456");
   
           log.infof("endpoint: %s", endpoint.getRawUri());
   
           from(direct("sendMqtt"))
                   .marshal().json(JsonLibrary.Jsonb)
                   .log("${body}")
                   .to(endpoint);
       }
   ```
   I defined `userName` 123456, but the EMQX server message shows username as undefined.
   
   EMQX Server message:
   
   ```bash
   ...
   2023-07-20T10:59:40.420785+08:00 [debug] msg: mqtt_packet_received, mfa: emqx_channel:handle_in/2, line: 338, peername: 172.10.0.2:40048, clientid: camel-paho-a2f84a1f-14a5-47f2-b4bd-c32a8354f012, packet: CONNECT(Q0, R0, D0, ClientId=camel-paho-a2f84a1f-14a5-47f2-b4bd-c32a8354f012, ProtoName=MQTT, ProtoVsn=5, CleanStart=true, KeepAlive=60, Username=undefined, Password=), tag: MQTT
   ...
   ```
   
   The EMQX authentication field is defined as `username`.
   
   It caused paho5 to have an authentication failure message.
   ```
   Caused by: org.apache.camel.RuntimeCamelException: Not authorized. (135)
   ```
   


-- 
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: commits-unsubscribe@camel.apache.org.apache.org

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


[GitHub] [camel-quarkus] CCH0124 commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "CCH0124 (via GitHub)" <gi...@apache.org>.
CCH0124 commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1644851699

   Thanks for your help.  👍 


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] CCH0124 commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "CCH0124 (via GitHub)" <gi...@apache.org>.
CCH0124 commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643520999

   I have tried to set password, but result is same.
   ```java
    final PahoMqtt5EndpointBuilderFactory.PahoMqtt5EndpointBuilder endpoint = pahoMqtt5("test/1/2")
                   .brokerUrl(brokerUrl)
                   .sslClientProps(properties)
                   .clientId(InetAddress.getLocalHost().getHostName())
                   .userName("123456").password("");
   ```
   
   I have tried MqttClient functions and it was successful.
   
   ```java
   public MqttClient mqttClient() throws UnknownHostException {
           MqttClient mqttClient;
           try {
               mqttClient = new MqttClient(this.brokerUrl, InetAddress.getLocalHost().getHostName());
               final var mqttConnectionOptions = new MqttConnectionOptions();
               mqttConnectionOptions.setAutomaticReconnect(true);
               if (properties.size() > 0) {
                   mqttConnectionOptions.setSSLProperties(this.properties);
               }
               if (username.isPresent()) {
                   mqttConnectionOptions.setUserName(this.username.get());
               }
               mqttClient.connect(mqttConnectionOptions);
           } catch (MqttException e) {
               throw new RuntimeException(e);
           }
   
           return mqttClient;
       }
   ```
   
   Camel Route
   
   ```java
   from(direct("sendMqtt"))
                   .marshal().json(JsonLibrary.Jsonb)
                   .log(LoggingLevel.INFO, "Camel Paho Publisher Topic: ${headers.CamelPahoMqtt5OverrideTopic}")
                   .to(pahoMqtt5("test/1")
                           .advanced()
                           .client(this.mqttClient()));
   ```


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton closed issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton closed issue #5107: Camel Paho 5 integrates EMQX JWKS
URL: https://github.com/apache/camel-quarkus/issues/5107


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643350552

   Looking at the component code, seems you must also provide a password for the authentication bits to get set correctly:
   
   https://github.com/apache/camel/blob/main/components/camel-paho-mqtt5/src/main/java/org/apache/camel/component/paho/mqtt5/PahoMqtt5Endpoint.java#L88


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] CCH0124 commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "CCH0124 (via GitHub)" <gi...@apache.org>.
CCH0124 commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643546091

   > > I have tried to set password
   > 
   > The problem is that it's empty. You need to pass a valid value.
   The EMQX JWKS token verification source is to choose one from username and password. 
   
   ```bash
   # EMQX jwks setting
   authn-jwt:jwks.from
   
   Type: enum
   
   Default: password
   
   Optional: username | password
   
   Field to take JWT from.
   ```


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] CCH0124 commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "CCH0124 (via GitHub)" <gi...@apache.org>.
CCH0124 commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643578370

   > One way to work around it could be to pass your own client instance to the component:
   > 
   > https://camel.apache.org/components/3.20.x/paho-mqtt5-component.html#_component_option_client
   > 
   > That way you're in charge of the authentication setup.
   
   The component_option_client can work for me.
   
   Can be enhance [username](
   https://camel.apache.org/components/3.20.x/paho-mqtt5-component.html#_endpoint_query_option_userName) description or support single option for authentication in the future ?
   
   
   Thanks.


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1657087177

   Fixed in https://github.com/apache/camel-quarkus/pull/5119.


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643586811

   > Can be enhance [username](https://camel.apache.org/components/3.20.x/paho-mqtt5-component.html#_endpoint_query_option_userName) description or support single option for authentication in the future ?
   
   https://issues.apache.org/jira/browse/CAMEL-19627


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643524583

   > I have tried to set password
   
   The problem is that it's empty.


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643300768

   Are you running in native mode or in the standard JVM mode?


-- 
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: commits-unsubscribe@camel.apache.org

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


[GitHub] [camel-quarkus] jamesnetherton commented on issue #5107: Camel Paho 5 integrates EMQX JWKS

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on issue #5107:
URL: https://github.com/apache/camel-quarkus/issues/5107#issuecomment-1643557426

   One way to work around it could be to pass your own client instance to the component:
   
   https://camel.apache.org/components/3.20.x/paho-mqtt5-component.html#_component_option_client
   
   That way you're in charge of the authentication setup.


-- 
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: commits-unsubscribe@camel.apache.org

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