-
-
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
fix(api): owner ID should be zero when created repo secret #31715
Conversation
- Change `owner.ID` to `0` in the `CreateOrUpdateSecret` function call Signed-off-by: Bo-Yi Wu <[email protected]>
- Remove unused variable `owner` from `CreateOrUpdateSecret` function Signed-off-by: Bo-Yi Wu <[email protected]>
- Remove unused `owner` variable in `DeleteSecret` function - Change `DeleteSecretByName` function call to use `0` instead of `owner.ID` Signed-off-by: Bo-Yi Wu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't get it, why?
And how to handle deleting org?
gitea/models/organization/org.go
Line 404 in 0fe9f93
&secret_model.Secret{OwnerID: org.ID}, |
Yes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood. I get it now.
* giteaofficial/main: Set owner id to zero when GetRegistrationToken for repo (go-gitea#31725) fix(api): owner ID should be zero when created repo secret (go-gitea#31715) Fix API endpoint for registration-token (go-gitea#31722) Fix loadRepository error when access user dashboard (go-gitea#31719) Add permission check when creating PR (go-gitea#31033)
Fix #31707. Also related to #31715. Some Actions resources could has different types of ownership. It could be: - global: all repos and orgs/users can use it. - org/user level: only the org/user can use it. - repo level: only the repo can use it. There are two ways to distinguish org/user level from repo level: 1. `{owner_id: 1, repo_id: 2}` for repo level, and `{owner_id: 1, repo_id: 0}` for org level. 2. `{owner_id: 0, repo_id: 2}` for repo level, and `{owner_id: 1, repo_id: 0}` for org level. The first way seems more reasonable, but it may not be true. The point is that although a resource, like a runner, belongs to a repo (it can be used by the repo), the runner doesn't belong to the repo's org (other repos in the same org cannot use the runner). So, the second method makes more sense. And the first way is not user-friendly to query, we must set the repo id to zero to avoid wrong results. So, #31715 should be right. And the most simple way to fix #31707 is just: ```diff - shared.GetRegistrationToken(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.ID) + shared.GetRegistrationToken(ctx, 0, ctx.Repo.Repository.ID) ``` However, it is quite intuitive to set both owner id and repo id since the repo belongs to the owner. So I prefer to be compatible with it. If we get both owner id and repo id not zero when creating or finding, it's very clear that the caller want one with repo level, but set owner id accidentally. So it's OK to accept it but fix the owner id to zero.
I was unable to create a backport for 1.22. @appleboy, please send one manually. 🍵
|
…31715) - Change condition to include `RepoID` equal to 0 for organization secrets --------- Signed-off-by: Bo-Yi Wu <[email protected]> Co-authored-by: Giteabot <[email protected]>
…31811) - Change condition to include `RepoID` equal to 0 for organization secrets Backport #31715 by @appleboy Signed-off-by: Bo-Yi Wu <[email protected]>
RepoID
equal to 0 for organization secrets