-
Notifications
You must be signed in to change notification settings - Fork 798
Added properties 'ssl_type' and 'ssl_cipher' to mysql_user to enable … #792
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,16 +14,16 @@ def self.instances | |
| users.collect do |name| | ||
| if mysqld_version.nil? | ||
| ## Default ... | ||
| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" | ||
| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD, SSL_TYPE, SSL_CIPHER /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" | ||
| else | ||
| if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 | ||
| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" | ||
| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, AUTHENTICATION_STRING, SSL_TYPE, SSL_CIPHER, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" | ||
| else | ||
| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" | ||
| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD, SSL_TYPE, SSL_CIPHER /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" | ||
| end | ||
| end | ||
| @max_user_connections, @max_connections_per_hour, @max_queries_per_hour, | ||
| @max_updates_per_hour, @password, @plugin = mysql([defaults_file, "-NBe", query].compact).split(/\s/) | ||
| @max_updates_per_hour, @password, @ssl_type, @ssl_cipher, @plugin = mysql([defaults_file, "-NBe", query].compact).split(/\s/) | ||
|
|
||
| new(:name => name, | ||
| :ensure => :present, | ||
|
|
@@ -32,7 +32,9 @@ def self.instances | |
| :max_user_connections => @max_user_connections, | ||
| :max_connections_per_hour => @max_connections_per_hour, | ||
| :max_queries_per_hour => @max_queries_per_hour, | ||
| :max_updates_per_hour => @max_updates_per_hour | ||
| :max_updates_per_hour => @max_updates_per_hour, | ||
| :ssl_type => @ssl_type, | ||
| :ssl_cipher => @ssl_cipher | ||
| ) | ||
| end | ||
| end | ||
|
|
@@ -56,6 +58,8 @@ def create | |
| max_connections_per_hour = @resource.value(:max_connections_per_hour) || 0 | ||
| max_queries_per_hour = @resource.value(:max_queries_per_hour) || 0 | ||
| max_updates_per_hour = @resource.value(:max_updates_per_hour) || 0 | ||
| ssl_type = @resource.value(:ssl_type) | ||
| ssl_cipher = @resource.value(:ssl_cipher) | ||
|
|
||
| # Use CREATE USER to be compatible with NO_AUTO_CREATE_USER sql_mode | ||
| # This is also required if you want to specify a authentication plugin | ||
|
|
@@ -72,11 +76,24 @@ def create | |
| @property_hash[:ensure] = :present | ||
| @property_hash[:password_hash] = password_hash | ||
| end | ||
| mysql([defaults_file, '-e', "GRANT USAGE ON *.* TO '#{merged_name}' WITH MAX_USER_CONNECTIONS #{max_user_connections} MAX_CONNECTIONS_PER_HOUR #{max_connections_per_hour} MAX_QUERIES_PER_HOUR #{max_queries_per_hour} MAX_UPDATES_PER_HOUR #{max_updates_per_hour}"].compact) | ||
| grant_require = case ssl_type | ||
| when 'ANY' then 'SSL' | ||
| when 'SPECIFIED' then 'SSL' | ||
| when 'X509' then 'X509' | ||
| when '' then 'NONE' | ||
| else raise Puppet::Error, "Non-supported SSL-type #{ssl_type}" | ||
| end | ||
| if !ssl_cipher.empty? | ||
| grant_require << " AND CIPHER '#{ssl_cipher}'" | ||
| end | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't understand why you're validating this here, rather than in the type. |
||
|
|
||
| mysql([defaults_file, '-e', "GRANT USAGE ON *.* TO '#{merged_name}' REQUIRE #{grant_require} WITH MAX_USER_CONNECTIONS #{max_user_connections} MAX_CONNECTIONS_PER_HOUR #{max_connections_per_hour} MAX_QUERIES_PER_HOUR #{max_queries_per_hour} MAX_UPDATES_PER_HOUR #{max_updates_per_hour}"].compact) | ||
| @property_hash[:max_user_connections] = max_user_connections | ||
| @property_hash[:max_connections_per_hour] = max_connections_per_hour | ||
| @property_hash[:max_queries_per_hour] = max_queries_per_hour | ||
| @property_hash[:max_updates_per_hour] = max_updates_per_hour | ||
| @property_hash[:ssl_type] = ssl_type | ||
| @property_hash[:ssl_cipher] = ssl_cipher | ||
|
|
||
| exists? ? (return true) : (return false) | ||
| end | ||
|
|
@@ -152,4 +169,25 @@ def max_updates_per_hour=(int) | |
| max_updates_per_hour == int ? (return true) : (return false) | ||
| end | ||
|
|
||
| def ssl_type=(string) | ||
| merged_name = self.class.cmd_user(@resource[:name]) | ||
| ssl_require = case string | ||
| when 'ANY' then 'SSL' | ||
| when 'SPECIFIED' then 'SSL' | ||
| when 'X509' then 'X509' | ||
| when '' then 'NONE' | ||
| else raise Puppet::Error, "Non-supported SSL-type #{string}" | ||
| end | ||
| mysql([defaults_file, '-e', "GRANT USAGE ON *.* TO #{merged_name} REQUIRE #{ssl_require}"].compact).chomp | ||
|
|
||
| ssl_type == string ? (return true) : (return false) | ||
| end | ||
|
|
||
| def ssl_cipher=(string) | ||
| merged_name = self.class.cmd_user(@resource[:name]) | ||
| mysql([defaults_file, '-e', "GRANT USAGE ON *.* TO #{merged_name} REQUIRE CIPHER '#{string}'"].compact).chomp | ||
|
|
||
| ssl_cipher == string ? (return true) : (return false) | ||
| end | ||
|
|
||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this need an annotation like
PLUGIN? since when has that been available?