0

I'm using the following libraries:

  • ember-cli: 0.2.0.beta.1
  • ember-cli-simple-auth: 0.7.3
  • ember-cli-simple-auth-oauth2: 0.7.3

The simple-auth libs were installed like so:

ember install:addon ember-cli-simple-auth
ember install:addon ember-cli-simple-auth-oauth2

I've been trying to get simple-auth configured with the standard simple-auth Oauth2 authenticator simple-auth-authenticator:oauth2-password-grant which seems to be mandatory to put in my login controller that mixed LoginControllerMixin (not sure why we have the ENV['simple-auth'] = { authenticator: ' ... ' }; option since it's not honored?) and trying to set the following end points:

serverTokenRevocationEndpoint: '/revoke'
serverTokenEndPoint: '/test'

no matter how I put things in the config/environment.js it just doesn't get honored. My end point remains the default /token and the revocation point is not in effect.

Do I need to create a custom Oauth2 authenticator class for my settings to be used?

I thought configuring it would kick off the standard classes and just work, no?

Here's what I have so far:

controllers/login.js

import Ember from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';

export
default Ember.Controller.extend(LoginControllerMixin, {
  authenticator: 'simple-auth-authenticator:oauth2-password-grant'
});

config/environment.js

/* jshint node: true */
var Auth = require('./auth.js');

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'mbo',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;

    ENV['simple-auth'] = {
      authorizer: 'simple-auth-authorizer:oauth2-bearer'
      // routeAfterAuthentication: 'user.dashboard'
    };

    ENV['simple-auth-oauth2'] = Auth.dev.internal;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';

    // ENV['simple-auth'] = {
    //   serverTokenEndpoint: '/api/v2/test',
    //   serverTokenRevocationEndpoint: '/api/v2/logout'
    // }
  }

  if (environment === 'production') {
    // ENV['simple-auth'] = {
    //   serverTokenEndpoint: '/token',
    //   serverTokenRevocationEndpoint: '/logout'
    // }
  }

  return ENV;
};

conf/auth.js

module.exports = {
  dev: {
    external: {
    },
    internal: {
        serverTokenEndpoint: '/token',
        serverTokenRevocationEndpoint: '/logout'
    }
  },
  prod: {
    external: {
    },
    internal: {
        serverTokenEndpoint: '/token',
        serverTokenRevocationEndpoint: '/logout'
    }
  }
};

As is, the authenticate method send the request to /token and the invalidateSession invalidates the session but sends no request to the back-end.

ashraf
  • 537
  • 7
  • 16
  • `ENV['simple-auth'] = { authenticator: ' ... ' };` doesn't exist - what you mean is `ENV['simple-auth'] = { authorizer: ' ... ' };` - please check the README for an explanation of the difference between authenticator and authorizer – marcoow Feb 25 '15 at 15:29
  • Please post your complete `config/environment.js`. – marcoow Feb 26 '15 at 08:32
  • @marcoow It seems that a full restart of the browser sorted the issue! You are obviously right about the `authenticator: ' ... '` not existing in 'simple-auth'. – ashraf Feb 26 '15 at 16:17
  • Your config seems correct – marcoow Feb 27 '15 at 17:23
  • @marcoow yeah, I suspect the browser was playing me! I'll double test before I put a final answer to this. Thanks for taking the time to look into this too. – ashraf Feb 28 '15 at 02:17

0 Answers0