Skip to content

Commit

Permalink
Validate user paswwords per run
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarl Stefansson authored and Colleen Murphy committed Dec 15, 2014
1 parent ecd7447 commit 1f11596
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ def create
end
end

def change_password
rabbitmqctl('change_password', resource[:name], resource[:password])
end

def password
nil
end


def check_password
responce = rabbitmqctl('eval', 'rabbit_auth_backend_internal:check_user_login(<<"' + resource[:name] + '">>, [{password, <<"' + resource[:password] +'">>}]).')
if responce.include? 'invalid credentials'
false
else
true
end
end

def destroy
rabbitmqctl('delete_user', resource[:name])
end
Expand Down
11 changes: 8 additions & 3 deletions lib/puppet/type/rabbitmq_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
newvalues(/^\S+$/)
end

# newproperty(:password) do
newparam(:password) do
desc 'User password to be set *on creation*'
newproperty(:password) do
desc 'User password to be set *on creation* and validated each run'
def insync?(is)
provider.check_password
end
def set(value)
provider.change_password
end
end

newproperty(:admin) do
Expand Down

0 comments on commit 1f11596

Please sign in to comment.