我试图弄清楚在请求中设置了authorizer:application的位置。它应该在标题中吗?从应用程序发出请求时,我无法在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
首先,阻止我执行此操作的原因是从未发送过标头。我有ember-cli-simple-auth以及ember-simple-auth。
该修复是从项目中移除灰烬-CLI-简单权威性和灰烬-CLI-简单身份验证令牌(https://github.com/jpadilla/ember-simple-auth-token/issues/96)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句