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

Add ui.explore settings to control view of explore pages (2) #14094

Merged

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Dec 21, 2020

This is an alternative PR to #13687.

Add [ui.explore] settings to allow restricting the
explore pages to logged in users only and to disable the users explore page.

The two proposed settings are:

  • REQUIRE_SIGNIN_VIEW: Only allows access to the explore pages if the
    user is signed in. Also restricts
    • /api/v1/user/search
    • /api/v1/users/{username}
    • /api/v1/users/{username}/repos
    • but does not restrict /api/v1/users/{username}/heatmap
  • DISABLE_USERS_PAGE: Disables the /explore/users page

Fix #2908

Close #13687

Signed-off-by: Andrew Thornton [email protected]

zeripath and others added 11 commits November 24, 2020 09:39
Add `[ui.explore]` settings to allow restricting the
explore pages to logged in users only and to restrict
the showing of users to only those with publically available
repositories.

The two proposed settings are:

- `REQUIRE_SIGNIN_VIEW`: Only allows access to the explore pages if the
user is signed in. Also restricts `/api/v1/user/search`.
- `ONLY_SHOW_USERS_WITH_PUBLIC_REPOS`: Only shows users with public
repos on the explore page. `/api/v1/user/search` will only show users
with public repos unless the user the is signed in.

Fix go-gitea#2908

Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: a1012112796 <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
Signed-off-by: Andrew Thornton <[email protected]>
@zeripath zeripath added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Dec 21, 2020
@zeripath zeripath added this to the 1.14.0 milestone Dec 21, 2020
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@34df4e5). Click here to learn what that means.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #14094   +/-   ##
=========================================
  Coverage          ?   42.33%           
=========================================
  Files             ?      726           
  Lines             ?    77756           
  Branches          ?        0           
=========================================
  Hits              ?    32918           
  Misses            ?    39431           
  Partials          ?     5407           
Impacted Files Coverage Δ
modules/setting/setting.go 45.47% <ø> (ø)
routers/home.go 47.19% <33.33%> (ø)
routers/api/v1/api.go 79.33% <60.00%> (ø)
routers/routes/macaron.go 92.54% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34df4e5...d35b5fe. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 21, 2020
@lafriks
Copy link
Member

lafriks commented Dec 21, 2020

Is there a use case where REQUIRE_SIGNIN_VIEW is needed? Imho that should be always true and we should not return list of users to unauthorized users

@techknowlogick
Copy link
Member

@lafriks REQUIRE_SIGNIN_VIEW is for more than just users, but all explore pages (such as repos & orgs too).

@lafriks
Copy link
Member

lafriks commented Dec 22, 2020

imho we should remove users page completely, I don't see much use for it to be honest

@lafriks lafriks added type/enhancement An improvement of existing functionality and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Dec 22, 2020
@lunny
Copy link
Member

lunny commented Dec 22, 2020

imho we should remove users page completely, I don't see much use for it to be honest

Maybe for a public big site, users want to find some people they want to contact.

@lunny
Copy link
Member

lunny commented Feb 18, 2021

Please resolve the conflicts

@zeripath
Copy link
Contributor Author

Conflicts fixed.

@@ -265,6 +270,10 @@ var (
Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
Keywords: "go,git,self-hosted,gitea",
},
Explore: struct {
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
Copy link
Member

Choose a reason for hiding this comment

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

I think maybe move this to service is better? We need a feature to disable all the user explore include APIs. A standalone setting for UI search seems not enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really think we have way too much stuff in [service] already - so if it's going in there it should go in [service.explore] I think.

Copy link
Member

Choose a reason for hiding this comment

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

+1 on [service.explore]

@art-ist
Copy link

art-ist commented Mar 5, 2021

You are checking for the ui.explore setting when http://gitea/api/v1/users/search is called. But

curl -X GET "http://gitea/api/v1/users/joe" -H  "accept: application/json"

was our next first guess. So checking on

m.Group("/{username}", func() {

is required as well.

Originally posted by @art-ist in #2908 (comment)

@zeripath
Copy link
Contributor Author

zeripath commented Mar 5, 2021

@art-ist I wrote this PR 3 months ago in response so I cannot fully remember all of the details but...

I am absolutely certain that you cannot just block /api/v1/users/{name} and in any case it is pointless as you can just go to /{name}


OK I think I'm wrong here and the UI doesn't rely on this path at all. I guess therefore it's fine to be blocked too.

Copy link
Member

@noerw noerw left a comment

Choose a reason for hiding this comment

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

Oher than the config location this LGBTTOPRTM (looks good and better than the other PR to me).

I think this more general config will serve more users concerned about privacy, a more finegrained control like ONLY_SHOW_USERS_WITH_PUBLIC_REPOS could be added later as needed

I thought more about this, see #2908 (comment) . In short:
We should probably allow for more flexibility and don't add a bool flag DISABLE_USERS_PAGE, but USERS_PAGE with 3 states OPT_OUT, OPT_IN, DISABLED, (where the first is the current behaviour, and the second can be implemented later)

@@ -265,6 +270,10 @@ var (
Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
Keywords: "go,git,self-hosted,gitea",
},
Explore: struct {
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
Copy link
Member

Choose a reason for hiding this comment

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

+1 on [service.explore]

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 10, 2021
@noerw noerw mentioned this pull request Mar 10, 2021
7 tasks
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 10, 2021
@6543
Copy link
Member

6543 commented Mar 11, 2021

🚀

Copy link
Member

@noerw noerw left a comment

Choose a reason for hiding this comment

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

Thinking about it again again, the opt-in feature can also be realised via a separate flag, so please ignore my above comment

@zeripath zeripath merged commit c8e5c79 into go-gitea:master Mar 11, 2021
@zeripath zeripath deleted the fix-2908-no-user-explore-page-settings branch March 11, 2021 13:40
@6543 6543 mentioned this pull request Mar 11, 2021
1 task
@go-gitea go-gitea locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide users from public view
10 participants