我正在尝试研究如何将 passport.js 与 grunt/yeoman 一起使用。我有以下内容:
// at the top of my gruntfile.js
var passport = require('passport');
var BasicStrategy = require('passport-http').BasicStrategy;
passport.use(new BasicStrategy(
function(username, password, done) {
return done(null, true); // I would expect this to always succeed, but still challenge for credentials
}
));
// further down in my connect config.
livereload: {
options: {
middleware: function (connect) {
return [
lrSnippet,
passport.initialize(),
passport.authenticate('basic', { session: false }),
mountFolder(connect, '.tmp'),
mountFolder(connect, yeomanConfig.app)
];
}
}
}
在每个请求上,响应只包含unauthorized
. 删除对passport.authenticate
使页面工作的调用,但显然现在没有身份验证。我试过改变中间件的顺序,但没有帮助,而且我离 yeoman/grunt 的专家还差得很远,所以我不完全确定还能尝试什么......
任何帮助将不胜感激。