powelli13 / dara-dots

Using Phaser 3 to implement a game idea I have.
MIT License
5 stars 2 forks source link

add tokens to secure channels #2

Closed powelli13 closed 3 years ago

powelli13 commented 4 years ago

Currently the existing games and player queues use the player defined name to identify the players. This should be replaced by a GUID that is generated on the server side. This player ID will always be in the context of the player queue or game and can be assigned to the persistent socket when the user connects. This can be updated in GameServerWeb.UserSocket module in the user_socket.ex file. I think that the same ID will persist on the socket struct for the duration of the connection, the same value across channels and across different pages. If that is not the case then we'll need a different approach.

powelli13 commented 3 years ago

All the token examples that I'm seeing are using a repo such as Ecto to validate users upon login, I don't know if tokens make sense when all users are essentially anonymous aside from their names.

powelli13 commented 3 years ago

I've started implementing this using get_session and put_session as a plug in pipeline to ensure that all the anonymous users have server assigned GUIDs to identify them while their on the site.

powelli13 commented 3 years ago

Tokens have been added to the socket to ensure that messages sent to game or lobby channels are from that sender. I followed the examples laid out in the Phoenix documentation to set up the tokens.