Registering users without authentication

In this chapter, we haven't yet picked up security. That will be covered in Chapter 9, Securing Your App with Spring Boot. For now, we need something to take its place.

As a workaround, we can introduce the concept of the user entering his or her own username and sending it with the HTTP-based request used to create the WebSocket.

To offer the user a place to enter their username, we can put this at the top of the Thymeleaf template:

    <input id="username" type="text" /> 
    <button id="connect">Connect</button> 
    <button id="disconnect" style="display: none">Disconnect</button> 

There is a both a Connect and a Disconnect button to analogously log in/log out of the WebSocket session.

Now we can wire it so ...

Get Learning Spring Boot 2.0 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.