Changeset - 1aa1655bf019
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 15 years ago 2011-03-15 23:34:14
marcin@python-works.com
fixed some config bool converter problems with ldap
3 files changed with 18 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/__init__.py
Show inline comments
 
@@ -26,7 +26,16 @@
 
# MA  02110-1301, USA.
 

	
 
def str2bool(v):
 
    return v.lower() in ["yes", "true", "t", "1"] if v else None
 
    if isinstance(v, (str, unicode)):
 
        obj = v.strip().lower()
 
        if obj in ['true', 'yes', 'on', 'y', 't', '1']:
 
            return True
 
        elif obj in ['false', 'no', 'off', 'n', 'f', '0']:
 
            return False
 
        else:
 
            if not safe:
 
                raise ValueError("String is not true/false: %r" % obj)
 
    return bool(obj)
 

	
 
def generate_api_key(username, salt=None):
 
    from tempfile import _RandomNameSequence
rhodecode/lib/auth.py
Show inline comments
 
@@ -43,7 +43,7 @@ if __platform__ == 'Windows':
 
if __platform__ in ('Linux', 'Darwin'):
 
    import bcrypt
 

	
 

	
 
from rhodecode.lib import str2bool
 
from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError
 
from rhodecode.lib.utils import get_repo_slug
 
from rhodecode.lib.auth_ldap import AuthLdap
 
@@ -179,7 +179,7 @@ def authenticate(username, password):
 
        #======================================================================
 
        # FALLBACK TO LDAP AUTH IF ENABLE                
 
        #======================================================================
 
        if ldap_settings.get('ldap_active', False):
 
        if str2bool(ldap_settings.get('ldap_active')):
 
            log.debug("Authenticating user using ldap")
 
            kwargs = {
 
                  'server':ldap_settings.get('ldap_host', ''),
 
@@ -187,7 +187,7 @@ def authenticate(username, password):
 
                  'port':ldap_settings.get('ldap_port'),
 
                  'bind_dn':ldap_settings.get('ldap_dn_user'),
 
                  'bind_pass':ldap_settings.get('ldap_dn_pass'),
 
                  'use_ldaps':ldap_settings.get('ldap_ldaps'),
 
                  'use_ldaps':str2bool(ldap_settings.get('ldap_ldaps')),
 
                  'tls_reqcert':ldap_settings.get('ldap_tls_reqcert'),
 
                  'ldap_filter':ldap_settings.get('ldap_filter'),
 
                  'search_scope':ldap_settings.get('ldap_search_scope'),
rhodecode/model/settings.py
Show inline comments
 
@@ -95,8 +95,11 @@ class SettingsModel(BaseModel):
 

	
 
        for row in r:
 
            v = row.app_settings_value
 
            if v in ['0', '1']:
 
                v = v == '1'
 
            if v in ['true', 'yes', 'on', 'y', 't', '1']:
 
                v = True
 
            elif v in ['false', 'no', 'off', 'n', 'f', '0']:
 
                v = False
 

	
 
            fd.update({row.app_settings_name:v})
 

	
 
        return fd
0 comments (0 inline, 0 general)