Skip to content
Snippets Groups Projects
Commit 04ce1968 authored by Sjoerd Simons's avatar Sjoerd Simons
Browse files

Add patch to support crypted passwords

parent c7b3eec0
No related branches found
No related tags found
No related merge requests found
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 ...@@ -23,3 +23,4 @@ BSConfig.pm.template_include_a_skeleton_reprepro.patch
Include_ddebs_in_reprepro_too_and_fix_inclusion_of_udebs.patch Include_ddebs_in_reprepro_too_and_fix_inclusion_of_udebs.patch
bs_publish_improve-logging_for_reprepro_invocations.patch bs_publish_improve-logging_for_reprepro_invocations.patch
publisher_reprepro_set_surprising_binary.patch publisher_reprepro_set_surprising_binary.patch
Add-support-for-md5-and-sha256-cypted-passwords.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment