Skip to content

Add user and password config to MySQL event listener #26260

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielbelchior
Copy link
Contributor

Description

This PR introduces support for configuring MySQL credentials in the event listener using the new properties mysql-event-listener.db.user and mysql-event-listener.db.password.
These properties allow users to specify the database username and password separately from the JDBC URL, making configuration more secure and user-friendly, especially when passwords contain special characters. The connection logic now uses these properties if provided, falling back to credentials in the JDBC URL if not set.
Documentation has been updated to reflect the new configuration options.

Additional context and related issues

This change aligns the MySQL event listener configuration with the approach used by other Trino connectors, improving consistency and usability. It addresses issues encountered when embedding credentials with special characters in the JDBC URL and enhances security by allowing sensitive information to be managed separately. No related issues were referenced, but this update is based on common best practices and user feedback.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(X) Release notes are required, with the following suggested text:

## MySQL event Listener
* Supports separate configuration properties for database username and password ({issue}`25941`)

Closes: #25941

Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions bot added the docs label Jul 22, 2025
@danielbelchior danielbelchior changed the title Feat(mysql-event-listener): Add user and password config to MySQL event listener Add user and password config to MySQL event listener Jul 22, 2025
@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from ad6a7cb to 7eb43bb Compare July 22, 2025 09:56
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from 7eb43bb to 1d09790 Compare July 23, 2025 09:20
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from 1d09790 to e98d7cf Compare July 23, 2025 09:21
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from e98d7cf to 8968d7a Compare July 23, 2025 09:26
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

Remove Feat(mysql-event-listener): from the commit title, and wrap the commit body at 72 characters. See https://trino.io/development/process.html#pull-request-and-commit-guidelines- for more details.

@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from 8968d7a to 41124be Compare July 23, 2025 09:44
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from 41124be to a3a6c3f Compare July 23, 2025 10:32
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Allow configuring MySQL credentials for the event listener using
separate mysql-event-listener.db.user and
mysql-event-listener.db.password properties. This makes it easier
and safer to provide credentials, especially when passwords
contain special characters, and aligns with the configuration
style of other Trino connectors. The connection logic now uses
these properties if provided, falling back to credentials in the
JDBC URL if not set.
@danielbelchior danielbelchior force-pushed the mysql-event-listener-add-credentials-config branch from a3a6c3f to 8dff8ac Compare July 23, 2025 10:57
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Comment on lines +79 to +85
if (getUser().isPresent() && url != null && url.matches(".*[?&]user=.+")) {
throw new RuntimeException("'user' property is set, but JDBC URL also contains 'user' in the query string. Please specify the user only once.");
}
// Check for password property
if (getPassword().isPresent() && url != null && url.matches(".*[?&]password=.+")) {
throw new RuntimeException("'password' property is set, but JDBC URL also contains 'password' in the query string. Please specify the password only once.");
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to parse the URL by ourselves. Please consider using helper methods in MySQL JDBC driver, e.g. ConnectionUrlParser.parseConnectionString method

@ebyhr
Copy link
Member

ebyhr commented Jul 27, 2025

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Jul 27, 2025
Copy link

cla-bot bot commented Jul 27, 2025

The cla-bot has been summoned, and re-checked this pull request!

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

Successfully merging this pull request may close these issues.

Allow for additional MySQL Event Listener connection properties
2 participants