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

[feature] Disable or Reduce "Explore" Page #5080

Open
gocursor opened this issue Mar 6, 2018 · 6 comments
Open

[feature] Disable or Reduce "Explore" Page #5080

gocursor opened this issue Mar 6, 2018 · 6 comments
Labels
🎯 feature Categorizes as related to a new feature

Comments

@gocursor
Copy link

gocursor commented Mar 6, 2018

Please add a configuration option to disable the "Explore" page - even when signed in.

Reason: I want that the user sees only the repositories and collaborators he works on and hide everything else from him (including all other users and organizations which are not relevant for him).

Another possible solution would be to add a configuration option "hideUsers" and "hideOrganizations" which would display "Explore" page, but show only the "Repositories" subpage (because only user-related repositories are displayed).

@unknwon unknwon added the 🎯 feature Categorizes as related to a new feature label Mar 6, 2018
@unknwon unknwon added this to the 0.12 milestone Mar 6, 2018
@gocursor
Copy link
Author

gocursor commented Mar 6, 2018

Thank you for adding this immediately to the next milestone (0.12)! And also thank you for providing us such a great product for free!

@novalis111
Copy link

As a workaround i just added this to nginx server block:

location /explore { deny all; }

But a more fine-grained solution would be great. I just migrated from gitlab and love gogs! Awesome project.

@miqmago
Copy link

miqmago commented Apr 12, 2019

Meanwhile, could you point me to any quick hacky solution? Don't mind if it's not perfect. I've tried to download the source code, checkout 0.11.86 branch, modify routes/home.go and templates/explore/navbar.tmpl and add:

diff --git a/routes/home.go b/routes/home.go
index 9835b55..215cd70 100644
--- a/routes/home.go
+++ b/routes/home.go
@@ -131,6 +131,7 @@ func ExploreUsers(c *context.Context) {
        c.Data["Title"] = c.Tr("explore")
        c.Data["PageIsExplore"] = true
        c.Data["PageIsExploreUsers"] = true
+       c.Data["PageIsAdmin"] = true
 
        RenderUserSearch(c, &UserSearchOptions{
                Type:     models.USER_TYPE_INDIVIDUAL,
@@ -146,6 +147,7 @@ func ExploreOrganizations(c *context.Context) {
        c.Data["Title"] = c.Tr("explore")
        c.Data["PageIsExplore"] = true
        c.Data["PageIsExploreOrganizations"] = true
+       c.Data["PageIsAdmin"] = true
 
        RenderUserSearch(c, &UserSearchOptions{
                Type:     models.USER_TYPE_ORGANIZATION,
diff --git a/templates/explore/navbar.tmpl b/templates/explore/navbar.tmpl
index 465e73e..1bbb109 100644
--- a/templates/explore/navbar.tmpl
+++ b/templates/explore/navbar.tmpl
@@ -4,11 +4,13 @@
                <a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubURL}}/explore/repos">
                        <span class="octicon octicon-repo"></span> {{.i18n.Tr "explore.repos"}}
                </a>
+               {{if .LoggedUser.IsAdmin}}
                <a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubURL}}/explore/users">
                        <span class="octicon octicon-person"></span> {{.i18n.Tr "explore.users"}}
                </a>
                <a class="{{if .PageIsExploreOrganizations}}active{{end}} item" href="{{AppSubURL}}/explore/organizations">
                        <span class="octicon octicon-organization"></span> {{.i18n.Tr "explore.organizations"}}
                </a>
+               {{end}}
        </div>
 </div>

Recompile, but a normal user is still able to view the users list. Don't know if I'm missing something...

@miqmago
Copy link

miqmago commented Apr 12, 2019

Sorry for last comment, it works, but have to advise that url routes are still accessible. So at least not visible :)

@miqmago
Copy link

miqmago commented Apr 25, 2019

Thanks to go-gitea/gitea#2908 (comment) I was able to protect routes against url browsing too:

--- a/cmd/web.go
+++ b/cmd/web.go
@@ -177,6 +177,7 @@ func runWeb(c *cli.Context) error {
        ignSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: setting.Service.RequireSignInView})
        ignSignInAndCsrf := context.Toggle(&context.ToggleOptions{DisableCSRF: true})
        reqSignOut := context.Toggle(&context.ToggleOptions{SignOutRequired: true})
+       reqAdmin := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true})
 
        bindIgnErr := binding.BindIgnErr
 
@@ -191,8 +192,8 @@ func runWeb(c *cli.Context) error {
                        c.Redirect(setting.AppSubURL + "/explore/repos")
                })
                m.Get("/repos", routes.ExploreRepos)
-               m.Get("/users", routes.ExploreUsers)
-               m.Get("/organizations", routes.ExploreOrganizations)
+               m.Get("/users", reqAdmin, routes.ExploreUsers)
+               m.Get("/organizations", reqAdmin, routes.ExploreOrganizations)
        }, ignSignIn)
        m.Combo("/install", routes.InstallInit).Get(routes.Install).
                Post(bindIgnErr(form.Install{}), routes.InstallPost)
@@ -261,8 +262,6 @@ func runWeb(c *cli.Context) error {
        })
        // ***** END: User *****
 
-       reqAdmin := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true})
-
        // ***** START: Admin *****
        m.Group("/admin", func() {
                m.Get("", admin.Dashboard)

@No54
Copy link

No54 commented Nov 13, 2019

"[Service] REQUIRE_SIGNIN_VIEW = true " is prefered.

@unknwon unknwon removed this from the Triaging priority milestone Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 feature Categorizes as related to a new feature
Projects
None yet
Development

No branches or pull requests

5 participants