Skip to content

Commit

Permalink
Merge pull request redhat-openstack#275 from cmurphy/change_password
Browse files Browse the repository at this point in the history
(MODULES-1085) Allow changing of user password
  • Loading branch information
hunner committed Dec 16, 2014
2 parents edd56fb + ecd4120 commit e1aab42
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb
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
response = rabbitmqctl('eval', 'rabbit_auth_backend_internal:check_user_login(<<"' + resource[:name] + '">>, [{password, <<"' + resource[:password] +'">>}]).')
if response.include? 'invalid credentials'
false
else
true
end
end

def destroy
rabbitmqctl('delete_user', resource[:name])
end
Expand Down
14 changes: 11 additions & 3 deletions lib/puppet/type/rabbitmq_user.rb
Expand Up @@ -18,9 +18,17 @@
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
def change_to_s(current, desired)
"password has been changed"
end
end

newproperty(:admin) do
Expand Down

0 comments on commit e1aab42

Please sign in to comment.