Tutorial: Develop Apps with Secure WebSockets in Java

Tutorial: Develop Apps with Secure WebSockets in Java

This tutorial shows you how to develop an application with Spring Boot and WebSockets, then secure them with Okta.

rocky ricky

Can you provide any sample example for the plain websocket connection authentication with JWT without STOMP.

Matt Raible

I’m sorry, I don’t have any examples. The Spring Security Docs has a section on SockJS that might be helpful.

Олег Павлюков

Where maven dependencies?
Which one I need?
<dependency>
<groupid>org.springframework.security</groupid>
<artifactid>spring-security-oauth2-jose</artifactid>
<version>5.3.2.RELEASE</version>
</dependency>

<dependency>
<groupid>org.springframework.security</groupid>
<artifactid>spring-security-oauth2-client</artifactid>
<version>5.3.2.RELEASE</version>
</dependency>
<dependency>
<groupid>org.springframework.security</groupid>
<artifactid>spring-security-oauth2-resource-server</artifactid>
<version>5.2.0.RELEASE</version>

John Million

Thanks for this article, it saved my day as I could only find separate code snippets for this use case.
In my case, I had to disable CORS checking in WebSecurityConfigurerAdapter as my JS server and my Spring Websocket server are not on the same port:
http.csrf().disable().cors().disable();

Rafael Castilla

this post is brilliant, but i would like to know how to show all user connected to queue ?

Matt Raible

I’m sorry, but I’m not sure how to do that.

Christian Goudreau

Uhm, I can decode the token, but my request are still being unauthorized…

Matt Raible

Hello Christian,

Can you compare your code to the this post’s example on GitHub. Everything should work if you’re using the same versions.

Marco Berri

Hi,
Good Article!

just a question, is possible configure mutual authentication wss/ssl/https from client spring boot and server spring boot?
I have a big problem…

https://stackoverflow.com/q…