-
-
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
actions: login via GITEA_TOKEN to package repository not working #23642
Comments
Token scope was added in 1.19 so perhaps your token needs to be re-issued with a new scope (this happened to me in a slightly different context but where I could see the full error response from gitea which mentioned the token scope being inadequate). |
Did you set your ROOT_RUL in app.ini to |
@dboreham How do you do that? As far as I understood that specific token is a task defined token which would not affect any secrets I have defined myself. gitea/routers/api/actions/runner/utils.go Line 70 in be93e48
I think there is a typo 😉 . I set ROOT_URL at least to |
Does it work from the command line? |
The package repository itself is working. When I try to use a pregenerated secret and use that, it is working as well.
What is not working ist the use of the GITEA_TOKEN to publish data into the package repository.
|
401 Unauthorized is returned by I removed gitea/routers/api/packages/api.go Line 460 in d02e83a
|
Just a note: That looks like it works but you can't upload a container or other things.
|
Partly fixes #23642 Error info: ![image](https://user-images.githubusercontent.com/18380374/227827027-4280a368-ec9e-49e0-bb93-6b496ada7cd9.png) ActionsUser (userID -2) is used to login in to docker in action jobs. Due to we have no permission policy settings of ActionsUser now, ActionsUser can only access public registry by this quick fix.
Partly fixes go-gitea#23642 Error info: ![image](https://user-images.githubusercontent.com/18380374/227827027-4280a368-ec9e-49e0-bb93-6b496ada7cd9.png) ActionsUser (userID -2) is used to login in to docker in action jobs. Due to we have no permission policy settings of ActionsUser now, ActionsUser can only access public registry by this quick fix.
Backport #23729 by @yp05327 Partly fixes #23642 Error info: ![image](https://user-images.githubusercontent.com/18380374/227827027-4280a368-ec9e-49e0-bb93-6b496ada7cd9.png) ActionsUser (userID -2) is used to login in to docker in action jobs. Due to we have no permission policy settings of ActionsUser now, ActionsUser can only access public registry by this quick fix. Co-authored-by: yp05327 <[email protected]>
What is the status on this one? |
It depends on the trigger user's permission to that package. And you can always use a PAT to do that. |
Ok, but 1.19.3 still does not pay respect to that, or? Because the build happens on push through me, I'm the owner of the repo and it still fails with authentication required after using GITEA_TOKEN for a successful Docker Login. Which is the earliest version that works? |
The linked PR is active with 1.20 |
Currently on 1.20.0-rc2 and this works: - name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: git.example.com
username: ${{ gitea.repository_owner }}
password: ${{ secrets.GITEA_TOKEN}} But push fails with:
|
That is right as @KN4CK3R mentioned before: #23642 (comment) Here it got decided to temporarily only allow read only access and postpone the permission check: #23729 (comment) The underlining issue is an ongoing discussion how to manage permissions in general. There is a proposal in #24635 but nothing implemented in that direction yet (AFAIK) |
You can try to specify token within url
|
Same result for me with gitea 1.20.4. How do you push the docker images to the gitea container registry from within the gitea actions? Do you use custom PATs instead the GITEA_TOKEN/GITHUB_TOKEN? |
@PatrickHuetter You must use PATs for writing to package repositories right now. |
Thanks @krombel. I got it working with PATs. |
This should be listed as a missing feature on this page. My organization does not permit static PATs to be used in workflows, which means we can't use that as a workaround. It would have been much easier to figure out this is why the permissions error occurs if it had been listed in the documentation as a current limitation. |
it doesnt work for me with user PAT:
i added some debug logs:
So looks like container.Verify() found the right user, but doesnt fill the IsApiToken and ApiTokenScope data fields. therefore reqPackageAccess denied the access. Gitea version: 1.21.10 built with GNU Make 4.2.1, go1.21.9 : bindata, sqlite, sqlite_unlock_notify |
I cannot reproduce this. Please check your PAT's permission which has read/write packages permission. |
scope: all, and "jenkins" user is added to project with write permission. |
As i said, all permissions are added. i listed the tokes by api:
Response:
|
If the owner of this repo is organization, does this user have the permission to access organization packages? |
I don't think this is implemented. The job token can't be used to publish packages at the moment. |
It look like, token is not working for personal repo (eg: elbandi/test)
I verify, that jenkins user has write permission to elbandi/test: curl -X 'GET' \
'https://git.domain.hu/api/v1/repos/elbandi/test/collaborators/jenkins/permission' \
-H 'accept: application/json' \
-H 'authorization: Basic xxxx' result (look good: jenkins has write role to elbandi/test): {
"permission": "write",
"role_name": "write",
"user": {
"id": 7,
"login": "jenkins",
"login_name": "",
"full_name": "Jenkins build system",
"email": "[email protected]",
"language": "",
"is_admin": false,
"last_login": "1970-01-01T01:00:00+01:00",
"created": "2021-03-03T00:07:56+01:00",
"restricted": false,
"active": true,
"prohibit_login": false,
"location": "",
"website": "",
"description": "",
"visibility": "public",
"followers_count": 0,
"following_count": 0,
"starred_repos_count": 0,
"username": "jenkins"
}
} Try to upload a file as a generic package to elbandi/test:
unsuccessful :( Try to upload a file as a generic package to an organisation package: $ curl --user jenkins:2bcb4b4293d6f624b49d22cdbf8f46b800c65cc5 \
--upload-file README.md \
https://git.elbandi.net/api/packages/kubernetes/generic/test/1.0.0/file.bin
$ it works. |
Sadly, this issue covers quite an important feature, but the discussion has been dissolved by unrelated topics of improper configuration. As highlighted by others, at the very least, a note should be placed here: https://docs.gitea.com/usage/actions/comparison#missing-features I just spent 2 hours assuming that Gitea would support this feature, as it's very common and not listed. Creating a PAT does not solve this issue. A PAT can not be scoped to a single repo, has to be created manually, and managed / copied / or stored (unless we want to end up with multiple PATs) Gitea already associates packages with repos, so mirroring GitHubs should probably be supported without changes to Giteas design. The basic flow should probably be something like this:
This also means that if UserB pushes changes to a repo owned by UserA, the token will have access to the UserA package namespace. Now I don't have any idea what your goals and concerns are, but PATs should be seen as a workaround, not as a solution, since they are clumsy, error-prone and give access to the namespace of the owner. |
@lunny What would be the right way of getting this going? |
Create a PAT with permission of package and use that PAT to do login, push. |
As a temporary workaround I have defined an For this user I created a PAT name: Docker Build and Push
run-name: ${{ gitea.actor }} is running Docker build and push
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to local Gitea registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ env.actions_user }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Docker Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.registry }}/${{ gitea.repository }}:latest Note that I also defined my registry and actions user in my runner's runner:
envs:
registry: gitea.mydomain.tld
actions_user: actions This seems to work perfectly. Or at least for the time being 😄 . Instead of using a dedicated user you could also opt to set your own username as the |
I'm curious how you got that to work? While creating a separate 'actions_user' with a PAT and write access to packages works for me to publish packages for my organization (by setting PACKAGES_TOKEN as a secret at the organization level), I have observed that it is not possible to disable login for that user after creating the PAT, since this does not only prohibit login to the web UI but also to the packages registry using the PAT. |
I have filed a PR here: https://gitea.com/gitea/docs/pulls/77. |
Description
I am having this snippet in a workflow file:
I exchanged
github.repository_owner
withgithub.actor
as well. Bot did not work.I see the following error in the actions run log:
Gitea Version
1.19.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
I am running it in a docker container and am reverse proxying the https port.
Database
None
The text was updated successfully, but these errors were encountered: