Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

Commit

Permalink
added encrypted_password param when creating user
Browse files Browse the repository at this point in the history
  • Loading branch information
cmer committed Aug 10, 2012
1 parent 6fb2dcb commit 83fd7ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -49,6 +49,12 @@ pg_user "myuser" do
password "mypassword"
end

# create a user with an MD5-encrypted password
pg_user "myuser" do
privileges :superuser => false, :createdb => false, :login => true
encrypted_password "667ff118ef6d196c96313aeaee7da519"
end

# drop a user
pg_user "myuser" do
action :drop
Expand Down Expand Up @@ -453,4 +459,4 @@ Many thanks go to the following who have contributed to making this cookbook eve

* Freely distributable and licensed under the [MIT license](http://phlipper.mit-license.org/2012/license.html).
* Copyright (c) 2012 Phil Cohen (github@phlippers.net) [![endorse](http://api.coderwall.com/phlipper/endorsecount.png)](http://coderwall.com/phlipper)
* http://phlippers.net/
* http://phlippers.net/
12 changes: 7 additions & 5 deletions definitions/pg_user.rb
Expand Up @@ -7,12 +7,14 @@
:login => true
}
privileges.merge! params[:privileges] if params[:privileges]

sql = [params[:name]]

sql.push privileges.to_a.map! { |p,b| (b ? '' : 'NO') + p.to_s.upcase }.join ' '

if params[:password]
if params[:encrypted_password]
sql.push "ENCRYPTED PASSWORD '#{params[:encrypted_password]}'"
elsif params[:password]
sql.push "PASSWORD '#{params[:password]}'"
end

Expand All @@ -24,7 +26,7 @@

execute "altering pg user #{params[:name]}" do
user "postgres"
command "psql -c \"ALTER ROLE #{sql}\""
command "psql -c \"ALTER ROLE #{sql}\""
only_if exists, :user => "postgres"
end

Expand All @@ -40,4 +42,4 @@
command "psql -c \"DROP ROLE IF EXISTS #{params[:name]}\""
end
end
end
end

0 comments on commit 83fd7ec

Please sign in to comment.