Monday 28 July 2014

XMPP chat

Prosody is a good XMPP chat server. It can be installed from the distro repository.

A guide: http://www.techytalk.info/install-configure-prosody-xmpp-jabber-server-on-debian-ubuntu-linux/

There are many desktop clients for XMPP. There are a few web clients too: https://conversejs.org/ and http://candy-chat.github.io/candy/

https://conversejs.org/docs/html/

However, for these web clients to connect to the XMPP server, they need to use HTTP, so the XMPP server needs a plugin to communicate using xmpp over http, called BOSH: http://xmpp.org/extensions/xep-0124.html

The BOSH plugin for Prosody is: http://prosody.im/doc/modules/mod_bosh

Once the bosh-bind plugin is installed, a redirect should be setup in the web server (Apache or Nginx). This is because, converse.js must connect to the XMPP server (through bosh) at port 5280. However, browsers prevent authentication to this port because of same-origin policies (to prevent XSS). Therefore, the javascript can be made to authenticate to a particular directory which redirects the request to the correct url and port.

http://prosody.im/doc/setting_up_bosh

For integrating prosody with Wordpress, there is a plugin:
https://github.com/llun/wordpress-authenticator

However, this plugin requires wordpress to store passwords as md5 hashes (using a plugin) instead of phpass. Md5 hashes are very insecure so wordpress-authenticator cannot be used.

There is another prosody plugin for wordpress authentication: https://code.google.com/p/prosody-modules/wiki/mod_auth_wordpress
However, the code is alpha and development seems to have halted.

To integrate converse.js with a site that already uses authentication, one needs to use PHP prebinding: http://www.techytalk.info/other-projects/xmpp-bosh-toolkit/
http://stackoverflow.com/questions/3696165/get-xmpp-sid-and-rid-from-bosh-in-php
http://stackoverflow.com/questions/23264662/java-trying-to-prebind-converse-js-using-bosh-but-not-able-to-get-the-sid-and

https://github.com/candy-chat/xmpp-prebind-php/

Prosody: creating accounts:  http://prosody.im/doc/creating_accounts





No comments:

Post a Comment