-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Preview of Markdown not working, getting 403 #17843
Comments
The same 403 is present in the apache webserver log. [28/Nov/2021:15:18:04 +0100] "POST /git/api/v1/repos/servers/server-installs/markdown HTTP/1.1" 403 59 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0" |
I just remembered another similar issue: |
This was also present on 1.14. |
I've tried changing the ROOT_URL as mentioned in the referenced issue, but that doesn't fix the problem. |
Setting the *_VISIBILITY variables to public also doesn't work. Don't know what else to check now. |
Can you check (inspect) the requests sent by your browser? What's the difference between a correct request and an incorrect request? |
From the Firefox console. Headers:
Request:
Must note that a different token appears to be sent than is stored in my cookies. Also, Firefox reports 'CORS Missing Allow Origin' in the transferred column |
Maybe that's the problem. On my side, the CSRF token in POST and in COOKIE are the same. Can you check the source code of the page to see which CSRF token is correct? which is incorrect? The correct CSRF token should also exist in the page source code. ps: You can safely paste the starting sub-string of your CSRF tokens here, it won't cause any security problem. |
The csrf is changed by the 403 response. |
What are your cookie settings in app.ini? It might just be helpful to paste that up entirely - skipping the secrets and the confidential stuff but explaining what the values are. (For example if your root URL is something like https://foo.example.com/bar put this in instead.) Could you check if the problem still occurs in an incognito window? Have you tried deleting all of your Gitea cookies? |
I have changed nothing in app.ini wrt cookies, everything is at defaults. Problem is present is private window as well. Removing all cookies doesn't help. |
Even disabling selinux doesn't help, so it appears to be somewhere inside the application code |
This can easily be reproduced by setting up a Fedora 35 machine/VM and installing the RPM I created (see https://gitlab.com/fhuberts/rpmsUpstream/-/tree/master/fedora/gitea). I'll attach a built RPM package in a minute. This should make it a lot easier to debug. |
Github refuses to attach the rpms/gz/zip. bummer. It's quite easy to build the RPM yourself, or just ping me |
Ha, easy workaround. Put them on gitlab: https://gitlab.com/fhuberts/gitea-rpms |
Ok, so I'm only having this problem on wiki pages. Preview works fine on issues. |
Ah that helps! |
Didn't know that before, hit that by accident. |
OK on both 1.15.7 and 1.16-dev I'm getting the right thing on the wiki. What permissions does the user you're trying to write with have in that repository? |
the logged in user is the owner of the repo. |
and the filesystem owner of the wiki repo is the user under which gitea runs (e.g. user 'git') |
I still cannot reproduce this. I think it would be useful to see your app.ini. |
I put the RPM packages on gitlab (#17843 (comment)), so you can completely reproduce my setup by installing a Fedora VM with those RPMs. |
And now it works again for a very small example in an issue. |
Thanks for the rpms, but it's a bit much to expect us to install vagrant, download a fedora cloud-base, create a virtual machine install 288 packages into that virtual machine, then install your homemade packages into that virtual machine. (Which ones?! All of them?) Even after doing all that we would then still have to guess what the eventual configuration would be. So instead:
It may be that 1.15.10 will solve this issue as it might be that you were using a memory provider and this an issue to do with the multiple sessioners in 1.15.0-1.15.9. |
As I've tried to explain, the RPMs exactly reproduce my setup. There is no need for vagrant, just a plain Fedora 35 server with those RPMs installed. Installing the RPMs will drag in all dependencies and configure the server, exactly reproducing my setup. I will update those RPMs, but most importantly I will upload the configuration files you've asked for in that repo as well. What do you mean with session provider? It's a daemon, there is no session. Or do you mean gitea user session? --> local login. I'm running 1.15.9 and it still has the issue. I'll add a comment after uploading all the files in that repo. |
I've updated the RPMs and added all config files. |
Are you sure that the ProxyPassReverse is correct? https://docs.gitea.io/en-us/reverse-proxies/#apache-httpd Does not recommend a ProxyPassReverse |
Removed the ProxyPassReverse:
While playing around I did see something very strange:
|
|
I'm sorry but I have to react to point 3 here. I will investigate point 1 you mention but I'm not holding out hope that that will solve the problem. Would it be so bad to consider that there might actually be a bug in gitea? You seem to be only pushing back on me instead of trying to understand the problem and investigating the gitea side. Thanks for the clarification on point 2. I'll report back when I've tried your point 1. |
And here are the configuration files, so that you don't have to go out to the git repo I put together for this issue. |
So I've tried without the unix domain socket, without SSL, just HTTP proxy: exact same problem. |
In your browser console have you watched the network to check how your browser is communicating with gitea when you click the preview page? Are you certain that the request is going to the correct place? |
I saw that problem by another user using my gitea instance. First i wondered, why it doesn't render the wiki edit preview, because on my machine (using chrome) everything works fine. Maybe its due to the browser, because the other user was using edge. |
OK so I've finally managed to start a fedora docker with systemd using https://hub.docker.com/r/jrei/systemd-fedora/ docker pull jrei/systemd-fedora
docker run -d --name systemd-fedora --tmpfs /tmp --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro jrei/systemd-fedora
docker exec -it systemd-fedora bash Then in that container: yum install https://gitlab.com/fhuberts/gitea-rpms/-/raw/master/gitea-1.15.9-1.fc35.x86_64.rpm Now for whatever reason that postgres didn't come up for me straight away, but I think the db is irrelevant so I switched to sqlite by editing the app.ini and restarted gitea: vi /etc/gitea/app.ini # to edit the app.ini as above
systemctl restart gitea Then on the host I navigate to:
created a user and then a test repository. Then gone to wiki markdown and yes I can reproduce the issue, but looking in the network console I see: POST https://8eba9d421607/git/api/v1/repos/administrator/simple-test/markdown Now I remember I've not set a ROOT_URL in app.ini ... (Gitea requires that you set the ROOT_URL to match the site.) So now I go back to command line and change the app.ini using DOMAIN=172.17.0.2
ROOT_URL=https://172.17.0.2/git then I run systemctl restart gitea And refresh my edit page. et voila ça marche. |
I tried both Firefox and Chrome. Both show the same result. |
@zeripath Thanks for looking into this, it helped me narrow down the problem... I made it work on my server, and the problem is that I need to access the server with its FQDN to make it work! This seems very weird and actually a bug. Literally the only thing different is using the 'hostname.domain.name' or 'hostname'. And the POST goes out to the same (apart from the FQDN) URL. |
Setting domain to 'hostname' has the following effect:
Same/reverse holds when setting domain to 'hostname.domain.name'. (I did see it work for issue comment previews a few times but can't reproduce that now) Seems like a hostname check is too strict. |
For now I've implemented a workaround for this bug (see https://gitlab.com/fhuberts/rpmsUpstream/-/commit/d403b45ede235a1852e57be9546b169b44fdcbe3?w=1). |
It would be useful if you could check the cookies that are set. You'll probably find that the cookies are being set as per the FQDN or hostname as appropriate. https://stackoverflow.com/questions/1062963/how-do-browser-cookie-domains-work |
Without the workaround cookies are stored under 'hostname', with the workaround cookies are stored under 'domain.name'. |
I also just discovered why issue comment previews sometimes seem to work: in a list with issues, the links to the issues (on the issue titles) are to the FQDN of the issue, even though the page with the list is opened on the 'hostname'! |
Summary: |
Currently, Gitea uses an absolute full URL That's why we asked many times to check whether the CSRF token and COOKIE were working correctly. |
After many refactoring to the URL and CSRF modules, this issue can be closed
And a new issue for the root problem: |
Gitea Version
1.15.6+27-gd29a0fc3b
Git Version
2.33.1
Operating System
Fedora 35 x64
How are you running Gitea?
Self-made RPM package, see https://gitlab.com/fhuberts/rpmsUpstream/-/tree/master/fedora/gitea
Database
PostgreSQL
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Description
Nov 28 14:57:07 git.somewhere gitea[3372]: 2021/11/28 14:57:07 Started POST /api/v1/repos/servers/server-installs/markdown for 192.168.180.11:0
Nov 28 14:57:07 git.somewhere gitea[3372]: 2021/11/28 14:57:07 Completed POST /api/v1/repos/servers/server-installs/markdown 403 Forbidden in 821.289µs
Screenshots
No response
The text was updated successfully, but these errors were encountered: