Skip to content

Commit 76d8480

Browse files
author
Johan De Wit
committed
[x509 user] Use $external db for this type of users
1 parent f1062ad commit 76d8480

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

lib/puppet/provider/mongodb_user/mongodb.rb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,27 @@ def create
5858
roles: role_hashes(@resource[:roles], @resource[:database]),
5959
}
6060

61-
# is this still needed / we only support verion 4 and higher
62-
if mongo_4? || mongo_5? || mongo_6?
63-
case @resource[:auth_mechanism]
64-
when :scram_sha_256 # rubocop:disable Naming/VariableNumber
65-
command[:mechanisms] = ['SCRAM-SHA-256']
66-
command[:pwd] = @resource[:password]
67-
command[:digestPassword] = true
68-
when :scram_sha_1 # rubocop:disable Naming/VariableNumber
69-
command[:mechanisms] = ['SCRAM-SHA-1']
70-
command[:pwd] = password_hash
71-
command[:digestPassword] = false
72-
when :x509
73-
command[:mechanisms] = ['MONGODB-X509']
74-
else
75-
command[:pwd] = password_hash
76-
command[:digestPassword] = false
77-
78-
end
61+
case @resource[:auth_mechanism]
62+
when :scram_sha_256 # rubocop:disable Naming/VariableNumber
63+
command[:mechanisms] = ['SCRAM-SHA-256']
64+
command[:pwd] = @resource[:password]
65+
command[:digestPassword] = true
66+
when :scram_sha_1 # rubocop:disable Naming/VariableNumber
67+
command[:mechanisms] = ['SCRAM-SHA-1']
68+
command[:pwd] = password_hash
69+
command[:digestPassword] = false
70+
when :x509
71+
command[:mechanisms] = ['MONGODB-X509']
72+
else
73+
command[:pwd] = password_hash
74+
command[:digestPassword] = false
7975
end
8076

81-
Puppet.debug("XXXXXXXXXX about to create user with command: #{command}")
8277
if @resource[:auth_mechanism] == :x509
78+
Puppet.debug("XXXXXXXXXX about to create X509 user with command: #{command}")
8379
mongo_eval("db.getSiblingDB(\"$external\").runCommand(#{command.to_json}}", @resource[:database])
8480
else
81+
Puppet.debug("XXXXXXXXXX about to create regular user with command: #{command}")
8582
mongo_eval("db.runCommand(#{command.to_json})", @resource[:database])
8683
end
8784
else

0 commit comments

Comments
 (0)