March 2020
Intermediate to advanced
328 pages
7h 58m
English
Clients that connect to our secured Socket must be able to pass the authentication parameters on connection. Phoenix’s JavaScript client provides a simple way to add the right authentication parameters.
We wrote an AuthSocket that accepts a "token" parameter and verifies it using a known secret. We’ll complete the client side of this flow by including the token with the socket connection. This task boils down to a few key parts:
Controller—generate a token when our page loads and write it into the page’s JavaScript
JavaScript—send the token parameter with the Socket connection
Socket—use the token in our Socket
We’ll generate an authentication token in the Controller that renders our page view. We’ve worked ...
Read now
Unlock full access