如何在使用SHA256作为密码的feathersjs身份验证中添加自定义身份验证

时间:2019-01-31 10:47:26

标签: node.js authentication bcrypt sha256 feathersjs

我注意到Feathersjs身份验证使用bcrypt作为密码。

这是hooks.js中的代码

const { authenticate } = require('@feathersjs/authentication').hooks;

const {
  hashPassword, protect
} = require('@feathersjs/authentication-local').hooks;


module.exports = {
  before: {
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [ hashPassword() ],
    update: [ hashPassword(),  authenticate('jwt') ],
    patch: [ hashPassword(),  authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
  },

  after: {
    all: [ 
      // Make sure the password field is never sent to the client
      // Always must be the last hook
      protect('password')
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
};

现在,我想将默认的哈希密码更改为sha256,而不是bycrpt。有人有解决方案吗?

谢谢

0 个答案:

没有答案