Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ PATH =
;;
;; allow request with credentials
;ALLOW_CREDENTIALS = false
;;
;; set X-FRAME-OPTIONS header
;X_FRAME_OPTIONS = SAMEORIGIN

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
- `METHODS`: **GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS**: list of methods allowed to request
- `MAX_AGE`: **10m**: max time to cache response
- `ALLOW_CREDENTIALS`: **false**: allow request with credentials
- `X_FRAME_OPTIONS`: **SAMEORIGIN**: Set the `X-Frame-Options` header value.

## UI (`ui`)

Expand Down
2 changes: 1 addition & 1 deletion modules/context/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func APIContexter() func(http.Handler) http.Handler {
}
}

ctx.Resp.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)

ctx.Data["CsrfToken"] = html.EscapeString(ctx.csrf.GetToken())

Expand Down
2 changes: 1 addition & 1 deletion modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func Contexter() func(next http.Handler) http.Handler {
}
}

ctx.Resp.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)

ctx.Data["CsrfToken"] = html.EscapeString(ctx.csrf.GetToken())
ctx.Data["CsrfTokenHtml"] = template.HTML(`<input type="hidden" name="_csrf" value="` + ctx.Data["CsrfToken"].(string) + `">`)
Expand Down
6 changes: 4 additions & 2 deletions modules/setting/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ var (
Methods []string
MaxAge time.Duration
AllowCredentials bool
XFrameOptions string
}{
Enabled: false,
MaxAge: 10 * time.Minute,
Enabled: false,
MaxAge: 10 * time.Minute,
XFrameOptions: "SAMEORIGIN",
}
)

Expand Down
2 changes: 1 addition & 1 deletion routers/install/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func installRecovery() func(next http.Handler) http.Handler {
"SignedUserName": "",
}

w.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)

if !setting.IsProd() {
store["ErrorMsg"] = combinedErr
Expand Down
2 changes: 1 addition & 1 deletion routers/web/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func Recovery() func(next http.Handler) http.Handler {
store["SignedUserName"] = ""
}

w.Header().Set(`X-Frame-Options`, `SAMEORIGIN`)
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)

if !setting.IsProd() {
store["ErrorMsg"] = combinedErr
Expand Down