Skip to content

Quarkus WebSockets Next does not respect @HttpAuthenticationMechanism #46013

@vmutafov

Description

@vmutafov

Describe the bug

Hi! Please, correct me if I'm wrong, but it seems Quarkus WebSockets Next doesn't handle @HttpAuthenticationMechanism when declared on the web socket class like:

@RolesAllowed("*")
@HttpAuthenticationMechanism(value = "some-custom-mechanism")
@WebSocket(path = "/test")
public class TestWebSocket {
  ...
}

As far as I understand how the @HttpAuthenticationMechanism annotation is handled in regular RestEasy endpoints, usages are recorded here and then the HttpAuthenticator should use the declared auth mechanism.

If there is no pre-selected auth mechanism, all registered auth mechanisms are iterated and requests are checked with every mechanism. In my opinion, this may lead to unexpected security problems if a websocket that should have used a dedicated auth mechanism, now may accept requests as long as they are authenticated by some other auth mechanism.

Expected behavior

The @HttpAuthenticationMechanism should either be supported or at least a build time exception should be thrown when it's declared on a websocket.

Actual behavior

The @HttpAuthenticationMechanism annotation is not handled.

How to Reproduce?

  1. Add a custom auth mechanism like in here
  2. Create a websocket and make it use the custom auth mechanism
  3. Configure some other auth mechanism - I used the Smallrye JWT auth config in my case
  4. Try to connect to the websocket with credentials that are not valid for the custom auth mechanism but valid for the other auth mechanism

Output of uname -a or ver

23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

Output of java -version

openjdk version "21" 2023-09-19 OpenJDK Runtime Environment (build 21+35-2513) OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)

Quarkus version or git rev

3.17.7

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)

Additional information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions