Skip to content
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 users with code unit access permission only can not access contributors page #32299

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Oct 21, 2024

As we added contributor page in activity, the permission check isn't update correctly.
We should show activity unit when user only have code read permission, for the contributor page, but it is impossible now.

Case 1: code unit no access, pr unit has access
Before: (Empty page)
image

After:
image

Case 2: code unit has access, pr unit has no access
Before: You can not see Activity tab
After: (redirect to contributors page)
image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 21, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 21, 2024
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Oct 21, 2024
@yp05327 yp05327 marked this pull request as draft October 21, 2024 04:53
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 21, 2024
@yp05327 yp05327 marked this pull request as ready for review October 21, 2024 05:00
@yp05327 yp05327 changed the title Improve permission check for activity pages Improve permission check for repo activity pages Oct 21, 2024
@yp05327 yp05327 changed the title Improve permission check for repo activity pages Fix users with code unit access permission only can not access contributors page Oct 21, 2024
@@ -1446,17 +1446,17 @@ func registerRoutes(m *web.Router) {
m.Group("/contributors", func() {
m.Get("", repo.Contributors)
m.Get("/data", repo.ContributorsData)
})
}, reqRepoCodeReader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just questionable, why it needs to check this permission? Does the handler expose any "real code"?

Copy link
Contributor Author

@yp05327 yp05327 Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original logic in the template needs code permission or it will display nothing.
So, I think it should have same permission checks in router, or when you removed them in the menu in UI, but you can still access these pages by just editing the URL.

And for the original logic, maybe it depends on the definition of Code: does author info include in it?
These information come from commits, and commits are Code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I have no interest to touch the legacy logic at the moment because it is quite a mess (I did do some quick fixes just because these "bugs" affected end users and are potentially related to my PRs).


The real problem is that there is NO clear definition for the "permission" system, people just patched the code again and again, and there are more serious abuses like "issue reader / pull reader permissions are mixed (/{type:issues|pulls})".

Maybe you could define these permissions clearly first before code work. The definition should be reasonable to most end users and daily usage, but not by what it literally looks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, anything contain the information from commits (no matter from original repo or forks) or themselves should be controlled by code unit permission, as codes are managed by git, and git uses commits to record the status/changes of these codes.
I'm not sure whether it is acceptable to others. What's your opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why they need such strict rules?

Permissions should be as loose as possible to satisfy every users for various use cases, as long as the permission design doesn't cause harm or leak sensitive data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind:

The purpose of a permission system is to "prevent from users doing harm to a repo".

  • code permission means the user could access the full code. Disabling it means that prevent the user from accessing the full code. The purpose should be "protect the full code from leaking"
  • pr read means that the user could discuss and review the code change (not the full code) , approve or reject.
  • activity means that the user could see the statistics of the repo (commits number and authors do not really leak code)

So, that's why I would like to keep the commit/files tabs on the "pr" page, and would like to make users could read the statistics of the repo as much as possible (useful and no harm)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give me some time to think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants