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