@@ -92,6 +92,34 @@ class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
9292 " 'sha256-biLFinpqYMtWHmXfkA1BPeCY0/fNt46SAZ+BBk5YUog='"
9393 + " 'sha256-zQDRfdePzsm4666fPPtpna61v74bryIt2Xu5qx2rn4A='" ;
9494
95+ // - 'sha256-biL...' is required for 'display: none;' inline CSS
96+ // - 'sha256-ZdH...' is required for 'display: none' inline CSS
97+ // - 'sha256-aqN...' is required for 'display:none' inline CSS
98+ // - 'sha256-tIs...' is required for 'text-decoration: none;' inline CSS
99+ // - 'sha256-VPM...' is required for 'vertical-align: middle;' inline CSS
100+ // - 'sha256-CDs...' is required for 'padding:0px' inline CSS
101+ // - 'sha256-65m...' is required for 'white-space:nowrap' inline CSS
102+ // - 'sha256-xSK...' is required for 'margin: 0px; padding: 0px;' inline CSS
103+ // - 'sha256-Jnn...' is required for 'padding:0;width:10px;height:10px;' inline CSS
104+ // - 'sha256-yBh...' is required for 'margin: 20px' inline CSS
105+ // - 'sha256-ec+...' is required for 'width:300px' inline CSS
106+ // - 'sha256-rqk...' is required for 'width:300px;' inline CSS
107+ // - 'sha256-PGJ...' is required for 'width:200px;' inline CSS
108+ private static final String STYLE_H2_CONSOLE =
109+ " 'sha256-biLFinpqYMtWHmXfkA1BPeCY0/fNt46SAZ+BBk5YUog='"
110+ + " 'sha256-ZdHxw9eWtnxUb3mk6tBS+gIiVUPE3pGM470keHPDFlE='"
111+ + " 'sha256-aqNNdDLnnrDOnTNdkJpYlAxKVJtLt9CtFLklmInuUAE='"
112+ + " 'sha256-tIs8OfjWm8MHgPJrHv7mM4wvA/FDFcra3Pd5icRMX+k='"
113+ + " 'sha256-VPm872V2JvE+vhivDg7UeH+N9a9YzzqGGow5mzY48hc='"
114+ + " 'sha256-CDs+xFw5uMoNgtE5XIrz5GXgs3O+/NFkYK2IK/vKSBE='"
115+ + " 'sha256-65mkwZPt4V1miqNM9CcVYkrpnlQigG9H6Vi9OM/JCgY='"
116+ + " 'sha256-xSKCQeN6yeCb4HCkijkjoBFHWdJFwmwDiFa3XlZZ6Bs='"
117+ + " 'sha256-JnnwE+8wsBgf/bh1qyvAsUVHBgiTioeZ1NSUKff7mOM='"
118+ + " 'sha256-yBhVF062O1IGu3ZngyEhh9l561VFLsJpdSxVtbwisRY='"
119+ + " 'sha256-eC+jXvbVSsG0J4zQfR5fWxxUCqpaa5DZLbINjWNCu48='"
120+ + " 'sha256-rqkMEwsWwrInJqctxmIaWOCFPV+Qmym3tMHH3wtq3Y0='"
121+ + " 'sha256-PGJ8tjuz2DXGgB1Sie9pW8BrxBGK6EQndbLEkXd44T8='" ;
122+
95123 // - 'unsafe-inline' is required by jquery.min.js (that is using code inside of
96124 // event handlers. We can't use hashing algorithms because they aren't supported
97125 // for handlers. In future, we should get rid of jQuery or use
@@ -119,6 +147,9 @@ class ContentSecurityPolicyHeaderWriter implements HeaderWriter {
119147 // - 'self' is required for AJAX requests from our scripts (country suggestions on /series/add)
120148 private static final String CONNECT_SRC = "connect-src 'self'" ;
121149
150+ // - 'self' is required for frames on H2 webconsole
151+ private static final String CHILD_SRC = "child-src 'self'" ;
152+
122153 private static final char SEPARATOR = ';' ;
123154
124155 private static final int MIN_HEADER_LENGTH =
@@ -165,6 +196,9 @@ private String constructDirectives(String uri) {
165196
166197 } else if (uri .startsWith (TOGGLZ_PAGES_PATTERN )) {
167198 sb .append (STYLE_TOGGLZ );
199+
200+ } else if (uri .startsWith ("/console/" )) {
201+ sb .append (STYLE_H2_CONSOLE );
168202 }
169203
170204 sb .append (SEPARATOR )
@@ -179,6 +213,10 @@ private String constructDirectives(String uri) {
179213 sb .append (SCRIPTS_SERIES_ADD_PAGE )
180214 .append (SEPARATOR )
181215 .append (CONNECT_SRC );
216+
217+ } else if (uri .startsWith ("/console/" )) {
218+ sb .append (SEPARATOR )
219+ .append (CHILD_SRC );
182220 }
183221
184222 return sb .toString ();
0 commit comments