Show More
@@ -26,7 +26,16 b'' | |||
|
26 | 26 | # MA 02110-1301, USA. |
|
27 | 27 | |
|
28 | 28 | def str2bool(v): |
|
29 | return v.lower() in ["yes", "true", "t", "1"] if v else None | |
|
29 | if isinstance(v, (str, unicode)): | |
|
30 | obj = v.strip().lower() | |
|
31 | if obj in ['true', 'yes', 'on', 'y', 't', '1']: | |
|
32 | return True | |
|
33 | elif obj in ['false', 'no', 'off', 'n', 'f', '0']: | |
|
34 | return False | |
|
35 | else: | |
|
36 | if not safe: | |
|
37 | raise ValueError("String is not true/false: %r" % obj) | |
|
38 | return bool(obj) | |
|
30 | 39 | |
|
31 | 40 | def generate_api_key(username, salt=None): |
|
32 | 41 | from tempfile import _RandomNameSequence |
@@ -43,7 +43,7 b" if __platform__ == 'Windows':" | |||
|
43 | 43 | if __platform__ in ('Linux', 'Darwin'): |
|
44 | 44 | import bcrypt |
|
45 | 45 | |
|
46 | ||
|
46 | from rhodecode.lib import str2bool | |
|
47 | 47 | from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError |
|
48 | 48 | from rhodecode.lib.utils import get_repo_slug |
|
49 | 49 | from rhodecode.lib.auth_ldap import AuthLdap |
@@ -179,7 +179,7 b' def authenticate(username, password):' | |||
|
179 | 179 | #====================================================================== |
|
180 | 180 | # FALLBACK TO LDAP AUTH IF ENABLE |
|
181 | 181 | #====================================================================== |
|
182 |
if ldap_settings.get('ldap_active' |
|
|
182 | if str2bool(ldap_settings.get('ldap_active')): | |
|
183 | 183 | log.debug("Authenticating user using ldap") |
|
184 | 184 | kwargs = { |
|
185 | 185 | 'server':ldap_settings.get('ldap_host', ''), |
@@ -187,7 +187,7 b' def authenticate(username, password):' | |||
|
187 | 187 | 'port':ldap_settings.get('ldap_port'), |
|
188 | 188 | 'bind_dn':ldap_settings.get('ldap_dn_user'), |
|
189 | 189 | 'bind_pass':ldap_settings.get('ldap_dn_pass'), |
|
190 | 'use_ldaps':ldap_settings.get('ldap_ldaps'), | |
|
190 | 'use_ldaps':str2bool(ldap_settings.get('ldap_ldaps')), | |
|
191 | 191 | 'tls_reqcert':ldap_settings.get('ldap_tls_reqcert'), |
|
192 | 192 | 'ldap_filter':ldap_settings.get('ldap_filter'), |
|
193 | 193 | 'search_scope':ldap_settings.get('ldap_search_scope'), |
@@ -95,8 +95,11 b' class SettingsModel(BaseModel):' | |||
|
95 | 95 | |
|
96 | 96 | for row in r: |
|
97 | 97 | v = row.app_settings_value |
|
98 |
if v in [' |
|
|
99 |
v = |
|
|
98 | if v in ['true', 'yes', 'on', 'y', 't', '1']: | |
|
99 | v = True | |
|
100 | elif v in ['false', 'no', 'off', 'n', 'f', '0']: | |
|
101 | v = False | |
|
102 | ||
|
100 | 103 | fd.update({row.app_settings_name:v}) |
|
101 | 104 | |
|
102 | 105 | return fd |
General Comments 0
You need to be logged in to leave comments.
Login now