Description
Description
We are using the api to find out which releases exist for a specific repository. Until 1.19.3 we were able to download those assets as well when passing the api key in the header to the browser_download_url
which is part of the listing at
https://git.fluves.net/api/swagger#/repository/repoGetReleaseByTag
This no longer works in 1.20.1 (not checked versions between 1.19.3 and 1.20.1).
The headers we pass are:
headers = {
"Authorization": f"token {gitea_token}",
"Content-Type": "application/json",
"Accept": "application/json",
}
this works for the api, but no longer for the download. The URL given works if I use it from a browser where I logged in manually.
Gitea Version
1.20.1
Can you reproduce the bug on the Gitea demo site?
Yes:
Building an example at try.gitea.org
I generated a new token with read:package and read:repository rights.
c44ec64232370bc06c9f4aa8c2c67e0121ccc72b
(nothing valuable is in the repo, it is safe to share this).
eg if I go to:
https://try.gitea.io/api/v1/repos/johanvdw/bug26165/releases/
and then try to open
https://try.gitea.io/johanvdw/bug26165/releases/download/0.1/README.txt
curl -X 'GET' \
'https://try.gitea.io/api/v1/repos/johanvdw/bug26165/releases/tags/0.1?token=c44ec64232370bc06c9f4aa8c2c67e0121ccc72b' \
-H 'accept: application/json'
response:
{
"id": 10386849,
"tag_name": "0.1",
"target_commitish": "main",
"name": "test",
"body": "test",
"url": "https://try.gitea.io/api/v1/repos/johanvdw/bug26165/releases/10386849",
"html_url": "https://try.gitea.io/johanvdw/bug26165/releases/tag/0.1",
"tarball_url": "https://try.gitea.io/johanvdw/bug26165/archive/0.1.tar.gz",
"zipball_url": "https://try.gitea.io/johanvdw/bug26165/archive/0.1.zip",
"draft": false,
"prerelease": false,
"created_at": "2023-07-26T13:02:36Z",
"published_at": "2023-07-26T13:02:36Z",
"author": {
...
},
"assets": [
{
"id": 3458,
"name": "README.txt",
"size": 53,
"download_count": 1,
"created_at": "2023-07-26T13:03:22Z",
"uuid": "fe39078d-5858-4afb-a71f-115a313f3cb9",
"browser_download_url": "https://try.gitea.io/johanvdw/bug26165/releases/download/0.1/README.txt"
}
]
}
will give me a browser_download_url in assets, but I'm not able to use that to download the file.
curl -X 'GET' https://try.gitea.io/johanvdw/bug26165/releases/download/0.1/README.txt
Not found.
similar results when specifying a token (the first variant was definitely working in 1.19).
curl -X 'GET' https://try.gitea.io/johanvdw/bug26165/releases/download/0.1/README.txt -H 'Authorization: token c44ec64232370bc06c9f4aa8c2c67e0121ccc72b'
curl -X 'GET' https://try.gitea.io/johanvdw/bug26165/releases/download/0.1/README.txt?token=c44ec64232370bc06c9f4aa8c2c67e0121ccc72b
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
docker.
Database
PostgreSQL