Show More
@@ -49,7 +49,7 b' from rhodecode.model.db import (' | |||||
49 | User, Repository, Permission, UserToPerm, UserGroupToPerm, UserGroupMember, |
|
49 | User, Repository, Permission, UserToPerm, UserGroupToPerm, UserGroupMember, | |
50 | UserIpMap, UserApiKeys, RepoGroup, UserGroup) |
|
50 | UserIpMap, UserApiKeys, RepoGroup, UserGroup) | |
51 | from rhodecode.lib import caches |
|
51 | from rhodecode.lib import caches | |
52 | from rhodecode.lib.utils2 import safe_unicode, aslist, safe_str, md5, safe_int |
|
52 | from rhodecode.lib.utils2 import safe_unicode, aslist, safe_str, md5, safe_int, sha1 | |
53 | from rhodecode.lib.utils import ( |
|
53 | from rhodecode.lib.utils import ( | |
54 | get_repo_slug, get_repo_group_slug, get_user_group_slug) |
|
54 | get_repo_slug, get_repo_group_slug, get_user_group_slug) | |
55 | from rhodecode.lib.caching_query import FromCache |
|
55 | from rhodecode.lib.caching_query import FromCache | |
@@ -210,12 +210,12 b' class _RhodeCodeCryptoSha256(_RhodeCodeC' | |||||
210 | return hashlib.sha256(password).hexdigest() == hashed |
|
210 | return hashlib.sha256(password).hexdigest() == hashed | |
211 |
|
211 | |||
212 |
|
212 | |||
213 |
class _RhodeCodeCrypto |
|
213 | class _RhodeCodeCryptoTest(_RhodeCodeCryptoBase): | |
214 | ENC_PREF = '_' |
|
214 | ENC_PREF = '_' | |
215 |
|
215 | |||
216 | def hash_create(self, str_): |
|
216 | def hash_create(self, str_): | |
217 | self._assert_bytes(str_) |
|
217 | self._assert_bytes(str_) | |
218 |
return |
|
218 | return sha1(str_) | |
219 |
|
219 | |||
220 | def hash_check(self, password, hashed): |
|
220 | def hash_check(self, password, hashed): | |
221 | """ |
|
221 | """ | |
@@ -225,18 +225,18 b' class _RhodeCodeCryptoMd5(_RhodeCodeCryp' | |||||
225 | :param hashed: password in hashed form |
|
225 | :param hashed: password in hashed form | |
226 | """ |
|
226 | """ | |
227 | self._assert_bytes(password) |
|
227 | self._assert_bytes(password) | |
228 |
return |
|
228 | return sha1(password) == hashed | |
229 |
|
229 | |||
230 |
|
230 | |||
231 | def crypto_backend(): |
|
231 | def crypto_backend(): | |
232 | """ |
|
232 | """ | |
233 | Return the matching crypto backend. |
|
233 | Return the matching crypto backend. | |
234 |
|
234 | |||
235 |
Selection is based on if we run tests or not, we pick |
|
235 | Selection is based on if we run tests or not, we pick sha1-test backend to run | |
236 | tests faster since BCRYPT is expensive to calculate |
|
236 | tests faster since BCRYPT is expensive to calculate | |
237 | """ |
|
237 | """ | |
238 | if rhodecode.is_test: |
|
238 | if rhodecode.is_test: | |
239 |
RhodeCodeCrypto = _RhodeCodeCrypto |
|
239 | RhodeCodeCrypto = _RhodeCodeCryptoTest() | |
240 | else: |
|
240 | else: | |
241 | RhodeCodeCrypto = _RhodeCodeCryptoBCrypt() |
|
241 | RhodeCodeCrypto = _RhodeCodeCryptoBCrypt() | |
242 |
|
242 |
@@ -75,7 +75,7 b' def test_hash_check_with_update_enforces' | |||||
75 |
|
75 | |||
76 |
|
76 | |||
77 | @pytest.fixture(params=[ |
|
77 | @pytest.fixture(params=[ | |
78 |
auth._RhodeCodeCrypto |
|
78 | auth._RhodeCodeCryptoTest, | |
79 | auth._RhodeCodeCryptoBCrypt, |
|
79 | auth._RhodeCodeCryptoBCrypt, | |
80 | auth._RhodeCodeCryptoSha256, |
|
80 | auth._RhodeCodeCryptoSha256, | |
81 | ]) |
|
81 | ]) |
General Comments 0
You need to be logged in to leave comments.
Login now