File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,30 @@ def index() -> BottleViewReturn:
103103 # Accept any following paths for client-side routing
104104 @app .get ("/dashboard<:re:(/.*)?>" )
105105 def dashboard () -> BottleViewReturn :
106- return static_file ("index.html" , BASE_DIR , mimetype = "text/html" )
106+ if allow_unsafe :
107+ headers = {}
108+ else :
109+ # CSP header
110+ if llm_provider is not None :
111+ script_src_str = "script-src 'self' 'unsafe-inline' 'unsafe-eval'"
112+ else :
113+ # Parallel coordinate, which uses WebGL, requires unsafe-eval.
114+ script_src_str = "script-src 'self' 'unsafe-eval'"
115+
116+ csp_string = ";" .join (
117+ [
118+ "default-src 'self'" ,
119+ "img-src 'self' data: blob:" ,
120+ "frame-src 'self'" ,
121+ "object-src 'none'" ,
122+ "connect-src 'self'" ,
123+ "style-src 'self' data: 'unsafe-inline'" ,
124+ script_src_str ,
125+ ]
126+ )
127+ headers = {"Content-Security-Policy" : csp_string }
128+
129+ return static_file ("index.html" , BASE_DIR , mimetype = "text/html" , headers = headers )
107130
108131 @app .get ("/api/meta" )
109132 @json_api_view
You can’t perform that action at this time.
0 commit comments