我无法在composer-rest-server中找到使用本地策略进行身份验证的有效解决方案。事实上,只有一个工作解决方案是使用github。我尝试将COMPOSER_PROVIDERS设置为
export COMPOSER_PROVIDERS='{
"local": {
"provider": "local",
"module": "passport-local",
"usernameField": "username",
"passwordField": "password",
"authPath": "/auth/local",
"callbackURL":"/auth/local/callback",
"successRedirect": "/",
"failureRedirect": "/",
"setAccessToken": true,
"callbackHTTPMethod": "post"
}
}'
但没有运气。我甚至没有为此获得登录表单。对于localhost:3000 / auth / local,我得到404.看起来没有人尝试过本地身份验证策略。我是nodejs编程的新手。任何帮助都非常感谢。
答案 0 :(得分:0)
其他人可能会发布解决方案,但您可能希望参考以下链接:Where to put PassportJs local strategy in an express application?和https://github.com/strongloop/loopback-example-passport/issues/99以及How to use passport-local to authenticate in composer rest server
答案 1 :(得分:0)
通过在passport-configurator.js
中将回调函数更改为默认值来解决此问题