Tag: 羽毛

如何在使用feathersjs响应NodeJs之前发送令牌jwt来validation?

我正在使用令牌jwt做pipe理仪表板。 我想用户只有login才能获得对中间件的访问权限。 我想这样做,如果他login,服务器显示主页,如果没有,然后他redirect到login页面。 下面是我的中间件index.js const auth = require('feathers-authentication'); const pupils = require('./pupils'); const login = require('./login'); const home = require('./home'); module.exports = function () { // Add your custom middleware here. Remember, that // in Express the order matters const app = this; // eslint-disable-line no-unused-vars app.use('/pupils.html', pupils()); app.use('/login.html', login()); app.use('/', home()); app.post('/login', auth.express.authenticate('local', { […]

要更新MongoDB文档中的单个字段,最好的方法是什么? 在feathersjs中更新或修补钩子

我试图在单个字段中更新mongodb文档,我怀疑要使用羽化框架使用哪个补丁或更新的方法,举例说明我们如何才能做到这一点。 const { authenticate } = require('feathers-authentication').hooks; module.exports = { before: { all: [ authenticate('jwt') ], find: [], get: [], create: [], update: [], patch: [], remove: [] }, after: { all: [], find: [], get: [], create: [], update: [], patch: [], remove: [] }, error: { all: [], find: [], get: [], create: […]

将非用户字段添加到有效内容以用于JWT令牌

您好我正在寻找添加一个非用户字段的身份validation过程中的有效载荷,所以我可以包含在JWT令牌。 请求是这样的: { "scriptId": "script1", "password": "password", "userName": "user1" } configuration是这样的: "auth": { "local": { "usernameField" : "scriptId" }, "token": { "secret": "mysecret", "payload": ["scriptId","userName"], "expiresIn": "10min" }, "successRedirect": "/chat.html" } 我怎样才能传递userName参数,所以我可以在auth /令牌服务的前钩子检索它,所以我可以把它的hook.data 或者如果有更好的方法来做,只需让我知道。

在FeathersJS中使用connect-history-api-fallback中间件来服务Vue.js SPA

正如标题所示,我正在为FeathersJS中的public/index.html提供一个Vue.js单页应用程序。 由于我使用的是vue-router的HTML5历史logging模式,为了将请求的前端位置重写为/index.html ,我必须使用像connect-history-api-fallback这样的中间件。 在app.use(notFound());之前在src/middleware设置这个中间件app.use(notFound()); 不起作用,因为Feathers在一切之前提供静态文件,所以在请求被重写的时候什么也没有提起/index.html而notFound提供404响应。 在src/app.js .use('/', serveStatic(app.get('public')))也是有问题的,因为它会将每个服务请求重写到/index.html ,导致API调用不可用。 我结束了移动serveStatic中间件后.configure(services)和放置connect-history-api-fallback如上所示: app.use(compress()) .options('*', cors()) .use(cors()) // favicon and serveStatic used to be here .use(bodyParser.json()) .use(bodyParser.urlencoded({ extended: true })) .configure(hooks()) .configure(rest()) .configure(socketio()) .configure(services) .use(require('connect-history-api-fallback')()) // now they are down here .use(favicon(path.join(app.get('public'), 'favicon.ico'))) .use('/', serveStatic(app.get('public'))) .configure(middleware); 我的问题是以下几点:这种方法有什么性能或安全方面的缺陷吗?

如何对待羽毛球内的承诺?

我想在插入数据库之前validation数据。 Feathersjs的方式是通过使用钩子。 在插入一组权限之前,我必须考虑用户post提供的数据的完整性。 我的解决scheme是find与用户提供的数据相关的所有权限。 通过比较列表的长度,我可以certificate,如果数据是正确的。 钩子的代码贴在下面: const permissionModel = require('./../../models/user-group.model'); module.exports = function (options = {}) { return function usergroupBefore(hook) { function fnCreateGroup(data, params) { let inIds = []; // the code in this block is for populating the inIds array if (inIds.length === 0) { throw Error('You must provide the permission List'); } //now […]