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

Allow maximum permission granted to visitor/user #33456

Open
rozmansi opened this issue Jan 31, 2025 · 5 comments
Open

Allow maximum permission granted to visitor/user #33456

rozmansi opened this issue Jan 31, 2025 · 5 comments
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@rozmansi
Copy link

Feature Description

Hi!

I am running a Gitea server with hundreds of repositories. 99% are private.

I want to have a team (e.g. Testers) which has write access to Issues and Wiki for every repository on the server. But, I do not want to have members of this team access to the Code.
I have made a team called Testers, selected All repositories, and filled in the Allow Access to Repository Sections with appropriate level of permissions. Had to set Code unit to No Access.

This works fine for private repositories. Users, having code access via membership of other teams granted per-repository access, can access the code. Other users, members of Testers team, can only use issue tracker and Wiki.

The problem is Public repositories. Any anonymous visitor can read the code of a public repository. But the members of the Testers team cannot. They may Sign Out or use an In-private browser to access the code of a public repository. But not while being signed in.

Shouldn't Gitea use maximum granted permission when combining Public permissions with team permissions?

If some repo is public, it is annoying users need to sign out to get more access to this same repo.

Screenshots

No response

@rozmansi rozmansi added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Jan 31, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jan 31, 2025

I think it is supported in main branch (will be 1.24 for next release)

-> Support public code/issue access for private repositories #33127 (wiki is already supported in 1.23)

And for anonymous access, there is a draft PR: WIP: Add anonymous access support for private repositories #33257

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jan 31, 2025
@wxiaoguang
Copy link
Contributor

Does it work for you?

@rozmansi
Copy link
Author

rozmansi commented Feb 6, 2025

Does it work for you?

Sorry, I am running a production server, so I guess I'll wait for the 1.24 release to confirm.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 6, 2025

Without really deploying an instance, does the design look good to you?

Create a private repo, and set Default access permission for all signed-in users: to Read

@rozmansi
Copy link
Author

Without really deploying an instance, does the design look good to you?

Not quite. Suppose you have the following scenario:

  1. Team Project X needs full control of specific repositories. User Alice is a member of this team
  2. Team Testers, need Issues/Wiki control of all repositories. User Bob is a member of this team.
  3. User Clara is not a member of either team. She may have some access to other repos on this server, but she is not working on Project X, nor is a tester.

Now, we have some repositories.

  • Private repo X, team Project X has full access to it.
  • Private repo Y.
  • Public repo P.

Now, focus on user Bob.
He can use the Issues/Wiki of all projects. Correct.
He cannot see the Code of private repos X and Y. Correct. He is not a developer.
Since repo P is public, user Bob should have at least that many permissions anonymous visitors have. But since he is a member of the group Testers, he is denied Code access to all repos: including the public ones. So, Bob needs to sign-out of Gitea to gain enough permissions to read code in the public repository P.

Create a private repo, and set Default access permission for all signed-in users: to Read

This means I give all signed-in users permission to use Issues/Wiki. Including Clara, who is not a member of any team with access to this private repository, neither a member of Testers group.

In other words your proposal grants too much permission to private repositories.

To make matters worse, I am using LDAP authentication and have quite a lot of users that can log in to Gitea. They are developers of some repos, but not others. Some users are testers only. So, I would not be comfortable to select Default access permission for all signed-in users: to Read and allow developers access to foreign private repositories.

Maybe the solution to my proposal could be simply implemented just by changing the ACL checks from

if mayAccess(repo, user, unit, forReading) {
    read_stuff();
}

to

if mayAccess(repo, user, unit, forReading) || (isPublic(repo) && mayAccessAnonymously(repo, unit, forReading)) {
    read_stuff();
}

The catch is the || fallback for public repos.

@wxiaoguang wxiaoguang removed the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

2 participants