Skip to content

Commit

Permalink
fix: change default CSP value (#2601)
Browse files Browse the repository at this point in the history
Co-authored-by: Zeping Bai <[email protected]>
  • Loading branch information
nthsky and bzp2010 authored Nov 7, 2022
1 parent b5672b6 commit 8dcadce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/conf/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ conf:
# access_control_allow_headers: "Authorization"
# access_control-allow_methods: "*"
# x_frame_options: "deny"
# content_security_policy: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; frame-src xx.xx.xx.xx:3000" # You can set frame-src to provide content for your grafana panel.
# content_security_policy: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; frame-src xx.xx.xx.xx:3000" # You can set frame-src to provide content for your grafana panel.

authentication:
secret:
Expand Down
6 changes: 4 additions & 2 deletions api/internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const (
EnvTEST = "test"

WebDir = "html/"

DefaultCSP = "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
State = "123456"
)

Expand Down Expand Up @@ -414,7 +416,7 @@ func initSecurity(conf Security) {
if conf != se {
SecurityConf = conf
if conf.ContentSecurityPolicy == "" {
SecurityConf.ContentSecurityPolicy = "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'"
SecurityConf.ContentSecurityPolicy = DefaultCSP
}
if conf.XFrameOptions == "" {
SecurityConf.XFrameOptions = "deny"
Expand All @@ -424,6 +426,6 @@ func initSecurity(conf Security) {

SecurityConf = Security{
XFrameOptions: "deny",
ContentSecurityPolicy: "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'",
ContentSecurityPolicy: DefaultCSP,
}
}

0 comments on commit 8dcadce

Please sign in to comment.