MySQL/MariaDB: Custom callback/trigger support on user activation/deactivation #49716
+53
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
The Teleport server is unable to authenticate users with a TLS proxy, such as Maxscale, between the Teleport server and the MariaDB/MySQL database. This is because the TLS proxy terminates the original TLS connection and creates a new one with a different TLS certificate, causing a mismatch in the CN attribute. As a result, users created by Teleport in the database with a specific CN attribute cannot log in.
The communication schema is:
Teleport server [Teleport client TLS certificate] -> Maxscale (TLS proxy) [Maxscale TLS certificate] -> MariaDB/MySQL server.
The suggested solution
Updated SQL procedures to call a callback user-created procedure upon user activation or deactivation if exists (a custom trigger on user activation/deactivation) . This allows for customizable actions to be triggered when a user's status changes.
The result I would like to achieve with such changes is updating database users before a login.
Teleport successfully creates users in the MariaDB/MySQL database with
REQUIRE SUBJECT /cn={username}
, but the TLS proxy creates a new TLS connection and uses another TLS certificate with a differentCN
attribute and the Teleport users can't login into a database.The solution is the optional creation of one or two stored procedures by the Teleport administrator in the
teleport
database:teleport_user_activated_callback(username)
with a signatureteleport_user_deactivated_callback(username)
with a signatureThe suggested stored procedures allow database administrators to react to these actions and update the teleport user in a database by changing
REQUIRE SUBJECT /CN={username}
to another method of authentication, for example:REQUIRE SUBJECT
IDENTIFIED WITH own_auth_plugin
Expected workflow:
teleport_activate_user(username)
MariaDB/MySQL stored procedure.teleport_activate_user
calls the client's ownteleport_user_activated_callback(username)
procedure if it exists and executes the client's business logic on this action.The same approach is used when the user deactivates in a database:
teleport_deactivate_user(username)
MariaDB/MySQL stored procedure.teleport_deactivate_user(username)
calls the client's ownteleport_user_deactivated_callback(username)
procedure if it exists and executes the client's business logic on this action.What do you think about such an approach?