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

[feature request] mongodb authentication #844

Closed
SamuelTJackson opened this issue Feb 20, 2020 · 3 comments
Closed

[feature request] mongodb authentication #844

SamuelTJackson opened this issue Feb 20, 2020 · 3 comments

Comments

@SamuelTJackson
Copy link
Contributor

Hi,
it should be possible to set the mongodb username, password and authdb.

something like:

Environment variable Configuration attribute
IOTA_MONGO_USER mongodb.user
IOTA_MONGO_PASSWORD mongodb.password
IOTA_MONGO_AUTH_DB mongodb.authDB
@fgalan
Copy link
Member

fgalan commented Feb 24, 2020

It sounds interesting and it shouldn't be complex (just a matter of using the new parameters in the point of the code in which the connection to MongoDB is done).

It would be great if somebody supporting the use case (i.e. using MongoDB server with authentication) could provide the implementation. We will be more than happy to review the pull request with this :)

Thanks for the feedback!

@SamuelTJackson
Copy link
Contributor Author

I'm not an expert in javascript but this is my suggestion. Maybe it helps:

'IOTA_AUTOCAST',
insert:

'IOTA_MONGO_USER',
'IOTA_MONGO_PASSWORD',
'IOTA_MONGO_AUTH_DB',

'IOTA_MONGO_REPLICASET',
insert:

'IOTA_MONGO_USER',
'IOTA_MONGO_PASSWORD',
'IOTA_MONGO_AUTH_DB',

insert:

if (process.env.IOTA_MONGO_USER) {
        config.mongodb.user = process.env.IOTA_MONGO_USER;
}

if (process.env.IOTA_MONGO_PASSWORD) {
        config.mongodb.password = process.env.IOTA_MONGO_PASSWORD;
}
if (process.env.IOTA_MONGO_AUTH_DB) {
        config.mongodb.authDB = process.env.IOTA_MONGO_AUTH_DB;
}

insert:

if (currentConfig.mongodb.user && currentConfig.mongodb.password) {
   currentConfig.username = currentConfig.mongodb.user;
   currentConfig.password = currentConfig.mongodb.password;
}

if (currentConfig.mongodb.authDB) {
  options.authDB = {auth_db: currentConfig.mongodb.authDB};
}

insert:

if (options.authDB) {
        var delimiter = options.replicaSet ? '&' : '?';
        url += delimiter + 'authSource=' + options.authDB.auth_db;
}

https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/installationguide.md add new varialbes:
| IOTA_MONGO_USER | mongodb.user |
| IOTA_MONGO_PASSWORD | mongodb.password |
| IOTA_MONGO_AUTH_DB | mongodb.authDB |

@fgalan
Copy link
Member

fgalan commented Feb 26, 2020

Fixed by PR #846

@fgalan fgalan closed this as completed Feb 26, 2020
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