vert-x3 / vertx-mqtt

Vert.x MQTT
Apache License 2.0
184 stars 86 forks source link

Provide methods in MqttEndpoint to access underlying http request #208

Closed injecteer closed 2 years ago

injecteer commented 2 years ago

Sometimes pre-checks must be performed upon handshake, like:

MqttServer.create vertx endpointHandler{ MqttEndpoint endpoint ->
  if( endpoint.path() != '/mqtt1' ) endpoint.reject()
  if( endpoint.headers().Authentication.startsWith( 'Bearer ' ) && !checkJWT( endpoint.headers().Authentication ) ) endpoint.reject() 
} listen 8888

To prevent "DoS" attacks or check for authentication or other crtiterias beforehand and reject the connection immediately.

So, it should be possible to access underlying HttpServerRequest and it's methods.

vietj commented 2 years ago

there is no underlying Vert.x HTTP server request in the current WebSocket transport, but we can still expose the HTTP headers and the HTTP request URI as provided during the handshake

injecteer commented 2 years ago

@vietj can you also backport the fix to 3.9.x version?