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处理
- 在mac os上运行azure时Node.jsexception201
- Nodejs上传base64图像到azure blob存储结果为“ResourceNotFound”错误
- 使用包含Node.js项目的TeamCity构buildCloud Service包
- Azure Node.js Web应用程序 – 如何在更新时提供服务?
- 从azure eventhub使用node.js消耗八位字节stream数据
- 连接到Azure移动服务上托pipe的Socket.IO服务器返回错误
- process.env.portvariables上的Node.js和MS Azure
- 用于节点的Azure SDK在JSON响应中四舍五入
- 使Azure DocumentDB不返回服务字段