gremlin-javascript 中的纯文本 SASL 身份验证



我正在尝试使用JavaScript驱动程序变体连接到Gremlin服务器。

在包版本 2.7.0 之前,可以通过将选项传递给Gremlin.createClient()轻松完成此操作,如 Azure Cosmos DB 的以下示例所示:

const client = Gremlin.createClient(
config.port, 
config.endpoint, 
{ 
"session": false, 
"ssl": true, 
"user": `/dbs/${config.database}/colls/${config.collection}`,
"password": config.primaryKey
}
);

在较新版本的软件包中,我无法完成它。官方文档建议使用gremlin.driver.auth.PlainTextSaslAuthenticator.但是,该方法似乎未在包中实现并返回TypeError: Cannot read property 'PlainTextSaslAuthenticator' of undefined

我的测试代码(与工作示例中的配置相同.js(:

const gremlin = require("gremlin");
const config = require("./config");
const Graph = gremlin.structure.Graph;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const graph = new Graph();
const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator(
`/dbs/${config.database}/colls/${config.collection}`,
config.primaryKey
);
const g = graph.traversal().withRemote(new DriverRemoteConnection(`ws://${config.endpoint}:${config.port}`, { authenticator });

返回:

C:reposgremlin-testindex.js:9
const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator(
^
TypeError: Cannot read property 'PlainTextSaslAuthenticator' of undefined
at Object.<anonymous> (C:reposgremlin-testindex.js:9:47)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3

有人知道解决这个问题的方法吗?

我对 Gremlin.js 没有太多经验,但我只是下载了它并手动搜索了它的所有文件 - 我找不到任何PlainTextSaslAuthenticator函数或其声明的痕迹。

这可能意味着两个三个中的一个 -

  1. 它的功能已被(意外(删除
  2. 它使用已被(意外(删除的第三方软件包
  3. 它尚未添加到包中

在快速的Google搜索中,我找到了这个链接,它似乎显示它被添加到/lib/driver/auth,但是该目录似乎不存在我通过npm install gremlin获得的软件包中。也许它还没有发布?

因此,我建议您在 Github 上提出问题,但似乎您链接的存储库不允许提出问题。所以也许通过电子邮件/联系作者?

编辑:

感谢斯蒂芬的链接 - 代码尚未合并到包中。在这里跟踪它。

最新更新