Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal : Permit modification of X-FRAME-OPTIONS headers #7951

Closed
Noctisae opened this issue Aug 23, 2019 · 4 comments · Fixed by #16643
Closed

Proposal : Permit modification of X-FRAME-OPTIONS headers #7951

Noctisae opened this issue Aug 23, 2019 · 4 comments · Fixed by #16643
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@Noctisae
Copy link

Hello,

I'd like to file a proposal concerning the HTTP headers sent by Gitea, due to a specific user case I'm running into.

Currently, Gitea always send the HTTP header "X-FRAME-OPTIONS" with the value "SAMEORIGIN" in all requests, which is a good security practice. However, I'm currently running into a case where I need to set this header to a value like "ALLOW-FROM <external_site>", to permit framing Gitea inside a portal I'm currently working on. Because I do not have control over the proxy serving Gitea, one of the solution I have is to set the header from Gitea directly. I could also mount a proxy on the same machine as Gitea to have this proxy serve the right headers instead of Gitea, but (in my view) this solution is a complicated workaround of a otherwise easy to fix issue.

I'm proposing to permit the configuration of this specific header with a line inside the app.ini, with a default value of SAMEORIGIN (to ensure the default behavior of Gitea isn't modified with the proposed change). This way, anyone could set the value of this header to the value which suits their need, without compromising the default security of the solution. I do understand my case is uncommon, but I think this evolution could be implemented very easily (due to the fact that I've already done it on my part). I can propose the PR if interested.

Thoughts?

@STaRDoGG
Copy link

STaRDoGG commented Sep 5, 2019

I'd like to be able to individually control the sameorigin header as well; perhaps per repo?

My use case:

  • I'm running Gitea locally via docker on a LAN machine.
  • I also own a public website, and in a post on it, I want to iframe the raw code of one repo (in this case just a single file in the repo; a .css file) on the local Gitea machine. This way, if/when I ever update the source code locally it'll always fetch the latest version of that code within the iframe of that post.

Currently I can't due to the sameorigin header. If I could disable that header for that specific file or repo, then I'd be able to accomplish this.

@lunny lunny added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Sep 5, 2019
@jap1968
Copy link

jap1968 commented May 29, 2020

Same problem here. I am running gitea and swagger editor in two different containers. I would like to load a .yaml file from gitea into the editor. Swagger complains about CORS blocking the request, but maybe the real problem is the X-FRAME-OPTIONS header.

@lafriks
Copy link
Member

lafriks commented May 29, 2020

CORS has different headers that need to be added to allow cross origin requests

@spasche
Copy link

spasche commented Jul 25, 2021

I agree that having a way to control X-Frame-Options header at the application level would be useful.

If you use nginx as a reverse proxy, it's possible to override it there (credits to https://serverfault.com/a/982013):

server {
    server_name gitea.example.com;
    [...]
    location / {
        proxy_pass http://gitea:8080;

        proxy_hide_header X-Frame-Options;
        add_header X-Frame-Options "allow-from https://trusted.example.com/" always;
    }
}

zeripath added a commit to zeripath/gitea that referenced this issue Aug 6, 2021
This PR provides a mechanism to set the X-FRAME-OPTIONS header.

Fix go-gitea#7951

Signed-off-by: Andrew Thornton <[email protected]>
techknowlogick pushed a commit that referenced this issue Aug 6, 2021
* Allow setting X-FRAME-OPTIONS

This PR provides a mechanism to set the X-FRAME-OPTIONS header.

Fix #7951

Signed-off-by: Andrew Thornton <[email protected]>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: John Olheiser <[email protected]>

Co-authored-by: John Olheiser <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants