Microsoft Azure Active Directory Passport身份validation
贝娄的代码运行良好,但是当授权头来自php代码的空令牌(eg-'Authorization:bearer')时,node.js应用程序会崩溃。 我正在使用“passport-azure-ad”节点模块。 我与邮政人检查,它是validation令牌,但是当请求来自PHPcurl请求,应用程序崩溃。 其原因是,http头在“passport-azure-ad”节点模块中设置了两次。 我无法捕捉到这个错误。
router.get('/getUser', passport.authenticate('oauth-bearer', { session: false, tenantIdOrName: TENANT }), function (req, token, done) { // Send response });
崩溃错误跟踪 – _http_outgoing.js:356抛出错误('发送后不能设置标题'); ^
错误:发送后无法设置标题。 在\ node_modules \ passport \ lib \ middleware \ authenticate.js:156:13)
PHP代码=>
$headers = array ('Authorization: bearer ' . $Requestheader['id_token']); $ch = curl_init (); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); curl_setopt ( $ch, CURLOPT_URL, 'http://serverhost/auth/getUser' ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers ); return curl_exec ( $ch );
我该如何处理这个错误,谢谢。
Node.js正在一个线程中运行,当错误没有被处理时它会崩溃。 这里是关于Node.js中exception处理的非常有用的线程:
Node.js最佳实践exception处理
- 快速有效地创buildCSV文件报告,而不会减慢node.js服务器的速度
- 存储过程受节点mssql对象影响的行
- 无法在Azure Web应用程序上运行EXE文件
- 在Node.js中访问Azure ServiceConfiguration设置
- 如何让Azure nodejs webapp重新运行npm install?
- configurationAzure在开发环境中运行nodejs应用程序
- 将Azure托pipe的DocPad Node.js网站的GitHub更新部署到站点,使站点离线1-2分钟
- 使用node-gyp的node.js应用程序无法在Azure网站上部署
- 在为重新创build的网站运行“azure色网站日志尾巴”时未经授权访问