DEV Community

Robertino
Robertino

Posted on

πŸ€– Dependable and Secure Realtime in Spring Boot with Auth0 and Ably

πŸ“• Learn how to build a realtime chat application with Spring Boot, Auth0 and Ably.

When developing a service, one of the main hurdles to consider is authentication. For every action, you’ll need to both authorize the user (check they are who they say they are) and then ensure they can only do actions which they have permission to do.

Auth0, an authentication and authorization platform, simplifies this process immensely. Not only does it allow for easy integration with your own login systems, it makes integrating other login services such as Google and Twitter simple. It allows for a simple setup of permissions, roles with set permissions attached, and for these roles to be assigned to users. These users can then make use of various login systems to access the same account and thus have the same permissions associated with them.

With Spring Boot, this is extremely powerful, partially due to the strong integration of Auth0 with it. A simple redirect to an Auth0 login page will return a token which a Spring Boot server can use to verify the user and access their associated permissions.

This token can then be used to correctly generate access to other services. For example, Ably, a real-time communications solution, makes use of tokens to authenticate with an Ably App. Once a user has authenticated with Auth0 and has an Auth0 token, they can use this to request a token from a Spring Boot server to authenticate directly with Ably, with the appropriate permissions and access granted.

In this tutorial, we’ll be going through the basics of setting up an interoperating system as described above. The actual service we’ll be providing is a chat application, which will:

  • Allow users to sign in using a Google account
  • Signed in users will be able to publish messages to a group chat
  • Non-signed in users will be able to subscribe and read messages published
  • Users will be able to see who is online in the chat
  • Users will, when joining, be able to load the last 20 messages of conversation they’ve missed

Read more...

Top comments (0)