Add frame-options option

This commit is contained in:
Sergey Stepanov 2024-05-13 19:29:13 +03:00
parent 0500550fc0
commit 99976dd560
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
4 changed files with 9 additions and 0 deletions

View file

@ -4,6 +4,7 @@ coordinator:
debug: true
server:
address:
frameOptions: SAMEORIGIN
https: true
tls:
domain: cloudretro.io

View file

@ -60,6 +60,7 @@ coordinator:
server:
address: :8000
cacheControl: "max-age=259200, must-revalidate"
frameOptions: ""
https: false
# Letsencrypt or self cert config
tls:

View file

@ -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

View file

@ -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)
@ -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