我正在使用以下库:
-
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
我一直在尝试使用标准的simple-auth Oauth2身份验证器 simple-auth-authenticator:oauth2-password-grant
来配置simple-auth,这似乎是必须放入我的登录控制器混合 LoginControllerMixin
(不知道为什么我们有 ENV['simple-auth'] = { authenticator: ' ... ' };
选项,因为它没有被尊重?)和试图设置以下终点:
serverTokenRevocationEndpoint: '/revoke'
serverTokenEndPoint: '/test'
无论我如何把东西放在 config/environment.js
中它都没有得到尊重 . 我的终点仍然是默认 /token
,并且撤销点无效 .
我是否需要为要使用的设置创建自定义 Oauth2
身份验证器类?
我认为配置它会启动标准类,只是工作,不是吗?
这是我到目前为止所拥有的:
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'
}
}
};
按原样, authenticate
方法将请求发送到 /token
, invalidateSession
使会话无效,但不向后端发送请求 .