|
16 | 16 | import com.facebook.airlift.concurrent.BoundedExecutor;
|
17 | 17 | import com.facebook.airlift.configuration.AbstractConfigurationAwareModule;
|
18 | 18 | import com.facebook.airlift.discovery.server.EmbeddedDiscoveryModule;
|
| 19 | +import com.facebook.airlift.http.server.HttpServerBinder.HttpResourceBinding; |
19 | 20 | import com.facebook.presto.client.QueryResults;
|
20 | 21 | import com.facebook.presto.cost.CostCalculator;
|
21 | 22 | import com.facebook.presto.cost.CostCalculator.EstimatedExchanges;
|
|
139 | 140 | public class CoordinatorModule
|
140 | 141 | extends AbstractConfigurationAwareModule
|
141 | 142 | {
|
| 143 | + private static final String DEFAULT_WEBUI_CSP = |
| 144 | + "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; " + |
| 145 | + "font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'; img-src http: https: data:"; |
| 146 | + |
| 147 | + private HttpResourceBinding webUIBinder(Binder binder, String path, String classPathResourceBase) |
| 148 | + { |
| 149 | + return httpServerBinder(binder).bindResource(path, classPathResourceBase) |
| 150 | + .withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff") |
| 151 | + .withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, DEFAULT_WEBUI_CSP); |
| 152 | + } |
| 153 | + |
142 | 154 | @Override
|
143 | 155 | protected void setup(Binder binder)
|
144 | 156 | {
|
145 |
| - httpServerBinder(binder).bindResource("/ui", "webapp").withWelcomeFile("index.html") |
146 |
| - .withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff") |
147 |
| - .withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'; img-src http: https: data:"); |
148 |
| - httpServerBinder(binder).bindResource("/tableau", "webapp/tableau") |
149 |
| - .withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff") |
150 |
| - .withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'; img-src http: https: data:"); |
| 157 | + webUIBinder(binder, "/ui/dev", "webapp/dev").withWelcomeFile("index.html"); |
| 158 | + webUIBinder(binder, "/ui", "webapp").withWelcomeFile("index.html"); |
| 159 | + webUIBinder(binder, "/tableau", "webapp/tableau"); |
151 | 160 |
|
152 | 161 | // discovery server
|
153 | 162 | install(installModuleIf(EmbeddedDiscoveryConfig.class, EmbeddedDiscoveryConfig::isEnabled, new EmbeddedDiscoveryModule()));
|
|
0 commit comments