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

MongoDB doesnt support authentication #1510

Closed
cblancog00 opened this issue Oct 10, 2023 · 1 comment
Closed

MongoDB doesnt support authentication #1510

cblancog00 opened this issue Oct 10, 2023 · 1 comment

Comments

@cblancog00
Copy link
Contributor

IoT Agent Node Lib version the issue has been seen with

3.4.4

Bound or port used (API interaction)

Other

NGSI version

NGSI-LD

Are you running a container?

Yes, I am using a contaner (Docker, Kubernetes...)

Image type

normal

Expected behaviour you didn't see

I moved this issue from the iotagent-json repo:
telefonicaid/iotagent-json#739

The error was not related to the iotagent, instead it's related to the iotagent-node-lib who is the resposible of the Mongo connection.

When setting a mongo connection with authentication using user and password it fails throwing an Authentication Fail error.
I've been looking throw the code and it seems to be related to the iotagent-node-lib/lib/model/dbConn.js
And it seems to only generates connection strings without autentication

https://github.com/telefonicaid/iotagent-node-lib/blob/master/lib/model/dbConn.js

Test passes, cause an expected result it's bad defined cause in mongo connection strings user and password goes before the host

{
mongodb: {
host: 'example.com',
port: '98765',
db: 'examples',
replicaSet: 'rs0',
user: 'user01',
password: 'pass01',
authSource: 'admin'
},
expected: {
url: 'mongodb://example.com:98765/examples',
options: {
replicaSet: 'rs0',
auth: {
user: 'user01',
password: 'pass01'
},
authSource: 'admin',
useNewUrlParser: true,
useUnifiedTopology: true
}
}
},

The error should be solved easily, checking if the options.auth is present and concat into the url string. Located in th e init function

Unexpected behaviour you saw

No response

Steps to reproduce the problem

No response

Configs

No response

Log output

No response

@fgalan
Copy link
Member

fgalan commented Oct 11, 2023

PR #1511

@fgalan fgalan closed this as completed Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants