< mockra >

Ember Simple Auth - 19 Jan 2014

Adding authentication to your EmberJS application is pretty straight forward if you use one of the existing libraries out there. My favorite auth library is ember-simple-auth.

Implementing ember-simple-auth is quick and easy, and it provides a pretty robust auth implementation. The first step is adding an initializer for including ember-simple-auth in your ember application. You can do so with the following command:

You’ll also need to implement the route mixin provided by ember-simple-auth. You can add the top line of this gist to your router.js file to do so.

In order to allow a user to login to your application, you’ll need to create a login route. The following gists will show you how to setup your login route files.

Your back-end will also need to implement a POST /token API that returns an access_token, as well as optional expires_in and refresh_token keys.

Here’s an example implementation in Ruby on Rails, you will need to route POST /token to sessions#create: