fix: grant limited-org unit read access to authenticated non-members - #38871
Open
waterWang wants to merge 1 commit into
Open
fix: grant limited-org unit read access to authenticated non-members#38871waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
Contributor
|
That was fast, thank you :) |
Contributor
|
Thank you, please add a simple test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
limitedvisibility should show the same tabs aspublic, with the audience narrowed to authenticated users.Root Cause
Organization.UnitPermission()inmodels/organization/org.go:A signed-in non-member has no teams in the org, so the first block (team check) is skipped.
IsPublic()returnstrueonly forVisibleTypePublic, solimitedfalls through toAccessModeNone.This cascades to
services/context/org.gowhereCanReadUnit()wrapsUnitPermission(), andtemplates/org/menu.tmplhides tabs whenCanReadPackagesetc. are false.Fix
Add
(doer != nil && org.Visibility.IsLimited())to the read-access condition:limitedorgs grant read access to authenticated users and deny it to anonymous visitors — matching the documented semantics of the visibility setting.Fixes #38870