🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

ember-simple-auth-devise-token-auth

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-simple-auth-devise-token-auth

Authenticator and Ember Data adapter mixin for integrating Ember Simple Auth with Devise Token Auth

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Ember Simple Auth Devise Token Auth

Authenticator and Ember Data adapter mixin for integrating Ember Simple Auth with Devise Token Auth.

"Ember auth couldn’t be any easier!"                                -You, probably.

Compatibility

  • Ember.js v2.18 or above
  • Ember CLI v2.13 or above

Installation

ember install ember-simple-auth-devise-token-auth

Usage

If you’re not already familiar with setting up Ember Simple Auth, it’s recommended that you take a moment to brush up on it since that library is what does all the heavy lifting. Luckily, it’s amazing and setting up is indeed quite simple.

Now, this is going to be super easy and boils down to two quick steps:

  • Extending the DeviseTokenAuthAuthenticator in your own app/authenticators/my-arbitrarily-named-authenticator.js
  • Mixing the DataAdapterMixin into your Ember Data adapter.

Note: Since authorizers are deprecated in Ember Simple Auth, ember-simple-auth-devise-token-auth does not provide any authorizers. (This is not to be confused with authenticators). The authorization takes place via the Ember Data adapter mixin.

Basic Example

ember-simple-auth-devise-token-auth ships with sensible defaults and should be ready to use out of the box.

// app/authenticators/devise-token-auth.js

import DeviseTokenAuthAuthenticator from 'ember-simple-auth-devise-token-auth/authenticators/devise-token-auth';

export default DeviseTokenAuthAuthenticator.extend({
});
// app/adapters/application.js

import DS from 'ember-data';
import DataAdapterMixin from 'ember-simple-auth-devise-token-auth/mixins/data-adapter-mixin';

export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
});

Custom Example

ember-simple-auth-devise-token-auth allow you to customize your setup to give you flexibility.

The configurable values for the authenticator and their corresponding defaults are shown below. These default values match up with the defaults provided by Devise Token Auth:

  • authHost: /auth
  • identificationAttributeName: email
  • serverTokenEndpoint: /sign_in
  • invalidateEndpoint: /sign_out
  • validateTokenEndpoint: /validate_token

For example, let’s say the host of your JSON API isn’t the same as the host of your Ember SPA. Further, let’s say you’ve customized the Devise Token Auth endpoints in your Rails app and have decided to have your users sign in using a username instead of an email.

Your authenticator may look something like this then:

// app/authenticators/devise-token-auth.js

import DeviseTokenAuthAuthenticator from 'ember-simple-auth-devise-token-auth/authenticators/devise-token-auth';

export default DeviseTokenAuthAuthenticator.extend({
  authHost: 'http://localhost:3000/auth',
  serverTokenEndpoint: '/login',
  invalidateEndpoint: '/logout',
  validateTokenEndpoint: '/validate-token',
  identificationAttributeName: 'username',
});

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

ember-addon

FAQs

Package last updated on 09 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts