npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cli-auth0-lock

v0.2.2

Published

Adds support for Auth0 lock widget to Ember applications.

Downloads

23

Readme

Build Status

Ember-cli-auth0-lock

This addon wraps the Auth0 Lock library and adds basic support for the Auth0 authentication service to an Ember CLI project. It requires an Auth0 account and application to be setup.

A simple Ember CLI example using this addon is available at: http://ember-cli-auth0-lock.divshot.io

Installation

npm install --save-dev ember-cli-auth0-lock
ember generate ember-cli-auth0-lock

The addon will add following elements to your CLI project:

  • the auth0-lock bower dependency
  • an initializer that will inject an auth0 property with user data and a wrapper around auth0-lock methods on controllers and routes
  • 3 actions to your application route: login, signup and logout
  • a mixin to protect routes with authentication:

Usage

Before you can use the addon, you need to add your Auth0 ClientID and Domain to the environment configuration in ./config/environment.js:

'ember-cli-auth0-lock': {

  // [required] Auth0 credentials
  cid: 'MyAuth0ClientId',
  domain: 'myaccount.auth0.com',

  // [required] redirect from Auth0 when a user logs out
  logoutUrl: 'http://mydomain.com/logout',

  // [optional] Auth0 Lock authentication options
  authParams: {
    scope: 'openid user_id email nickname picture'
  },

  // [optional] Auth0 Lock CDN url, used in production build
  cdnUrl: 'http://cdn.auth0.com/js/lock-6.min.js'

}

Please see the Auth0 docs for more information on the authParams configuration object.

Route mixin

Use the auth0-protection mixin to require an authentication on a route:

import Ember from 'ember';
import Auth0Protection from 'ember-cli-auth0-lock/mixins/auth0-protection';

export default Ember.Route.extend(Auth0Protection, {
  model: function() {
    return ['This', 'is', 'a', 'protected', 'route'];
  }
});

Note: current protection is naive in terms of that it just redirects the app to the root url if the current user is not authenticated.

Also: an authentication check on the client won't protect any sensible data that you might serve in your application.

Signup, login and logout actions

The application route will catch any signup, login and logout actions that bubble up and call the corresponding method on the Lock Widget.

E.g. trigger the login action from a template:

<button {{action 'login'}}>login</button>

Authentication status and data

Routes and controllers expose following properties in an auth0 object:

auth0: {

  // is current user authenticated, anonymous
  isAuthed: <bool>,
  isAnonymous: <bool>,

  // Auth0 user profile (can be customized in authParams.scope)
  profile: {
    user_id: <string>
    nickname: <string>
    email: <string>
    picture: <string>
  },

  // Auth0 access token
  token: <string>

}

Development

The dummy application in ./tests/dummy contains an example integration of the addon for testing.

Installation

git clone https://github.com/cspanring/ember-cli-auth0-lock.git
npm install
bower install

Running

ember server

Visit the dummy app at http://localhost:4200.

Running Tests

ember test
ember test --server

For more information on using ember-cli, visit http://www.ember-cli.com/.