Mongo 具有资源令牌的客户端 API
Mongo client API with resource token
我一直在尝试将 Mongo API cosmos 帐户用于多个数据库,并希望为各个资源生成资源令牌。我看到如下文档数据库的实现。
client = new DocumentClient(new Uri(endpointUrl), resourceToken);
但是,我正在寻找与 Mongo.Driver
相关的实现
MongoClientSettings settings = new MongoClientSettings();
settings.Server = new MongoServerAddress(host, 10255);
settings.UseSsl = true;
settings.SslSettings = new SslSettings();
settings.SslSettings.EnabledSslProtocols = SslProtocols.Tls12;
MongoIdentity identity = new MongoInternalIdentity(dbName, userName);
MongoIdentityEvidence evidence = new PasswordEvidence(tokepass2);
settings.Credential = new MongoCredential("SCRAM-SHA-1", identity, evidence);
MongoClient client = new MongoClient(settings);
我正在尝试用生成的资源令牌替换 "tokepass2"。但这不起作用并以异常结束
One or more errors occurred. (Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.)
我知道我们有可能使用 header 中的令牌进行基于 REST 的 post 调用,但是我正在寻找与 Mongo 客户端相关的实现,如果有人实施了。
不幸的是,我认为它不能在 Wire protocol compatibility 上的 C# Mongo DB driver.Based 中实现:
Azure Cosmos DB implements wire protocols of common NoSQL databases
including Cassandra, MongoDB, Gremlin, and Azure Tables Storage. By
providing a native implementation of the wire protocols directly and
efficiently inside Cosmos DB, it allows existing client SDKs, drivers,
and tools of the NoSQL databases to interact with Cosmos DB
transparently. Cosmos DB does not use any source code of the databases
for providing wire-compatible APIs for any of the NoSQL databases.
By default, new accounts created using Azure Cosmos DB's API for
MongoDB are compatible with version 3.6 of the MongoDB wire protocol.
Any MongoDB client driver that understands this protocol version
should be able to natively connect to Cosmos DB.
Cosmos db mongo api 只为 Mongo DB 实现有线协议,它没有任何特定的 sdk 用于 mongo db。和其他 mongo db 驱动程序,如 mongo c# 驱动程序或 mongoose 等,它们是为 mongo db 而构建的,而不是为 cosmos db mongo api .所以这些驱动程序不能直接支持资源令牌功能。您不能用资源令牌替换主密钥。
如果你想使用资源令牌,你可以使用:
1.REST API 正如你在问题中提到的
2.Migrate mongo db 到 cosmos db sql api。请参考这个link:https://docs.microsoft.com/en-us/azure/cosmos-db/import-data
我一直在尝试将 Mongo API cosmos 帐户用于多个数据库,并希望为各个资源生成资源令牌。我看到如下文档数据库的实现。
client = new DocumentClient(new Uri(endpointUrl), resourceToken);
但是,我正在寻找与 Mongo.Driver
相关的实现MongoClientSettings settings = new MongoClientSettings();
settings.Server = new MongoServerAddress(host, 10255);
settings.UseSsl = true;
settings.SslSettings = new SslSettings();
settings.SslSettings.EnabledSslProtocols = SslProtocols.Tls12;
MongoIdentity identity = new MongoInternalIdentity(dbName, userName);
MongoIdentityEvidence evidence = new PasswordEvidence(tokepass2);
settings.Credential = new MongoCredential("SCRAM-SHA-1", identity, evidence);
MongoClient client = new MongoClient(settings);
我正在尝试用生成的资源令牌替换 "tokepass2"。但这不起作用并以异常结束
One or more errors occurred. (Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.)
我知道我们有可能使用 header 中的令牌进行基于 REST 的 post 调用,但是我正在寻找与 Mongo 客户端相关的实现,如果有人实施了。
不幸的是,我认为它不能在 Wire protocol compatibility 上的 C# Mongo DB driver.Based 中实现:
Azure Cosmos DB implements wire protocols of common NoSQL databases including Cassandra, MongoDB, Gremlin, and Azure Tables Storage. By providing a native implementation of the wire protocols directly and efficiently inside Cosmos DB, it allows existing client SDKs, drivers, and tools of the NoSQL databases to interact with Cosmos DB transparently. Cosmos DB does not use any source code of the databases for providing wire-compatible APIs for any of the NoSQL databases.
By default, new accounts created using Azure Cosmos DB's API for MongoDB are compatible with version 3.6 of the MongoDB wire protocol. Any MongoDB client driver that understands this protocol version should be able to natively connect to Cosmos DB.
Cosmos db mongo api 只为 Mongo DB 实现有线协议,它没有任何特定的 sdk 用于 mongo db。和其他 mongo db 驱动程序,如 mongo c# 驱动程序或 mongoose 等,它们是为 mongo db 而构建的,而不是为 cosmos db mongo api .所以这些驱动程序不能直接支持资源令牌功能。您不能用资源令牌替换主密钥。
如果你想使用资源令牌,你可以使用:
1.REST API 正如你在问题中提到的
2.Migrate mongo db 到 cosmos db sql api。请参考这个link:https://docs.microsoft.com/en-us/azure/cosmos-db/import-data