Add Authentication to Sockets

You can use Socket authentication when you want to restrict a client’s access to a real-time connection. This is useful in situations where you don’t want certain clients to access your application. For example, you would add authentication code to a Socket when user login is required to access the application, because the default Socket does not know that your application requires login. When you add authentication checks at the very edge of your application, in the Socket, you’re able to avoid writing code that checks if there is a logged in user lower in the system. This improves your system’s maintainability because your user session check exists in a single location.

Phoenix calls a Socket module’s connect/3 ...

Get Real-Time Phoenix now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.