Add disable-password-reveal option

Adds config item to add HORIZON_CONFIG['disable_password_reveal'] = True
option to Horizon's local_settings.py, from Mitaka onwards.  This
prevents the reveal password button from being displayed.

Change-Id: I299f6a6388c3a2ab68cabaeb16e5104ec319e144
Closes-bug: #1840251
This commit is contained in:
Xav Paice 2019-08-27 16:56:16 +12:00
parent 09614163a7
commit 957a6adc03
6 changed files with 67 additions and 1 deletions

View File

@ -404,3 +404,8 @@ options:
belongs to. Please see the README of the charm for further details.
.
If False then remove/disable any overrides in force.
disable-password-reveal:
type: boolean
default: false
description: |
If enabled, the reveal button for passwords is removed.

View File

@ -208,7 +208,8 @@ class HorizonContext(OSContextGenerator):
'dropdown_max_items': config('dropdown-max-items'),
'enable_consistency_groups': config('enable-consistency-groups'),
'disable_instance_snapshot': bool(
config('disable-instance-snapshot'))
config('disable-instance-snapshot')),
'disable_password_reveal': config('disable-password-reveal'),
}
return ctxt

View File

@ -124,6 +124,9 @@ HORIZON_CONFIG["password_autocomplete"] = "on"
# Setting this to True will disable the reveal button for password fields,
# including on the login form.
#HORIZON_CONFIG["disable_password_reveal"] = False
{% if disable_password_reveal %}
HORIZON_CONFIG["disable_password_reveal"] = True
{% endif %}
HORIZON_CONFIG["customization_module"] = "{{ customization_module }}"

View File

@ -126,6 +126,9 @@ HORIZON_CONFIG["password_autocomplete"] = "on"
# Setting this to True will disable the reveal button for password fields,
# including on the login form.
#HORIZON_CONFIG["disable_password_reveal"] = False
{% if disable_password_reveal %}
HORIZON_CONFIG["disable_password_reveal"] = True
{% endif %}
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))

View File

@ -126,6 +126,10 @@ HORIZON_CONFIG["password_autocomplete"] = "on"
# Setting this to True will disable the reveal button for password fields,
# including on the login form.
#HORIZON_CONFIG["disable_password_reveal"] = False
{% if disable_password_reveal %}
HORIZON_CONFIG["disable_password_reveal"] = True
{% endif %}
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))

View File

@ -124,6 +124,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -156,6 +157,42 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
def test_HorizonContext_disable_password_reveal(self):
self.test_config.set('disable-password-reveal', True)
self.assertEqual(horizon_contexts.HorizonContext()(),
{'compress_offline': True,
'debug': False,
'customization_module': '',
'default_role': 'Member',
'webroot': '/horizon',
'ubuntu_theme': True,
'default_theme': None,
'custom_theme': False,
'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": False,
"default_create_volume": True,
"image_formats": '',
"api_result_limit": 1000,
"enable_fip_topology_check": True,
"session_timeout": 3600,
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": True,
}
)
@ -188,6 +225,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -220,6 +258,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -253,6 +292,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -289,6 +329,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -321,6 +362,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -353,6 +395,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -390,6 +433,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -422,6 +466,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -454,6 +499,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -487,6 +533,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -520,6 +567,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -553,6 +601,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)
@ -586,6 +635,7 @@ class TestHorizonContexts(CharmTestCase):
"dropdown_max_items": 30,
"enable_consistency_groups": False,
"disable_instance_snapshot": False,
"disable_password_reveal": False,
}
)