Allow to enable password autocompletion by browser

Horizon tries to inhibit browsers' password autocompletion by default.
Offer a configurable option in the charm so that admin can allow
password autocompletion if necessary.

Change-Id: I461752d1d1175f777de5bff26953b200efb17137
Closes-Bug: 1714676
This commit is contained in:
Nobuto Murata 2017-10-12 12:25:30 -04:00 committed by Nobuto Murata
parent df70dab98a
commit a055181658
8 changed files with 68 additions and 11 deletions

View File

@ -337,3 +337,8 @@ options:
description: |
This option provides a means to enable customisation modules to modify
existing dashboards and panels. This is available from Liberty onwards.
allow-password-autocompletion:
type: boolean
default: False
description: |
Setting this to True will allow password form autocompletion by browser.

View File

@ -196,6 +196,8 @@ class HorizonContext(OSContextGenerator):
"neutron_network_firewall": config("neutron-network-firewall"),
"neutron_network_vpn": config("neutron-network-vpn"),
"cinder_backup": config("cinder-backup"),
"allow_password_autocompletion":
config("allow-password-autocompletion"),
"password_retrieve": config("password-retrieve"),
'virtualenv': git_pip_venv_dir(projects_yaml)
if config('openstack-origin-git') else None,

View File

@ -84,6 +84,9 @@ HORIZON_CONFIG = {
# Turn off browser autocompletion for the login form if so desired.
# HORIZON_CONFIG["password_autocomplete"] = "off"
{% if allow_password_autocompletion %}
HORIZON_CONFIG["password_autocomplete"] = "on"
{% endif %}
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))

View File

@ -94,6 +94,9 @@ SESSION_COOKIE_SECURE = True
# Turn off browser autocompletion for forms including the login form and
# the database creation workflow if so desired.
#HORIZON_CONFIG["password_autocomplete"] = "off"
{% if allow_password_autocompletion %}
HORIZON_CONFIG["password_autocomplete"] = "on"
{% endif %}
# Setting this to True will disable the reveal button for password fields,
# including on the login form.

View File

@ -114,6 +114,9 @@ SESSION_COOKIE_SECURE = True
# Turn off browser autocompletion for forms including the login form and
# the database creation workflow if so desired.
#HORIZON_CONFIG["password_autocomplete"] = "off"
{% if allow_password_autocompletion %}
HORIZON_CONFIG["password_autocomplete"] = "on"
{% endif %}
# Setting this to True will disable the reveal button for password fields,
# including on the login form.

View File

@ -116,6 +116,9 @@ SESSION_COOKIE_SECURE = True
# Turn off browser autocompletion for forms including the login form and
# the database creation workflow if so desired.
#HORIZON_CONFIG["password_autocomplete"] = "off"
{% if allow_password_autocompletion %}
HORIZON_CONFIG["password_autocomplete"] = "on"
{% endif %}
# Setting this to True will disable the reveal button for password fields,
# including on the login form.

View File

@ -116,6 +116,9 @@ SESSION_COOKIE_SECURE = True
# Turn off browser autocompletion for forms including the login form and
# the database creation workflow if so desired.
#HORIZON_CONFIG["password_autocomplete"] = "off"
{% if allow_password_autocompletion %}
HORIZON_CONFIG["password_autocomplete"] = "on"
{% endif %}
# Setting this to True will disable the reveal button for password fields,
# including on the login form.

View File

@ -136,7 +136,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -159,7 +160,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": "example_domain",
"multi_domain": False
"multi_domain": False,
"allow_password_autocompletion": False,
}
)
@ -182,7 +184,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -205,7 +208,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -229,7 +233,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -256,7 +261,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -279,7 +285,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -302,7 +309,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -330,7 +338,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": True,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -353,7 +362,8 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": True,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
@ -376,7 +386,32 @@ class TestHorizonContexts(CharmTestCase):
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True
"multi_domain": True,
"allow_password_autocompletion": False,
}
)
def test_HorizonContext_password_autocompletion(self):
self.test_config.set('allow-password-autocompletion', True)
self.assertEqual(horizon_contexts.HorizonContext()(),
{'compress_offline': True, 'debug': False,
'customization_module': '',
'default_role': 'Member', 'webroot': '/horizon',
'ubuntu_theme': True,
'default_theme': None,
'virtualenv': None,
'secret': 'secret',
'support_profile': None,
"neutron_network_dvr": False,
"neutron_network_l3ha": False,
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True,
"allow_password_autocompletion": True,
}
)