فهرست منبع

[core] Hide some ini properties

Mark some properties as private
Even if the private properties are shown, escape the passwords
Romain Rigaux 11 سال پیش
والد
کامیت
39f6a58
3فایلهای تغییر یافته به همراه14 افزوده شده و 1 حذف شده
  1. 3 0
      desktop/core/src/desktop/conf.py
  2. 7 1
      desktop/core/src/desktop/templates/dump_config.mako
  3. 4 0
      desktop/core/src/desktop/tests.py

+ 3 - 0
desktop/core/src/desktop/conf.py

@@ -189,6 +189,7 @@ SMTP = ConfigSection(
       key="password",
       help=_("The password for the SMTP user."),
       type=str,
+      private=True,
       default=""
     ),
 
@@ -234,6 +235,7 @@ DATABASE = ConfigSection(
     PASSWORD=Config(
       key='password',
       help=_('Database password.'),
+      private=True,
       type=str,
       default='',
     ),
@@ -419,6 +421,7 @@ LDAP = ConfigSection(
                    help=_("The distinguished name to bind as, when importing from LDAP.")),
     BIND_PASSWORD=Config("bind_password",
                    default=None,
+                   private=True,
                    help=_("The password for the bind user.")),
     SEARCH_BIND_AUTHENTICATION=Config("search_bind_authentication",
                    default=True,

+ 7 - 1
desktop/core/src/desktop/templates/dump_config.mako

@@ -140,7 +140,13 @@ ${layout.menubar(section='dump_config')}
                 <p class="dump_config_help"><i>${ config_obj.config.help or _('No help available.') }</i></p>
                 ${ recurseList(config_obj.get().values(), depth + 1) }
               % else:
-                <p>${ str(config_obj.get_raw()).decode('utf-8', 'replace') }</p>
+                <p>
+                  % if 'password' in config_obj.config.key:
+                    ${ "*" * 10 }
+                  % else:
+                    ${ str(config_obj.get_raw()).decode('utf-8', 'replace') }
+                  % endif
+                  </p>
                 <p class="dump_config_help"><i>${ config_obj.config.help or _('No help available.') }</i></p>
                 <p class="dump_config_default">${ _('Default:') } <i>${ str(config_obj.config.default).decode('utf-8', 'replace') }</i></p>
               % endif

+ 4 - 0
desktop/core/src/desktop/tests.py

@@ -194,6 +194,10 @@ def test_dump_config():
   finally:
     finish()
 
+  # Not showing some passwords
+  response = c.get(reverse('desktop.views.dump_config'))
+  assert_false('bind_password' in response.content)
+
   # Login as someone else
   client_not_me = make_logged_in_client(username='not_me', is_superuser=False, groupname='test')
   grant_access("not_me", "test", "desktop")