aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/web.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-12-12 13:01:17 +0800
committerGitHub <noreply@github.com>2023-12-12 05:01:17 +0000
commit717d0f5934826e0ddfdce176cf3cab303cd74fbb (patch)
tree51d7fb840679d32105240d33b782b05a063bb8a0 /routers/web/web.go
parent4e879fed90665331d2a57e5abee9e0f02372c470 (diff)
downloadgitea-717d0f5934826e0ddfdce176cf3cab303cd74fbb.tar.gz
gitea-717d0f5934826e0ddfdce176cf3cab303cd74fbb.zip
Do some missing checks (#28423)
Diffstat (limited to 'routers/web/web.go')
-rw-r--r--routers/web/web.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/routers/web/web.go b/routers/web/web.go
index da7360f1b8..db0588056b 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -796,6 +796,24 @@ func registerRoutes(m *web.Route) {
}
}
+ individualPermsChecker := func(ctx *context.Context) {
+ // org permissions have been checked in context.OrgAssignment(), but individual permissions haven't been checked.
+ if ctx.ContextUser.IsIndividual() {
+ switch {
+ case ctx.ContextUser.Visibility == structs.VisibleTypePrivate:
+ if ctx.Doer == nil || (ctx.ContextUser.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin) {
+ ctx.NotFound("Visit Project", nil)
+ return
+ }
+ case ctx.ContextUser.Visibility == structs.VisibleTypeLimited:
+ if ctx.Doer == nil {
+ ctx.NotFound("Visit Project", nil)
+ return
+ }
+ }
+ }
+ }
+
// ***** START: Organization *****
m.Group("/org", func() {
m.Group("/{org}", func() {
@@ -976,11 +994,11 @@ func registerRoutes(m *web.Route) {
return
}
})
- })
+ }, reqUnitAccess(unit.TypeProjects, perm.AccessModeRead, true), individualPermsChecker)
m.Group("", func() {
m.Get("/code", user.CodeSearch)
- }, reqUnitAccess(unit.TypeCode, perm.AccessModeRead, false))
+ }, reqUnitAccess(unit.TypeCode, perm.AccessModeRead, false), individualPermsChecker)
}, ignSignIn, context_service.UserAssignmentWeb(), context.OrgAssignment()) // for "/{username}/-" (packages, projects, code)
m.Group("/{username}/{reponame}", func() {