如何在 NodeJS 端点访问 Ember-Simple-Auth-Token 授权方 header

How to access Ember-Simple-Auth-Token authorizer header in NodeJS endpoint

我想弄清楚 authorizer:application' 在请求中的设置位置。它应该在 headers 中的某个地方吗?从应用发出请求时,我无法在 nodejs 端点的请求中找到它。

我在 ember (adapter/application.js) 中的代码是:

import DS from "ember-data";
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';

export default DS.RESTAdapter.extend(DataAdapterMixin, {
  authorizer: 'authorizer:application',

端点很简单:

exports.getAuthorizer = function(req, res) {
  console.log(req);
}

我已经记录了请求,希望我能在里面找到授权人,但找不到。

如果您需要更多信息,请告诉我,谢谢

ember-simple-auth-token: https://github.com/jpadilla/ember-simple-auth-token

要访问 API 中的授权令牌,我只需要简单地执行以下操作:

exports.getAuthorizer = function(req, res) {
  if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
    return req.headers.authorization.split(' ')[1];
  } else if (req.query && req.query.token) {
    return req.query.token;
  } else {
    return null;
  }
}

https://github.com/auth0/express-jwt

首先阻止我这样做的是 header 从未被发送过。我有 ember-cli-simple-auth 和 ember-simple-auth。

修复 是从项目中删除 ember-cli-simple-auth 和 ember-cli-simple-auth-令牌 (https://github.com/jpadilla/ember-simple-auth-token/issues/96)