sails-auth不生成模型,策略等,

时间:2018-02-27 16:50:22

标签: npm sails.js

我安装了一个新的风帆应用程序,我计划整合护照进行身份验证。 Sails-auth似乎是最简单的方法,但它不会像文档中所说的那样创建任何文件。

风帆:0.12.14

我在安装sails-auth时得到了这个弃用的警告,

newmacs-iMac:dn dev$ npm install sails-auth --save  
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js

1 个答案:

答案 0 :(得分:1)

您必须按照https://github.com/trailsjs/sails-auth

中说明的步骤操作

首先,执行npm install sails-auth --save,然后安装您要使用的密码策略,例如: npm install passport-google-oauth 然后根据您要使用的护照策略创建包含以下内容的文件config/passport.js,例如:

module.exports.passport = {
  local: {
    strategy: require('passport-local').Strategy
  },

  basic: {
    strategy: require('passport-http').BasicStrategy,
    protocol: 'basic'
  }
};

此处可以找到更多示例https://github.com/trailsjs/sails-auth/blob/master/config/passport.js

然后创建config/auth.js

bcrypt: {
    /**
     * Specifiy number of salt rounds to perform on password. Values >10 are
     * slow.
     */
    rounds: 8
  }

然后,您可以根据您使用的护照策略向/auth/local/auth/google进行身份验证。

重要事项:与风帆v1.0 sails-auth似乎不再起作用,但由于您使用的是风帆0.12,它应该可以正常工作。