Last Updated: February 25, 2016
·
2.057K
· 534n

Meteor RESTful authentication

I am working on a project that involves Meteor and Joomla (Yes... Joomla! I know, I know... )... basically, we need to be able to provide the single sign-on functionality, it sounds like an easy solution: REST.

It is indeed a simple concept, but it turned out a bit tricky when it comes down to implementation. Here is a high level concept:

  • I had to customize the default Meteor authentication. There are a increasing number of people trying to do this, but I found this one the neatest customization.

  • I had to enable the RESTful interface to expose a collection. This one is a brilliant piece of work that crazytoad, called Collection API, which you can add to your project by mrt add collection-api.

  • Now the tricky part: the collection API can only expose a certain collection, it can still NOT trigger any client side action, such as triggering Accounts.callLoginMethod.

  • The trick: the beauty of Meteor, Deps.autorun helps to monitor a collection for updates, so whenever there is a change to the collection, a series of actions can be triggered, done!

You can find the code here