Skip to content
Browse files

added encrypted_password param when creating user

  • Loading branch information...
1 parent 6fb2dcb commit 83fd7ec21a6c3b6213f6bb31595586f82a21101c @cmer cmer committed
Showing with 14 additions and 6 deletions.
  1. +7 −1 README.md
  2. +7 −5 definitions/pg_user.rb
View
8 README.md
@@ -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
@@ -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/
View
12 definitions/pg_user.rb
@@ -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
@@ -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
@@ -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.
Something went wrong with that request. Please try again.