Sfoglia il codice sorgente

[desktop] Empty passwords should fall back to the password_script

Before this patch, *PASSWORD values would take precedence over
*PASSWORD_SCRIPTS, unless they were undefined (as represented with
a `None`). This change further limits *PASSWORD values to only take
precendence if they are non-empty.
Erick Tryzelaar 10 anni fa
parent
commit
294cb6c

+ 1 - 1
desktop/core/src/desktop/auth/backend.py

@@ -366,7 +366,7 @@ class LdapBackend(object):
         setattr(self._backend.settings, 'BIND_DN', bind_dn)
 
         bind_password = ldap_config.BIND_PASSWORD.get()
-        if bind_password is None:
+        if not bind_password:
           password = ldap_config.BIND_PASSWORD_SCRIPT.get()
         setattr(self._backend.settings, 'BIND_PASSWORD', bind_password)
 

+ 12 - 12
desktop/core/src/desktop/conf.py

@@ -143,14 +143,14 @@ CHERRYPY_SERVER_THREADS = Config(
 SECRET_KEY = Config(
   key="secret_key",
   help=_("Used in hashing algorithms for sessions."),
-  default=None)
+  default="")
 
 SECRET_KEY_SCRIPT = Config(
   key="secret_key_script",
   help=_("Execute this script to produce the Django secret key. This will be used when `secret_key` is not set."),
   type=coerce_password_from_script,
   private=True,
-  default=None)
+  default="")
 
 USER_ACCESS_HISTORY_SIZE = Config(
   key="user_access_history_size",
@@ -280,7 +280,7 @@ SMTP = ConfigSection(
       help=_("The password for the SMTP user."),
       type=str,
       private=True,
-      default=None,
+      default="",
     ),
 
     PASSWORD_SCRIPT = Config(
@@ -288,7 +288,7 @@ SMTP = ConfigSection(
       help=_("Execute this script to produce the SMTP user password. This will be used when the SMTP `password` is not set."),
       type=coerce_password_from_script,
       private=True,
-      default=None,
+      default="",
     ),
 
     USE_TLS = Config(
@@ -335,14 +335,14 @@ DATABASE = ConfigSection(
       help=_('Database password.'),
       private=True,
       type=str,
-      default=None,
+      default="",
     ),
     PASSWORD_SCRIPT=Config(
       key='password_script',
       help=_('Execute this script to produce the database password. This will be used when `password` is not set.'),
       private=True,
       type=coerce_password_from_script,
-      default=None,
+      default="",
     ),
     HOST=Config(
       key='host',
@@ -1012,7 +1012,7 @@ def get_redaction_policy():
 
 def get_secret_key():
   secret_key = SECRET_KEY.get()
-  if secret_key is None:
+  if not secret_key:
     secret_key = SECRET_KEY_SCRIPT.get()
 
   return secret_key
@@ -1020,7 +1020,7 @@ def get_secret_key():
 
 def get_ssl_password():
   password = SSL_PASSWORD.get()
-  if password is None:
+  if not password:
     password = SSL_PASSWORD_SCRIPT.get()
 
   return password
@@ -1028,7 +1028,7 @@ def get_ssl_password():
 
 def get_database_password():
   password = DATABASE.PASSWORD.get()
-  if password is None:
+  if not password:
     password = DATABASE.PASSWORD_SCRIPT.get()
 
   return password
@@ -1036,7 +1036,7 @@ def get_database_password():
 
 def get_smtp_password():
   password = SMTP.PASSWORD.get()
-  if password is None:
+  if not password:
     password = SMTP.PASSWORD_SCRIPT.get()
 
   return password
@@ -1044,7 +1044,7 @@ def get_smtp_password():
 
 def get_ldap_password():
   password = LDAP_PASSWORD.get()
-  if password is None:
+  if not password:
     password = LDAP_PASSWORD_SCRIPT.get()
 
   return password
@@ -1052,7 +1052,7 @@ def get_ldap_password():
 
 def get_ldap_bind_password(ldap_config):
   password = ldap_config.BIND_PASSWORD.get()
-  if password is None:
+  if not password:
     password = ldap_config.BIND_PASSWORD_SCRIPT.get()
 
   return password

+ 1 - 1
desktop/libs/librdbms/src/librdbms/conf.py

@@ -112,7 +112,7 @@ def get_database_password(name):
   """
 
   password = DATABASES[name].PASSWORD.get()
-  if password is None:
+  if not password:
     password = DATABASES[name].PASSWORD_SCRIPT.get()
 
   return password