【发布时间】:2015-02-05 20:32:03
【问题描述】:
我有一个使用 Ember CLI 0.1.12 的简单且有效的应用程序。我将 Ember Simple Auth 插件与令牌验证器和授权器一起使用。 https://github.com/jpadilla/ember-cli-simple-auth-token
首先,我无法进行身份验证,因为我不知道服务器应该返回什么。经过大量的谷歌搜索,我发现服务器应该返回如下内容:
{ "access_token": "ToKeN123hEre" }
现在我能够进行身份验证并且会话正常工作。但是当我进行其他调用时,授权头不会出现在请求头中,因此服务器不可能知道令牌。
这是我迄今为止尝试过的:
设置我的 environment.js 文件:
ENV['simple-auth'] = {
crossOriginWhitelist: ['*'],
authorizer: 'simple-auth-authorizer:token',
routeAfterAuthentication: '/profile'
};
ENV['simple-auth-token'] = {
serverTokenEndpoint: '/api0/auth',
identificationField: 'username',
passwordField: 'password',
tokenPropertyName: 'token',
authorizationPrefix: 'Bearer ',
authorizationHeaderName: 'Authorization',
headers: {}
};
让我的服务器使用 CORS 并允许 Authentication 标头和来自任何 Origin 的请求。
【问题讨论】:
标签: ember.js http-headers token ember-cli ember-simple-auth