Skip to content

fix: grant limited-org unit read access to authenticated non-members - #38871

Open
waterWang wants to merge 1 commit into
go-gitea:mainfrom
waterWang:fix/org-limited-visibility-38870
Open

fix: grant limited-org unit read access to authenticated non-members#38871
waterWang wants to merge 1 commit into
go-gitea:mainfrom
waterWang:fix/org-limited-visibility-38870

Conversation

@waterWang

Copy link
Copy Markdown
Contributor

Problem

An organization set to Limited ("Visible only to authenticated users") hides the Packages, Code, and Projects tabs for signed-in non-members. Only the Repositories tab is shown. While Packages still loads if the URL is entered directly, Code and Projects return 404.

The same organization set to Public shows all tabs to everyone, including anonymous visitors.

Expected: limited visibility should show the same tabs as public, with the audience narrowed to authenticated users.

Root Cause

Organization.UnitPermission() in models/organization/org.go:

if org.Visibility.IsPublic() {
    return perm.AccessModeRead
}
return perm.AccessModeNone

A signed-in non-member has no teams in the org, so the first block (team check) is skipped. IsPublic() returns true only for VisibleTypePublic, so limited falls through to AccessModeNone.

This cascades to services/context/org.go where CanReadUnit() wraps UnitPermission(), and templates/org/menu.tmpl hides tabs when CanReadPackages etc. are false.

Fix

Add (doer != nil && org.Visibility.IsLimited()) to the read-access condition:

if org.Visibility.IsPublic() || (doer != nil && org.Visibility.IsLimited()) {
    return perm.AccessModeRead
}

limited orgs grant read access to authenticated users and deny it to anonymous visitors — matching the documented semantics of the visibility setting.

Fixes #38870

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 11, 2026
@dianaStr7

Copy link
Copy Markdown
Contributor

That was fast, thank you :)

@wxiaoguang

Copy link
Copy Markdown
Contributor

Thank you, please add a simple test.

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. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Organizations with limited visibility hide every tab except Repositories for non-members

4 participants