Ember Simple Auth(带令牌插件)将不会使用令牌添加授权头文件 [英] Ember Simple Auth (with token plugin) won't add the Authorization header with the token

查看:165
本文介绍了Ember Simple Auth(带令牌插件)将不会使用令牌添加授权头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单和工作的应用程序与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:['*'],
授权者:'simple-auth-authorizer:token',
routeAfterAuthentication :'/ profile'
};

ENV ['simple-auth-token'] = {
serverTokenEndpoint:'/ api0 / auth',
identificationField:'username',
passwordField:'密码',
tokenPropertyName:'token',
authorizationPrefix:'承载',
authorizationHeaderName:'授权',
标题:{}
};

让我的服务器使用CORS,并允许来自任何Origin的Authentication标头和请求。

解决方案

我最终改变了access_token简单的令牌,现在它正常工作。


I had a simple and working application with Ember CLI 0.1.12. I use the Ember Simple Auth addon with the Token authenticator and authorizer. https://github.com/jpadilla/ember-cli-simple-auth-token

First, I wasn't able to authenticate, because I had no idea what the server was supposed to return. After a lot of googling, I was able to figure out that the server should return something like this:

{ "access_token": "ToKeN123hEre" }

Now I was able to authenticate and sessions work. But when I make other calls, the Authorization header doesn't appear in the request headers, so it's impossible for the server to know the token.

This is what I have tried so far:

Setting my environment.js file:

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: {}
};

Make my server use CORS and allow the Authentication header and requests from any Origin.

解决方案

I ended up changing "access_token" for simply "token", and now it works.

这篇关于Ember Simple Auth(带令牌插件)将不会使用令牌添加授权头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆