我是Node-red和passport-identityserver3的新手。
我在如何设置护照方面遇到了一些困难。
我使用C:\Users\xxx>npm install passport-identityserver3
命令安装了护照并尝试设置C:\Users\xxx\settings.js
文件:
adminAuth: {
type:"strategy",
strategy: {
name: "passport-identityserver3",
label: 'Sign in with',
icon:"an icon",
strategy: require('passport-identityserver3').Strategy,
options: {
configuration_endpoint: 'http://localhost:xxxx/.well-known/openid-configuration',
client_id: 'my_client_id',
client_secret: 'my_client_secret',
callback_url: 'http://localhost:1880/auth/strategy/callback',
scopes: ['profile', 'offline_access'],
},
verify: function(token, tokenSecret, profile, done) {
done(null, profile);
}
},
users: [
{ username: "admin",permissions: ["*"]}
]
},
我收到以下错误:
http://127.0.0.1:1880/auth/strategy
Error: Unknown authentication strategy "passport-identityserver3"
at attempt (C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\passport\lib\middleware\authenticate.js:173:37)
at authenticate (C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\passport\lib\middleware\authenticate.js:349:7)
at Layer.handle [as handle_request]
(C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request]
(C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\index.js:281:22
at Function.process_params
(C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\express\lib\router\index.js:275:10)
at SessionStrategy.strategy.pass
(C:\Users\xxxx\AppData\Roaming\npm\node_modules\node-
red\node_modules\passport\lib\middleware\authenticate.js:325:9)
谢谢你。
答案 0 :(得分:0)
您需要在Node-RED用户目录中运行npm i passport-identityserver3
。默认情况下,这应该是:
C:\Users\xxx\.node-red
不
C:\Users\xxx\
settings.js
文件也应该在此目录中。当您启动Node-RED时,它将列出哪个用户目录和settings.js
正在使用