I am developing an application containing both Python backend and frontend using Electron. There is no authentication. The two components communicate through WebSocket. How should I prevent the third party from connecting to the port?
You need to be able to distinguish between the trusted client and the untrusted third party in order to block the third party. This means that you somehow need to find out when the trusted client connected and when the connection does not come from the trusted client. This means you need some form of authentication but it does not need to be some setup with users and passwords or similar. How this authentication is done depends on your specific setup, i.e. it might simply be a specific IP associated with the correct client, it might be a token only the trusted client knows, it might be authentication based on a certificate (i.e. mutual authentication in