Is it possible use SecurityContext in App integrated Spring Security and Netty-socketio

53 views Asked by At

I want to integrate Spring Web + Spring Security and Netty-Socket.io.

But In my app, they are diffrent port and WAS(WEB use tomcat(port: 8080), Netty-Socket.io use netty(port: 8070))

But I want to use Security Context In my Netty Handler

Is it possible?

server.port=8080
socket.host=0.0.0.0
socket.port=8070
@Slf4j
@Component
public class SocketIOHandler {

    public SocketIOHandler(SocketIOServer socketIOServer) {
        socketIOServer.addEventListener("test", String.class, handleTest());
    }

    private DataListener<String> handleTest() {
        return (client, data, ackSender) -> {
            Authentication authentication = SecurityContextHolder.getContext()
                .getAuthentication();
            log.info("authentication: {}", authentication); // TODO: current is null
        };
    }
}
0

There are 0 answers