我安装了一个新的风帆应用程序,我计划整合护照进行身份验证。 Sails-auth似乎是最简单的方法,但它不会像文档中所说的那样创建任何文件。
风帆:0.12.14
我在安装sails-auth时得到了这个不赞成的警告,
newmacs-iMac:dn dev$ npm install sails-auth --save
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
你必须按照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它应该工作。