Skip to content

feat(outputs.mongodb): Add PLAIN authentication support and validation - #17869

Merged
mstrandboge merged 6 commits into
influxdata:masterfrom
skartikey:outputs_mongodb_plain_auth
Oct 27, 2025
Merged

feat(outputs.mongodb): Add PLAIN authentication support and validation#17869
mstrandboge merged 6 commits into
influxdata:masterfrom
skartikey:outputs_mongodb_plain_auth

Conversation

@skartikey

Copy link
Copy Markdown
Contributor

Summary

Added PLAIN authentication support following the same pattern as SCRAM:

  [[secretstores.os]]
    id      = "mongosecret"
    keyring = "telegraf"

  [[outputs.mongodb]]
    dsn = "mongodb://${MONGODB_HOST}/?tls=true"
    authentication = "PLAIN"
    username = "@{mongosecret:mongo_username}"
    password = "@{mongosecret:mongo_password}"

Security Considerations

PLAIN authentication sends credentials in plaintext during the SASL authentication handshake. The implementation includes:

  • Runtime warning if tls=true or mongodb+srv:// is not detected
  • Documentation warnings about TLS requirement
  • No change to how credentials are transmitted (follows MongoDB driver behavior)

Users must use TLS to secure PLAIN authentication in transit. Secret store protects credentials at rest.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #6460

Add support for PLAIN authentication mechanism (commonly used with LDAP) to the MongoDB output plugin. Users can now use secret-aware username and password fields instead of embedding credentials in the DSN.
@telegraf-tiger telegraf-tiger Bot added area/mongodb feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Oct 21, 2025

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @skartikey! Some comments...

Comment thread plugins/outputs/mongodb/mongodb.go
Comment thread plugins/outputs/mongodb/mongodb.go Outdated
Comment thread plugins/outputs/mongodb/README.md Outdated
skartikey and others added 2 commits October 21, 2025 20:52
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
From MongoDB's documentation, both parameters enable encrypted connections. MongoDB kept the ssl parameter for backwards compatibility with older applications, but added tls as the more modern/accurate name.
@skartikey
skartikey requested a review from srebhan October 22, 2025 10:51

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome job @skartikey! Two small suggestions...

Comment thread plugins/outputs/mongodb/mongodb.go Outdated
Comment thread plugins/outputs/mongodb/mongodb.go Outdated
skartikey and others added 3 commits October 23, 2025 10:43
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
@telegraf-tiger

Copy link
Copy Markdown
Contributor

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perfect. Thanks @skartikey!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Oct 23, 2025
@srebhan srebhan removed their assignment Oct 23, 2025
@mstrandboge
mstrandboge merged commit 435df4b into influxdata:master Oct 27, 2025
27 checks passed
@github-actions github-actions Bot added this to the v1.37.0 milestone Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mongodb feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

3 participants