我安装了一个新的风帆应用程序,我计划整合护照进行身份验证。 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
答案 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,它应该可以正常工作。