-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fix api releases attachments wrong URL #26175
Conversation
This throws the nice URL completely from the API, which causes problems for people who want this. So you broke one feature to fix another. It think it's way better to just add add a new field e.g. |
I found something interesting: It looks like the route |
Forgot was I wrote in the last post. I was stupid and didn't notice that I was also logged in in my second Browser. But I found something more interesting: |
I don't know what did you mean the |
|
It does not ignore the token. You can test it yourself. I'm working to find out more in the moment. |
Yes, it's not currently, but I just meant maybe it should ignore. if !middleware.IsAPIPath(req) && !isContainerPath(req) && !isAttachmentDownload(req) && !isGitRawReleaseOrLFSPath(req) {
return nil, nil
} containers, attachment download, git http protocol or lfs will support PAT currently. |
Why should be do that? This can break existing scripts. We currently have a working solution, so we just needed to add the |
How am I going to download a release attachment from the cli via the API from private repos in that case? Am I forced to make the repo public? |
The benefit is users could run a API-only Gitea. |
That's understandable, but we could support both. We add |
I think you mean |
I don't think it is a good idea to return a url from the api if you can not access it using the same method used in the api. That will only lead to confusion. |
Yes
We currently have Web routes e.g. |
Since |
The new API route uses the IDs instead of names. So here are 2 URLs:
The first one is the current one. I can tell by just looking at the URL that I will the Linux build of Version 1.2 of the Software. Can I get the same Information with the Second URL? We now have 2 different routes that lead to the same file (I'm generally not an fan of this). You can query the new API route through the API, but you can no longer query the route that is shown in the Browser. There are maybe situations where you need this. e.g. You want to automagically publish a Link on your site for your Nightly build. But your Nightly builds are only available for Patreon, which are logged in on the Gitea instance. So the Link to the Web URL works, but the Link to the API URL will not work, since the API uses different auth. There are also some people who may find it suspicious, when they see another Link in a Install script than they see in the Web Interface. IMHO a API should alwayas give you all Information that you also see in the Web Interface. I know that the Web route does not work with a token, but for public repos this does not matter. If you don't use release downloads from private repos through the API, you will get a degraded experience with no benefits with this PR. We currently support API identification for |
1 Even this PR will do not use But I think your idea about moving file read out of web routes and api routes is a good idea. It should also include git Smart HTTP routes. |
For me, it looks like if this PR changes the API response to this format
For the API itself this is true. But the Bot might just be updating a download script where the Users cares about the URL. |
I'm in favor of merging this PR. The new nice URL's break existing scripts because authentication no longer works. I think the discussion of changing the url's is interesting and good, but we should first make sure that the api can be used as before. |
Even when this PR is merged I will need an API call to get this URL, I won't be able to get it via the UI. |
As we currently have no API only Gitea, I think it's the best to just allow API auth for |
I don't think this PR break anything. The removal of
This PR is just a bugfix and with no any break. If you would like |
Not really. Before We currently have the following case: After your PR we will have the following case: So you obviously break Web Auth to fix API Auth. We need to make it work with both. Especially for Releases, the API might be used by a bot who post the Link somewhere where it can be downloaded when you are logged in. Your new URL also still don't contain the Filename. There are People (including me) who Release and Filename as part of the URL, but that should be a easy fix. |
Maybe you have a misunderstand. I don't think this will break Web Auth of the URL. |
I understand that, but the URL the API returns will not support Web Auth. |
Close as this PR is totally wrong. #26165's problem is basic auth is OK but token auth is not. |
Fix #26165
The problem should be fixed by #25639 but unfortunately it's not. Because custom URLs have been filled into attachments.