Show More
@@ -46,10 +46,10 b' except ImportError:' | |||||
46 | __url__ = 'http://rhodecode.org' |
|
46 | __url__ = 'http://rhodecode.org' | |
47 |
|
47 | |||
48 | PLATFORM_WIN = ('Windows') |
|
48 | PLATFORM_WIN = ('Windows') | |
49 | PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS') |
|
49 | PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS') #depracated | |
50 |
|
50 | |||
51 | is_windows = __platform__ in PLATFORM_WIN |
|
51 | is_windows = __platform__ in PLATFORM_WIN | |
52 | is_unix = __platform__ in PLATFORM_OTHERS |
|
52 | is_unix = not is_windows | |
53 |
|
53 | |||
54 |
|
54 | |||
55 | BACKENDS = { |
|
55 | BACKENDS = { |
@@ -35,7 +35,7 b' from pylons import config, url, request' | |||||
35 | from pylons.controllers.util import abort, redirect |
|
35 | from pylons.controllers.util import abort, redirect | |
36 | from pylons.i18n.translation import _ |
|
36 | from pylons.i18n.translation import _ | |
37 |
|
37 | |||
38 |
from rhodecode import __platform__, |
|
38 | from rhodecode import __platform__, is_windows, is_unix | |
39 | from rhodecode.model.meta import Session |
|
39 | from rhodecode.model.meta import Session | |
40 |
|
40 | |||
41 | from rhodecode.lib.utils2 import str2bool, safe_unicode |
|
41 | from rhodecode.lib.utils2 import str2bool, safe_unicode | |
@@ -92,10 +92,10 b' class RhodeCodeCrypto(object):' | |||||
92 |
|
92 | |||
93 | :param password: password to hash |
|
93 | :param password: password to hash | |
94 | """ |
|
94 | """ | |
95 | if __platform__ in PLATFORM_WIN: |
|
95 | if is_windows: | |
96 | from hashlib import sha256 |
|
96 | from hashlib import sha256 | |
97 | return sha256(str_).hexdigest() |
|
97 | return sha256(str_).hexdigest() | |
98 | elif __platform__ in PLATFORM_OTHERS: |
|
98 | elif is_unix: | |
99 | import bcrypt |
|
99 | import bcrypt | |
100 | return bcrypt.hashpw(str_, bcrypt.gensalt(10)) |
|
100 | return bcrypt.hashpw(str_, bcrypt.gensalt(10)) | |
101 | else: |
|
101 | else: | |
@@ -112,10 +112,10 b' class RhodeCodeCrypto(object):' | |||||
112 | :param hashed: password in hashed form |
|
112 | :param hashed: password in hashed form | |
113 | """ |
|
113 | """ | |
114 |
|
114 | |||
115 | if __platform__ in PLATFORM_WIN: |
|
115 | if is_windows: | |
116 | from hashlib import sha256 |
|
116 | from hashlib import sha256 | |
117 | return sha256(password).hexdigest() == hashed |
|
117 | return sha256(password).hexdigest() == hashed | |
118 | elif __platform__ in PLATFORM_OTHERS: |
|
118 | elif is_unix: | |
119 | import bcrypt |
|
119 | import bcrypt | |
120 | return bcrypt.hashpw(password, hashed) == hashed |
|
120 | return bcrypt.hashpw(password, hashed) == hashed | |
121 | else: |
|
121 | else: | |
@@ -235,7 +235,7 b' def authenticate(username, password):' | |||||
235 | user_attrs): |
|
235 | user_attrs): | |
236 | log.info('created new ldap user %s' % username) |
|
236 | log.info('created new ldap user %s' % username) | |
237 |
|
237 | |||
238 | Session.commit() |
|
238 | Session().commit() | |
239 | return True |
|
239 | return True | |
240 | except (LdapUsernameError, LdapPasswordError,): |
|
240 | except (LdapUsernameError, LdapPasswordError,): | |
241 | pass |
|
241 | pass | |
@@ -262,7 +262,7 b' def login_container_auth(username):' | |||||
262 | return None |
|
262 | return None | |
263 |
|
263 | |||
264 | user.update_lastlogin() |
|
264 | user.update_lastlogin() | |
265 | Session.commit() |
|
265 | Session().commit() | |
266 |
|
266 | |||
267 | log.debug('User %s is now logged in by container authentication', |
|
267 | log.debug('User %s is now logged in by container authentication', | |
268 | user.username) |
|
268 | user.username) | |
@@ -768,7 +768,7 b' class HasReposGroupPermissionAny(PermsFu' | |||||
768 | class HasReposGroupPermissionAll(PermsFunction): |
|
768 | class HasReposGroupPermissionAll(PermsFunction): | |
769 | def __call__(self, group_name=None, check_Location=''): |
|
769 | def __call__(self, group_name=None, check_Location=''): | |
770 | self.group_name = group_name |
|
770 | self.group_name = group_name | |
771 |
return super(HasReposGroupPermissionA |
|
771 | return super(HasReposGroupPermissionAll, self).__call__(check_Location) | |
772 |
|
772 | |||
773 | def check_permissions(self): |
|
773 | def check_permissions(self): | |
774 | try: |
|
774 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now