ember-simple-auth-oauth2和ember-cli:serverTokenRevocationEndpoint不受尊重

时间:2015-02-24 17:26:35

标签: ember.js ember-simple-auth

我使用以下库:

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

simple-auth libs安装如下:

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

我一直在尝试使用标准的简单身份验证Oauth2身份验证器simple-auth-authenticator:oauth2-password-grant来配置simple-auth,这似乎是强制要求我放入混合LoginControllerMixin的登录控制器(不确定)为什么我们有ENV['simple-auth'] = { authenticator: ' ... ' };选项,因为它没有被尊重?)并试图设置以下终点:

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

无论我如何将内容放入config/environment.js,它都不会受到尊重。我的终点仍然是默认/token,撤销点无效。

我是否需要为要使用的设置创建自定义Oauth2身份验证器类?

我认为配置它会启动标准类而只是工作,不是吗?

这是我到目前为止所拥有的:

控制器/ 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'
});

配置/ 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'
    }
  }
};

按原样,authenticate方法将请求发送到/tokeninvalidateSession使会话无效,但不向后端发送请求。

0 个答案:

没有答案