Skip to content

Commit 1f11596

Browse files
Jarl StefanssonColleen Murphy
authored andcommitted
Validate user paswwords per run
1 parent ecd7447 commit 1f11596

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ def create
3232
end
3333
end
3434

35+
def change_password
36+
rabbitmqctl('change_password', resource[:name], resource[:password])
37+
end
38+
39+
def password
40+
nil
41+
end
42+
43+
44+
def check_password
45+
responce = rabbitmqctl('eval', 'rabbit_auth_backend_internal:check_user_login(<<"' + resource[:name] + '">>, [{password, <<"' + resource[:password] +'">>}]).')
46+
if responce.include? 'invalid credentials'
47+
false
48+
else
49+
true
50+
end
51+
end
52+
3553
def destroy
3654
rabbitmqctl('delete_user', resource[:name])
3755
end

lib/puppet/type/rabbitmq_user.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
newvalues(/^\S+$/)
1919
end
2020

21-
# newproperty(:password) do
22-
newparam(:password) do
23-
desc 'User password to be set *on creation*'
21+
newproperty(:password) do
22+
desc 'User password to be set *on creation* and validated each run'
23+
def insync?(is)
24+
provider.check_password
25+
end
26+
def set(value)
27+
provider.change_password
28+
end
2429
end
2530

2631
newproperty(:admin) do

0 commit comments

Comments
 (0)