-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
At least t̶w̶o̶ three API calls don't work #3842
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
Comments
Seeme to me the log shows two completely different problems:
Can s/o confirm &&/|| fix this? |
Little code to test against try.gitea.io read TOKEN
curl -s "https://try.gitea.io/api/v1/repos/gitea/gitea/branches" -H "Authorization: token $TOKEN" | jq ".[].name"
> … all branches …
curl -s "https://try.gitea.io/api/v1/repos/gitea/gitea/commits/HEAD/statuses" -H "Authorization: token $TOKEN"
> []
curl -s "https://try.gitea.io/api/v1/repos/gitea/gitea/commits/fa3ceb610d/statuses" -H "Authorization: token $TOKEN"
> []
curl -s "https://try.gitea.io/api/v1/repos/gitea/gitea/commits/fa3ceb610d579c64142321ad4c82398a9d0bfde0/statuses" -H "Authorization: token $TOKEN"
> [] |
Does |
I tried it and voilà curl -s "$SERVER/api/v1/users/$USER/repos" -H "Authorization: token $TOKEN"
> … all repos …
curl -s "$SERVER/api/v1/users/$USER/tokens" -H "Authorization: token $TOKEN"
> (empty)
curl -D - -s "$SERVER/api/v1/users/$USER/tokens" -H "Authorization: token $TOKEN"
> HTTP/1.1 401 Unauthorized
> …
> Content-Length: 0 So I also don't get a response (same for the |
I like to reference to #4234 also |
@stevegt as you've mentioned in #4243 it must be used
the result for listing tokens is the same, an empty array.
|
I'm confused, what do you guys think, is "Unauthorized" it a Gitea bug (a bug in the API) or just a missuse? I think the first b/c
|
Lines 302 to 306 in 85414d8
Which is set here Lines 125 to 143 in 85414d8
Also interested in knowing what status-code you get for |
@bkcsoft hmm interesting. Indeed, listing only with basic auth work - even if this account is secured by 2FA.
I also noticed that the
|
So I'm running gitea in a setup doing SSL client certificate authentication in a reverse proxy, and injecting that as a header for gitea to use. Needless to say, that breaks the tokens api totally. I have a patch which hacks in detection for client cert auth as well as basic auth in this path, but the whole logic here seems not great. Any thoughts from gitea maintainers on seeing a rework for this? It seems there are some (expected?) differences to the regular authentication rules, but they aren't well codified. What should they be? |
Sidenote, in regards to 2FA, GitHub requires a header to be set with the rotating code in regards to requesting URLs with basic auth. |
I just wanted to report that v1.5 does not fix the API problems I reported initially:
This is not an authorization problem! Test: > curl -s https://try.gitea.io/api/v1/repos/gitea/gitea/branches
(…works…)
> curl -s https://try.gitea.io/api/v1/repos/gitea/gitea/branches | jq -r '.[] | select(.name | match("release/v1.5")) | .commit.id'
cfe6941905de745aed1f9297d9717249f53e6e67
> curl -D - -s https://try.gitea.io/api/v1/repos/gitea/gitea/commits/release%2Fv1.5/statuses
(HTTP 200 - works but empty #branch)
> curl -D - -s https://try.gitea.io/api/v1/repos/gitea/gitea/commits/v1.5.0/statuses
(HTTP 200 - works but empty #tag)
> curl -D - -s https://try.gitea.io/api/v1/repos/gitea/gitea/commits/cfe6941905de745aed1f9297d9717249f53e6e67/statuses
(HTTP 200 - works but empty #commit)
> curl -D - -s https://try.gitea.io/api/v1/repos/gitea/gitea/commits/HEAD/statuses
(HTTP 200 - works but empty #bonus:reference)
> curl -D - -s https://try.gitea.io/api/v1/repos/gitea/gitea/statuses/cfe6941905de745aed1f9297d9717249f53e6e67
(HTTP 200 - works but empty #otherEndpoint) Also, releasing still fails > curl -D - -X POST "https://$server/api/v1/repos/{owner}/{repo}/releases" -H "accept: application/json" -H "Authorization: token $token" -H "Content-Type: application/json" -d "{ \"body\": \"This is just a test release\", \"draft\": true, \"name\": \"my test\", \"prerelease\": true, \"tag_name\": \"testing\", \"target_commitish\": \"$commit\"}"
HTTP/1.1 404 Not Found
Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
Set-Cookie: i_like_gitea=48de81100517a47c; Path=/; HttpOnly
Set-Cookie: _csrf=XFBcIQxaBl1YNe9qFTRmh0L8oUI6MTUzNDE3MjEyNzc1NDkwNzM4Nw%3D%3D; Path=/; Expires=Tue, 14 Aug 2018 14:55:27 GMT
X-Frame-Options: SAMEORIGIN
Date: Mon, 13 Aug 2018 14:55:27 GMT
Content-Length: 0 On a side note: there is no API endpoint for tags and the releases endpoint only shows releases (which is kind-a logical) Is this working for anybody/nobody? Am I using it wrong? |
I can report that pretty obviouse there is no result as all requests are translated into the following sql SELECT `id`, `index`, `repo_id`, `state`, `sha`, `target_url`, `description`, `context`, `creator_id`, `created_unix`, `updated_unix` FROM `commit_status` WHERE (repo_id = ?) AND (sha = ?) LIMIT 10 but the table |
I seem to have solved the problem: commit status is not the commit itself but some state that you could set and afterwords read. So the problem seems to be that commit status can't be set to external commits? At least it is in need of documentation. But the API might even work as expected but was never filled with any data. So: commit/status != commit Another documentation problem I couldn't solve even after reading > curl -D - -s "https://$server/api/v1/repos/$user/$repo/archive/HEAD -H "Authorization: token $token"
HTTP/1.1 404 Not Found
… So after all I'm still missing a way to access the repository and it's commit logs itself |
There was just a code change that went through for creating releases. |
Thank you for the information, I will check with the next release. |
I still have the issue for the release creation with the version 1.5.2. I can fetch the different rleases, create an issue but I cannot create a release. Here is the python code I used to test it, which returns a 404 error.
Update: |
Probably a quite stupid question, but: What did you use as "target_commitish"? Did you literally use "string" or a real commitId/branch:HEAD/etc...? |
@HoffmannP you can use branch/tag/full commitid/short commitid |
@lunny that's how I understand it as well, I was just wondering what @eapetitfils was using |
@HoffmannP Before #5076 merged, you can only use branch name, but #5076 fixed that. |
@HoffmannP Not that stupid as I was just using "string", which works on try.gitea.io with CURL. I did some tests with a proper value (master:HEAD and the short commitid), but with the same results. I tried the following that works with CURL: but does not work with python:
returns: And both methods return an error 404 on my work server. I will do more test on my work server (installed on Ubuntu directly with the binary, no docker) as there should not be a difference between try.gitea.io and it. Then I will try to understand why the python code does not work as CURL, even though the adjusted code can be used to create issues. |
I found the problem in the python code. I was not preparing properly the payload and not setting the headers accordingly. Here is what it should be
Also, the 404 error on my own server somehow fixed itself with an upgrade to 1.6.2. |
[x]
):Description
At least two API calls don't work:
Getting a special commit (in my example the latest commit in a branch) via
/repos/{owner}/{repo}/commits/{ref}/statuses
Creating a release via
/repos/{owner}/{repo}/releases
Tested with newest Docker version
Test with swagger command interface and from outside (using AuthToken)
The text was updated successfully, but these errors were encountered: