Skip to content

Use JWT with Jetty Websockets? #24

Description

@situokko

I have been using this module with good success with my REST resources, however now as I am implementing Websocket I'd like to use this same authentication there but don't know how to plug it in Changes are it might work as is.

(I tried multiple Websocket libraries but then decided to go with older org.eclipse.jetty.websocket.api classs as the JEE7-based ones were too complicated to use)

Application.run(conf, env)

env.getApplicationContext().addServlet(BroadcastServlet.class, "/ws/*")
public class BroadcastServlet extends WebSocketServlet {
    public void configure(WebSocketServletFactory factory) {
        factory.register(BroadcastSocket.class);
    }
}
public class BroadcastSocket extends WebSocketAdapter {
    public void onWebSocketConnect(Session session) {
        ...
    }
}

So question goes, should this work already just by plugging AuthFilter to that Servlet-mapping somehow or would it require some changes?

As it's a Servlet and not Jax-RS Resource, I assume that Dropwizard will not be searching for the @Auth annotation from inside the WebSocketServlet nor the WebSocketAdapter, so I bet it would require some hacking to get it working so that the @Auth objects would get injected into WebSocketAdapter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions