]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: set security headers 39627/head
authorAvan Thakkar <athakkar@redhat.com>
Wed, 10 Feb 2021 22:12:49 +0000 (03:42 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Mon, 22 Feb 2021 17:48:48 +0000 (23:18 +0530)
Fixes: https://tracker.ceph.com/issues/49243
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
(cherry picked from commit 87bb3777877580f70018f4880488e264decc16e4)

 Conflicts:
qa/tasks/mgr/dashboard/test_requests.py
src/pybind/mgr/dashboard/services/auth.py
      - Adopted the necessary changes from the master branch.

qa/tasks/mgr/dashboard/test_requests.py
qa/tasks/mgr/test_prometheus.py
src/pybind/mgr/dashboard/services/auth.py
src/pybind/mgr/prometheus/module.py

index 0d9f8d9ba83697042c63c18f4b0c1bbc30bd8b0f..eba81d673af2c99301225d963a4266c70d78ad47 100644 (file)
@@ -20,4 +20,8 @@ class RequestsTest(DashboardTestCase):
         self.assertNotIn('Content-Encoding', self._resp.headers)
         self.assertHeaders({
             'Content-Type': 'application/json',
+            'server': 'Ceph-Dashboard',
+            'Content-Security-Policy': "frame-ancestors 'self';",
+            'X-Content-Type-Options': 'nosniff',
+            'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload'
         })
index 867d5cd5d6d6d38d2fe2af785bd3c3b14b575397..7fe37a1a5f8ff3114661ee5083f41b5f3a554fcb 100644 (file)
@@ -49,6 +49,7 @@ class TestPrometheus(MgrTestCase):
         r = requests.get(original_uri + "metrics", allow_redirects=False)
         self.assertEqual(r.status_code, 200)
         self.assertEqual(r.headers["content-type"], "text/plain;charset=utf-8")
+        self.assertEqual(r.headers["server"], "Ceph-Prometheus")
 
     def test_urls(self):
         self._assign_ports("prometheus", "server_port")
index bbb8a2ecfe11c664663f3943982d383691c0c456..ad07a177704a3dec61c1c8999dac376135eb6612 100644 (file)
@@ -15,6 +15,13 @@ import jwt
 from .access_control import LocalAuthenticator, UserDoesNotExist
 from .. import mgr
 
+cherrypy.config.update({
+    'response.headers.server': 'Ceph-Dashboard',
+    'response.headers.content-security-policy': "frame-ancestors 'self';",
+    'response.headers.x-content-type-options': 'nosniff',
+    'response.headers.strict-transport-security': 'max-age=63072000; includeSubDomains; preload'
+})
+
 
 class JwtManager(object):
     JWT_TOKEN_BLACKLIST_KEY = "jwt_token_black_list"
index f3068250fd9fd023e33fdb2b214feff98817d916..d1b89495d83daa6a9ff44764a0fb1e3b012f3d73 100644 (file)
@@ -50,6 +50,9 @@ os._exit = os_exit_noop
 # it's a dict, the writer doesn't need to declare 'global' for access
 
 _global_instance = None  # type: Optional[Module]
+cherrypy.config.update({
+    'response.headers.server': 'Ceph-Prometheus'
+})
 
 
 def health_status_to_number(status):