I recently started making an app in Emberjs. It is my first app and I am much impressed with how easy Ember makes making front-end apps.
However, things were going fine until I had to implement authentication in my app (using 2.0 btw). Prior to this, I only have experience working with Rails and I am not clear with how to go about with authentication here. I will be using Rails as a backend for the same. Also, the content on the web has only managed to overwhelm me And even though, I have been successful in making something to work out, things only look magic to me!
Firstly, does the authentication occur only on the front-end with it? Like I said, I intend to have a Rails backend to my app and was wondering about this, since I only intend to provide authentication via Facebook and Google (both OAuth 2.0) right now.
In case, it is possible, I won’t be able to refer/map the logged in user with a ‘Person’ in the backend, right?
What about torii - [link] (https://github.com/Vestorly/torii)? Is it necessary to use it with ember-simple-auth? What advantage does it provide in case I use it?
Also, I once came across a post which briefly described the working of the ember-simple-auth library, I mean not the integration code but can’t find it back. Please post it here, in case you get hold of it.
I can’t help with the Rails specific part but perhaps this will help: think of your Ember app as a native or desktop application. Get rid of the idea that it is somehow related to your server application. Once I started to view my Ember apps like that everything made a lot more sense.
I, usually, have authenticated my apps with token auth. In short: at sign in your user sends their username and password over the wire to Rails and if they are correct Rails returns a token. Store that token in localStorage or sessionStorage (I use this storage adapter) and for every request after that send it in a Authorization: Token the-token header (or whatever name Rails expects) via your adapter’s headers hook.
simple auth is about quick drop-in and ease of use and torii is for adding structure to your social auth flows (I think, I’ve studied it but haven’t used it).
The go-to solution for authentication in an Ember app is ember-simple-auth.
Unless you are in a very specific use case, it has you covered, or a plugin will.
Talking about plugins, as you’re using Rails, there’s a plugin included in ESA specifically for Devise called ember-simple-auth-devise.
Sooo, unless you’re not using Devise and/or are in a very specific use case, I suggest you give it a try.
Another option is torii. I have an example proj using this at crambear, which has a rails backend using devise and token auth. I have another proj using ember-simple-auth, also with a Rails backend here, but is a little out of date.