Skip to content

Commit

Permalink
Add frame-options option
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed May 13, 2024
1 parent 0500550 commit 99976dd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cd/cloudretro.io/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ coordinator:
debug: true
server:
address:
frameOptions: SAMEORIGIN
https: true
tls:
domain: cloudretro.io
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ coordinator:
server:
address: :8000
cacheControl: "max-age=259200, must-revalidate"
frameOptions: ""
https: false
# Letsencrypt or self cert config
tls:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (c *Monitoring) IsEnabled() bool { return c.MetricEnabled || c.ProfilingEna
type Server struct {
Address string
CacheControl string
FrameOptions string
Https bool
Tls struct {
Address string
Expand Down
6 changes: 6 additions & 0 deletions pkg/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func index(conf config.CoordinatorConfig, log *logger.Logger) httpx.Handler {
if conf.Coordinator.Server.CacheControl != "" {
w.Header().Add("Cache-Control", conf.Coordinator.Server.CacheControl)
}
if conf.Coordinator.Server.FrameOptions != "" {
w.Header().Add("X-Frame-Options", conf.Coordinator.Server.FrameOptions)
}
if r.URL.Path == "/" || strings.HasSuffix(r.URL.Path, "/index.html") {
tpl := template.Must(template.ParseFiles(indexHTML))
handler(tpl, w, r)
Expand All @@ -108,6 +111,9 @@ func index(conf config.CoordinatorConfig, log *logger.Logger) httpx.Handler {
if conf.Coordinator.Server.CacheControl != "" {
w.Header().Add("Cache-Control", conf.Coordinator.Server.CacheControl)
}
if conf.Coordinator.Server.FrameOptions != "" {
w.Header().Add("X-Frame-Options", conf.Coordinator.Server.FrameOptions)
}
if r.URL.Path == "/" || strings.HasSuffix(r.URL.Path, "/index.html") {
handler(indexTpl, w, r)
return
Expand Down

0 comments on commit 99976dd

Please sign in to comment.