Closed manyuanrong closed 3 years ago
I'm curious, is this authorization is about this uri string: mongodb://user:pass@localhost:3000
??
I'm curious, is this authorization is about this uri string:
mongodb://user:pass@localhost:3000
??
I'm not sure but maybe current code will just connect to db without auth
I saw from here https://www.youtube.com/watch?v=VF38U2qd27Q, seems he can connect to mongo atlas, but somehow my mongo string to local mongodb doesn't work. How to establish connection to mongodb with user pass?
if this issue is related with that user pass, then I will wait while looking for a workaround.
The version after v0.20.0 has completely used TS refactoring. Before that, it was packaged with mongodb's official rust library. Previous versions can work, but the plugin API of Deno itself is always in an unstable state, and it may be deleted. Therefore, this project has been completely rewritten and has not yet been able to support authorization. The work includes two parts
//memo
if authorization option was enabled on server, then server will throw this error:
MongoError: {"ok":0,"errmsg":"command insert requires authentication","code":13,"codeName":"Unauthorized"}
Is ready my dear, my pull request is complete. The driver now supports authentication!
Pull request https://github.com/denodrivers/deno_mongo/pull/156
If the password contains a percent sign "%", it will be an error;
url like this "mongodb://abc:asdf%25@localhost:27017/test";
used v0.20.0
@whiter001 already fixed on v0.20.1
v0.21.0 is supported
I still got an error
Uncaught (in promise) Error: MongoError: {"ok":0,"errmsg":"Authentication failed.","code":18,"codeName":"AuthenticationFailed"}
while using the same string as being used in my mongodb compass. how to debug this?
and this is my code:
import { MongoClient } from "https://deno.land/x/mongo@v0.21.0/mod.ts";
const client = new MongoClient();
await client.connect(`mongodb://${user}:${pass}@localhost:27017/${db}`);
I have same error.
my version is v0.21.0 and I tried to v0.21.2 also same.
my password is 123!%40%23
.
is it problem with special characters?
@iamdenny I don't think because of special characters, already tried using alphanumeric still doesn't work.
@darrylsepeda You can try to use the parameter object to connect
await client.connect({
credential:{
username: `$username`,
password: `${pass}`,
mechanism: `SCRAM-SHA-1`,
db: `$db`
},
db: `${db}`,
servers: [{host:"localhost",port:27017}]
});
@manyuanrong thanks and noted, will try in a few days and let you know. cheers!
The current version using TS has more functions than before. However, authorized login has not yet been implemented. If completed, 1.0 can be released
https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst#scram-sha-1