Skip to content

Commit

Permalink
[pocketbase#677] unset the X-Frame-Options when serving static files …
Browse files Browse the repository at this point in the history
…to allow files embedding
  • Loading branch information
ganigeorgiev committed Oct 2, 2022
1 parent b0db239 commit a6cafd1
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 208 deletions.
5 changes: 5 additions & 0 deletions tools/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ func (s *System) Serve(response http.ResponseWriter, fileKey string, name string
extContentType = ct
}

// clickjacking shouldn't be a concern when serving static files,
// so it safe to unset the global X-Frame-Options to allow files embedding
// (https://github.com/pocketbase/pocketbase/issues/677)
response.Header().Del("X-Frame-Options")

response.Header().Set("Content-Disposition", disposition+"; filename="+name)
response.Header().Set("Content-Type", extContentType)
response.Header().Set("Content-Length", strconv.FormatInt(r.Size(), 10))
Expand Down
4 changes: 4 additions & 0 deletions tools/filesystem/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func TestFileSystemServe(t *testing.T) {
t.Errorf("(%s) Expected value %q for header %q, got %q", scenario.path, hValue, hName, v)
}
}

if v := result.Header.Get("X-Frame-Options"); v != "" {
t.Errorf("(%s) Expected the X-Frame-Options header to be unset, got %v", scenario.path, v)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ PB_PROFILE_COLLECTION = "profiles"
PB_INSTALLER_PARAM = "installer"
PB_RULES_SYNTAX_DOCS = "https://pocketbase.io/docs/manage-collections#rules-filters-syntax"
PB_RELEASES = "https://github.com/pocketbase/pocketbase/releases"
PB_VERSION = "v0.7.7"
PB_VERSION = "v0.7.8"

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a6cafd1

Please sign in to comment.