Skip to content

Commit ccf37e7

Browse files
committed
Revert "Support for authentication plugins"
1 parent 1a87bae commit ccf37e7

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

lib/puppet/provider/mysql_user/mysql.rb

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ def self.instances
1212
# To reduce the number of calls to MySQL we collect all the properties in
1313
# one big swoop.
1414
users.collect do |name|
15-
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
15+
query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'"
1616
@max_user_connections, @max_connections_per_hour, @max_queries_per_hour,
17-
@max_updates_per_hour, @password, @plugin = mysql([defaults_file, "-NBe", query].compact).split(/\s/)
17+
@max_updates_per_hour, @password = mysql([defaults_file, "-NBe", query].compact).split(/\s/)
1818

1919
new(:name => name,
2020
:ensure => :present,
2121
:password_hash => @password,
22-
:plugin => @plugin,
2322
:max_user_connections => @max_user_connections,
2423
:max_connections_per_hour => @max_connections_per_hour,
2524
:max_queries_per_hour => @max_queries_per_hour,
@@ -40,26 +39,17 @@ def self.prefetch(resources)
4039
end
4140

4241
def create
43-
merged_name = @resource[:name].sub('@', "'@'")
42+
merged_name = @resource[:name].sub('@', "'@'")
4443
password_hash = @resource.value(:password_hash)
45-
plugin = @resource.value(:plugin)
4644
max_user_connections = @resource.value(:max_user_connections) || 0
4745
max_connections_per_hour = @resource.value(:max_connections_per_hour) || 0
4846
max_queries_per_hour = @resource.value(:max_queries_per_hour) || 0
4947
max_updates_per_hour = @resource.value(:max_updates_per_hour) || 0
5048

51-
# Use CREATE USER to be compatible with NO_AUTO_CREATE_USER sql_mode
52-
# This is also required if you want to specify a authentication plugin
53-
if !plugin.nil?
54-
mysql([defaults_file, '-e', "CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}'"].compact)
55-
@property_hash[:ensure] = :present
56-
@property_hash[:plugin] = plugin
57-
else
58-
mysql([defaults_file, '-e', "CREATE USER '#{merged_name}' IDENTIFIED BY PASSWORD '#{password_hash}'"].compact)
59-
@property_hash[:ensure] = :present
60-
@property_hash[:password_hash] = password_hash
61-
end
62-
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)
49+
mysql([defaults_file, '-e', "GRANT USAGE ON *.* TO '#{merged_name}' IDENTIFIED BY PASSWORD '#{password_hash}' 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)
50+
51+
@property_hash[:ensure] = :present
52+
@property_hash[:password_hash] = password_hash
6353
@property_hash[:max_user_connections] = max_user_connections
6454
@property_hash[:max_connections_per_hour] = max_connections_per_hour
6555
@property_hash[:max_queries_per_hour] = max_queries_per_hour

lib/puppet/type/mysql_user.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040
newvalue(/\w+/)
4141
end
4242

43-
newproperty(:plugin) do
44-
desc 'The authentication plugin of the user.'
45-
newvalue(/\w+/)
46-
end
47-
4843
newproperty(:max_user_connections) do
4944
desc "Max concurrent connections for the user. 0 means no (or global) limit."
5045
newvalue(/\d+/)

spec/unit/puppet/provider/mysql_user/mysql_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql')
3838
File.stubs(:file?).with('/root/.my.cnf').returns(true)
3939
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns('joe@localhost')
40-
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4')
40+
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4')
4141
end
4242

4343
let(:instance) { provider.class.instances.first }
@@ -46,7 +46,7 @@
4646
it 'returns an array of users' do
4747
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users)
4848
parsed_users.each do |user|
49-
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ')
49+
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ')
5050
end
5151

5252
usernames = provider.class.instances.collect {|x| x.name }
@@ -63,8 +63,7 @@
6363

6464
describe 'create' do
6565
it 'makes a user' do
66-
provider.expects(:mysql).with([defaults_file, '-e', "CREATE USER 'joe'@'localhost' IDENTIFIED BY PASSWORD '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'"])
67-
provider.expects(:mysql).with([defaults_file, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' WITH MAX_USER_CONNECTIONS 10 MAX_CONNECTIONS_PER_HOUR 10 MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 10"])
66+
provider.expects(:mysql).with([defaults_file, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' IDENTIFIED BY PASSWORD '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4' WITH MAX_USER_CONNECTIONS 10 MAX_CONNECTIONS_PER_HOUR 10 MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 10"])
6867
provider.expects(:exists?).returns(true)
6968
expect(provider.create).to be_truthy
7069
end

tests/mysql_user.pp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,3 @@
1919
ensure => present,
2020
password_hash => mysql_password('blah'),
2121
}
22-
23-
mysql_user{ 'socketplugin@%':
24-
ensure => present,
25-
plugin => 'unix_socket',
26-
}
27-
28-
mysql_user{ 'socketplugin@%':
29-
ensure => present,
30-
password_hash => mysql_password('blah'),
31-
plugin => 'mysql_native_password',
32-
}

0 commit comments

Comments
 (0)