Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support authorization #129

Closed
2 tasks done
manyuanrong opened this issue Nov 14, 2020 · 17 comments
Closed
2 tasks done

Support authorization #129

manyuanrong opened this issue Nov 14, 2020 · 17 comments
Labels
enhancement New feature or request
Milestone

Comments

@manyuanrong
Copy link
Member

manyuanrong commented Nov 14, 2020

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

  • Parsing ur connection string with authentication information
  • Implementation scram-sha1 authorization
@manyuanrong manyuanrong added the enhancement New feature or request label Nov 14, 2020
@manyuanrong manyuanrong added this to the 1.0 milestone Nov 14, 2020
@darrylsepeda
Copy link

I'm curious, is this authorization is about this uri string: mongodb://user:pass@localhost:3000??

@Preta-Crowz
Copy link

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

@darrylsepeda
Copy link

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.

@manyuanrong
Copy link
Member Author

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

  • Parsing ur connection string with authentication information
  • Implementation of mongodb's scram-sha1 authorization

@Preta-Crowz
Copy link

//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"}

@hviana
Copy link
Contributor

hviana commented Jan 8, 2021

Is ready my dear, my pull request is complete. The driver now supports authentication!

@hviana
Copy link
Contributor

hviana commented Jan 8, 2021

Pull request #156

@whiter001
Copy link

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
image

@Preta-Crowz
Copy link

@whiter001 already fixed on v0.20.1

@manyuanrong
Copy link
Member Author

v0.21.0 is supported

@darrylsepeda
Copy link

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?

@darrylsepeda
Copy link

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}`);

@iamdenny
Copy link

iamdenny commented Mar 2, 2021

I have same error.
image

my version is v0.21.0
and I tried to v0.21.2 also same.

@iamdenny
Copy link

iamdenny commented Mar 2, 2021

my password is 123!%40%23.
is it problem with special characters?

@darrylsepeda
Copy link

@iamdenny I don't think because of special characters, already tried using alphanumeric still doesn't work.

@manyuanrong
Copy link
Member Author

@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}]
});

@darrylsepeda
Copy link

@manyuanrong thanks and noted, will try in a few days and let you know. cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants