Using Phoenix as a chat service

I have a PHP app and I would like to add a chat to it through Phoenix, It will be rooms based chat.
The Phoenix app will have the messages and rooms tables. My problem is mostly with security. The PHP app has the User’s table so I can run an if statement and allow socket connection to logged in users only, but is there something I can do on the Phoenix side? It’s very confusing since the User’s table is in a different Database. I can’t think of what I can do. It seems that adding a micro service comes with serious security issues.
I would like to block connections that are coming not from the PHP app and I would like to disconnect User’s if needed. I assume I can do the disconnect from the PHP part and just send a disconnect event.
Any advice would be helpful.

1 Like

I’m not sure I understood, and my solution is not based on deep Phoenix knowledge.
But, maybe you can expose some endpoint in your PHP app that your Phoenix app will use for user approval.
Create some sort of “authentication micro service” that your Phoenix will use.
It will put some more load on the PHP side, but it feels to me that login is less significant - performance wise.


Thanks. I will think more on that. I basically want to create a mini service for myself only.

1 Like

If you want to pass data securely from the php part to the phoenix part without them communicating directly then this is exactly the purview of JWT (JSON Web Tokens), such as what the Guardian Phoenix library supports.