Commit 12f72c8b authored by Sjoerd Simons's avatar Sjoerd Simons Committed by Andrew Lee (李健秋)
Browse files

Add patch to support crypted passwords


Signed-off-by: Sjoerd Simons's avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
parent 5f6e4faa
From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Date: Mon, 20 Feb 2017 10:40:34 +0100
Subject: Add support for md5 and sha256 cypted() passwords
In some of our deployments we synchronize passwords as crypted by the
standard unix crypt into the OBS accounts database. This patch adds
support for the OBS side to recognize/support md5 and sha256 crypted
passwords, sha512 should be trivial to add but needs a database schema
update (the password_crypted is too small)
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---
src/api/app/models/user.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/api/app/models/user.rb b/src/api/app/models/user.rb
index 44f44e0..3cfa026 100644
--- a/src/api/app/models/user.rb
+++ b/src/api/app/models/user.rb
@@ -1026,7 +1026,7 @@ class User < ActiveRecord::Base
# This method returns an array which contains all valid hash types.
def self.default_password_hash_types
- %w(md5)
+ %w(md5, md5crypt, sha256crypt)
end
def self.update_notifications(params, user = nil)
@@ -1058,8 +1058,12 @@ class User < ActiveRecord::Base
# Hashes the given parameter by the selected hashing method. It uses the
# "password_salt" property's value to make the hashing more secure.
def hash_string(value)
+ crypt2index = { "md5crypt" => 1,
+ "sha256crypt" => 5 }
if password_hash_type == "md5"
- Digest::MD5.hexdigest(value + self.password_salt)
+ Digest::MD5.hexdigest(value + password_salt)
+ elsif crypt2index.keys.include?(password_hash_type)
+ value.crypt("$#{crypt2index[password_hash_type]}$#{password_salt}$").split("$")[3]
end
end
......@@ -23,3 +23,4 @@ BSConfig.pm.template_include_a_skeleton_reprepro.patch
Include_ddebs_in_reprepro_too_and_fix_inclusion_of_udebs.patch
bs_publish_improve-logging_for_reprepro_invocations.patch
publisher_reprepro_set_surprising_binary.patch
Add-support-for-md5-and-sha256-cypted-passwords.patch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment