Skip to content

Commit 12bd60b

Browse files
authored
Merge branch 'main' into refactor-of-32211
2 parents 4d9df45 + 9206fbb commit 12bd60b

File tree

14 files changed

+77
-52
lines changed

14 files changed

+77
-52
lines changed

cmd/admin_auth_ldap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
386386
return a.createAuthSource(ctx, authSource)
387387
}
388388

389-
// updateLdapBindDn updates a new LDAP (simple auth) authentication source.
389+
// updateLdapSimpleAuth updates a new LDAP (simple auth) authentication source.
390390
func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
391391
ctx, cancel := installSignals()
392392
defer cancel()

custom/conf/app.example.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,24 @@ LEVEL = Info
907907
;; Valid site url schemes for user profiles
908908
;VALID_SITE_URL_SCHEMES=http,https
909909

910+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
911+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
912+
;[service.explore]
913+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
914+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
915+
;;
916+
;; Only allow signed in users to view the explore pages.
917+
;REQUIRE_SIGNIN_VIEW = false
918+
;;
919+
;; Disable the users explore page.
920+
;DISABLE_USERS_PAGE = false
921+
;;
922+
;; Disable the organizations explore page.
923+
;DISABLE_ORGANIZATIONS_PAGE = false
924+
;;
925+
;; Disable the code explore page.
926+
;DISABLE_CODE_PAGE = false
927+
;;
910928

911929
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
912930
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

models/issues/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ func GetPinnedIssues(ctx context.Context, repoID int64, isPull bool) (IssueList,
872872
return issues, nil
873873
}
874874

875-
// IsNewPinnedAllowed returns if a new Issue or Pull request can be pinned
875+
// IsNewPinAllowed returns if a new Issue or Pull request can be pinned
876876
func IsNewPinAllowed(ctx context.Context, repoID int64, isPull bool) (bool, error) {
877877
var maxPin int
878878
_, err := db.GetEngine(ctx).SQL("SELECT COUNT(pin_order) FROM issue WHERE repo_id = ? AND is_pull = ? AND pin_order > 0", repoID, isPull).Get(&maxPin)

models/issues/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ func GetPullRequestByIssueID(ctx context.Context, issueID int64) (*PullRequest,
701701
return pr, pr.LoadAttributes(ctx)
702702
}
703703

704-
// GetPullRequestsByBaseHeadInfo returns the pull request by given base and head
704+
// GetPullRequestByBaseHeadInfo returns the pull request by given base and head
705705
func GetPullRequestByBaseHeadInfo(ctx context.Context, baseID, headID int64, base, head string) (*PullRequest, error) {
706706
pr := &PullRequest{}
707707
sess := db.GetEngine(ctx).

modules/setting/service.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ var Service = struct {
9090

9191
// Explore page settings
9292
Explore struct {
93-
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
94-
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
93+
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
94+
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
95+
DisableOrganizationsPage bool `ini:"DISABLE_ORGANIZATIONS_PAGE"`
96+
DisableCodePage bool `ini:"DISABLE_CODE_PAGE"`
9597
} `ini:"service.explore"`
9698
}{
9799
AllowedUserVisibilityModesSlice: []bool{true, true, true},

routers/api/v1/api.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,20 @@ func reqToken() func(ctx *context.APIContext) {
356356

357357
func reqExploreSignIn() func(ctx *context.APIContext) {
358358
return func(ctx *context.APIContext) {
359-
if setting.Service.Explore.RequireSigninView && !ctx.IsSigned {
359+
if (setting.Service.RequireSignInView || setting.Service.Explore.RequireSigninView) && !ctx.IsSigned {
360360
ctx.Error(http.StatusUnauthorized, "reqExploreSignIn", "you must be signed in to search for users")
361361
}
362362
}
363363
}
364364

365+
func reqUsersExploreEnabled() func(ctx *context.APIContext) {
366+
return func(ctx *context.APIContext) {
367+
if setting.Service.Explore.DisableUsersPage {
368+
ctx.NotFound()
369+
}
370+
}
371+
}
372+
365373
func reqBasicOrRevProxyAuth() func(ctx *context.APIContext) {
366374
return func(ctx *context.APIContext) {
367375
if ctx.IsSigned && setting.Service.EnableReverseProxyAuthAPI && ctx.Data["AuthedMethod"].(string) == auth.ReverseProxyMethodName {
@@ -955,7 +963,7 @@ func Routes() *web.Router {
955963

956964
// Users (requires user scope)
957965
m.Group("/users", func() {
958-
m.Get("/search", reqExploreSignIn(), user.Search)
966+
m.Get("/search", reqExploreSignIn(), reqUsersExploreEnabled(), user.Search)
959967

960968
m.Group("/{username}", func() {
961969
m.Get("", reqExploreSignIn(), user.GetInfo)

routers/web/explore/code.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ const (
2121

2222
// Code render explore code page
2323
func Code(ctx *context.Context) {
24-
if !setting.Indexer.RepoIndexerEnabled {
24+
if !setting.Indexer.RepoIndexerEnabled || setting.Service.Explore.DisableCodePage {
2525
ctx.Redirect(setting.AppSubURL + "/explore")
2626
return
2727
}
2828

29-
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
29+
ctx.Data["UsersPageIsDisabled"] = setting.Service.Explore.DisableUsersPage
30+
ctx.Data["OrganizationsPageIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
3031
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
3132
ctx.Data["Title"] = ctx.Tr("explore")
3233
ctx.Data["PageIsExplore"] = true

routers/web/explore/org.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import (
1414

1515
// Organizations render explore organizations page
1616
func Organizations(ctx *context.Context) {
17-
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
17+
if setting.Service.Explore.DisableOrganizationsPage {
18+
ctx.Redirect(setting.AppSubURL + "/explore")
19+
return
20+
}
21+
22+
ctx.Data["UsersPageIsDisabled"] = setting.Service.Explore.DisableUsersPage
23+
ctx.Data["CodePageIsDisabled"] = setting.Service.Explore.DisableCodePage
1824
ctx.Data["Title"] = ctx.Tr("explore")
1925
ctx.Data["PageIsExplore"] = true
2026
ctx.Data["PageIsExploreOrganizations"] = true

routers/web/explore/repo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
165165

166166
// Repos render explore repositories page
167167
func Repos(ctx *context.Context) {
168-
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
168+
ctx.Data["UsersPageIsDisabled"] = setting.Service.Explore.DisableUsersPage
169+
ctx.Data["OrganizationsPageIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
170+
ctx.Data["CodePageIsDisabled"] = setting.Service.Explore.DisableCodePage
169171
ctx.Data["Title"] = ctx.Tr("explore")
170172
ctx.Data["PageIsExplore"] = true
171173
ctx.Data["PageIsExploreRepositories"] = true

routers/web/explore/user.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,
131131
// Users render explore users page
132132
func Users(ctx *context.Context) {
133133
if setting.Service.Explore.DisableUsersPage {
134-
ctx.Redirect(setting.AppSubURL + "/explore/repos")
134+
ctx.Redirect(setting.AppSubURL + "/explore")
135135
return
136136
}
137+
ctx.Data["OrganizationsPageIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
138+
ctx.Data["CodePageIsDisabled"] = setting.Service.Explore.DisableCodePage
137139
ctx.Data["Title"] = ctx.Tr("explore")
138140
ctx.Data["PageIsExplore"] = true
139141
ctx.Data["PageIsExploreUsers"] = true

0 commit comments

Comments
 (0)