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

Use username & password (from env vars) for Mongo #336

Merged
merged 3 commits into from
May 20, 2024

Conversation

rmunn
Copy link
Collaborator

@rmunn rmunn commented May 20, 2024

Mongo connections can now use a username and password, specified by enviornment variables. If the environment variables are not present or are empty, then no authentication parameters are sent to Mongo.

Env vars used to specify the username and password will be LFMERGE_MONGO_USER and LFMERGE_MONGO_PASS, matching the convention used for other LfMerge env vars. LFMERGE_MONGO_AUTHSOURCE can also optionally be set to give the name of the MongoDB database where authentication is stored (default is admin and will probably not need changing).

Part of sillsdev/web-languageforge#1787, but closing this PR should not close that issue. The linked PR in the LF repo will be the one to close that issue.

Mongo connections can now use a username and password, specified by
enviornment variables. If the environment variables are not present or
are empty, then no authentication parameters are sent to Mongo.
Copy link

github-actions bot commented May 20, 2024

Test Results

    2 files  ±0    20 suites  ±0   5m 41s ⏱️ -1s
313 tests ±0  293 ✔️ ±0  20 💤 ±0  0 ±0 
316 runs  ±0  296 ✔️ ±0  20 💤 ±0  0 ±0 

Results for commit 871ea68. ± Comparison against base commit 51b8ad7.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@megahirt megahirt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Robin said he tested it locally

@rmunn rmunn merged commit 025f6b6 into develop May 20, 2024
3 checks passed
@rmunn rmunn deleted the chore/require-password-for-mongodb branch May 20, 2024 09:24
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool! hopefully we can secure mongo soon

mainDatabaseName = Settings.MongoMainDatabaseName;
client = new Lazy<IMongoClient>(GetNewConnection);
dbs = new ConcurrentDictionary<string, IMongoDatabase>();
}

private MongoClient GetNewConnection()
{
var clientSettings = new MongoClientSettings();
var clientSettings = MongoClientSettings.FromConnectionString(connectionString);
// clientSettings.WriteConcern = WriteConcern.WMajority; // If increasing the wait queue size still doesn't help, try this as well
clientSettings.WaitQueueSize = 50000;
clientSettings.Server = new MongoServerAddress(Settings.MongoHostname, Settings.MongoPort);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this line still relevant considering the port and host are in the connection string now?

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

Successfully merging this pull request may close these issues.

3 participants