diff --git a/cmd/drone-server/server.go b/cmd/drone-server/server.go index 903c92a4c..be82d6fb5 100644 --- a/cmd/drone-server/server.go +++ b/cmd/drone-server/server.go @@ -671,7 +671,6 @@ func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) { droneserver.Config.Services.Secrets = setupSecretService(c, v) droneserver.Config.Services.Senders = sender.New(v, v) droneserver.Config.Services.Environ = setupEnvironService(c, v) - droneserver.Config.Services.Limiter = setupLimiter(c, v) if endpoint := c.String("gating-service"); endpoint != "" { droneserver.Config.Services.Senders = sender.NewRemote(endpoint) diff --git a/cmd/drone-server/setup.go b/cmd/drone-server/setup.go index f16affa7e..16f5934db 100644 --- a/cmd/drone-server/setup.go +++ b/cmd/drone-server/setup.go @@ -66,10 +66,6 @@ func setupEnvironService(c *cli.Context, s store.Store) model.EnvironService { return nil } -func setupLimiter(c *cli.Context, s store.Store) model.Limiter { - return new(model.NoLimit) -} - func setupPubsub(c *cli.Context) {} func setupStream(c *cli.Context) {} func setupGatingService(c *cli.Context) {} diff --git a/model/limit.go b/model/limit.go deleted file mode 100644 index 2465700f4..000000000 --- a/model/limit.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2018 Drone.IO Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package model - -// Limiter defines an interface for limiting repository creation. -// This could be used, for example, to limit repository creation to -// a specific organization or a specific set of users. -type Limiter interface { - LimitUser(*User) error - LimitRepo(*User, *Repo) error - LimitRepos(*User, []*Repo) []*Repo - LimitBuild(*User, *Repo, *Build) error -} - -// NoLimit implements the Limiter interface without enforcing any -// actual limits. All limiting functions are no-ops. -type NoLimit struct{} - -// LimitUser is a no-op for limiting user creation. -func (NoLimit) LimitUser(*User) error { return nil } - -// LimitRepo is a no-op for limiting repo creation. -func (NoLimit) LimitRepo(*User, *Repo) error { return nil } - -// LimitRepos is a no-op for limiting repository listings. -func (NoLimit) LimitRepos(user *User, repos []*Repo) []*Repo { return repos } - -// LimitBuild is a no-op for limiting build creation. -func (NoLimit) LimitBuild(*User, *Repo, *Build) error { return nil } diff --git a/server/hook.go b/server/hook.go index 65093d0bd..74c28ad86 100644 --- a/server/hook.go +++ b/server/hook.go @@ -29,12 +29,12 @@ import ( "github.com/gin-gonic/gin" "github.com/Sirupsen/logrus" + "github.com/drone/envsubst" "github.com/laszlocph/drone-oss-08/model" "github.com/laszlocph/drone-oss-08/remote" "github.com/laszlocph/drone-oss-08/shared/httputil" "github.com/laszlocph/drone-oss-08/shared/token" "github.com/laszlocph/drone-oss-08/store" - "github.com/drone/envsubst" "github.com/laszlocph/drone-oss-08/cncd/pipeline/pipeline/backend" "github.com/laszlocph/drone-oss-08/cncd/pipeline/pipeline/frontend" @@ -212,11 +212,6 @@ func PostHook(c *gin.Context) { } } - if err = Config.Services.Limiter.LimitBuild(user, repo, build); err != nil { - c.String(403, "Build blocked by limiter") - return - } - build.Trim() err = store.CreateBuild(c, build, build.Procs...) if err != nil { diff --git a/server/login.go b/server/login.go index bb783aca7..c6354036f 100644 --- a/server/login.go +++ b/server/login.go @@ -19,12 +19,12 @@ import ( "net/http" "time" + "github.com/gorilla/securecookie" "github.com/laszlocph/drone-oss-08/model" "github.com/laszlocph/drone-oss-08/remote" "github.com/laszlocph/drone-oss-08/shared/httputil" "github.com/laszlocph/drone-oss-08/shared/token" "github.com/laszlocph/drone-oss-08/store" - "github.com/gorilla/securecookie" "github.com/Sirupsen/logrus" "github.com/gin-gonic/gin" @@ -95,11 +95,6 @@ func HandleAuth(c *gin.Context) { ), } - if err = Config.Services.Limiter.LimitUser(u); err != nil { - c.String(403, "User activation blocked by limiter") - return - } - // insert the user into the database if err := store.CreateUser(c, u); err != nil { logrus.Errorf("cannot insert %s. %s", u.Login, err) diff --git a/server/repo.go b/server/repo.go index 7f51db3b6..70c68269e 100644 --- a/server/repo.go +++ b/server/repo.go @@ -41,11 +41,6 @@ func PostRepo(c *gin.Context) { return } - if err := Config.Services.Limiter.LimitRepo(user, repo); err != nil { - c.String(403, "Repository activation blocked by limiter") - return - } - repo.IsActive = true repo.UserID = user.ID if !repo.AllowPush && !repo.AllowPull && !repo.AllowDeploy && !repo.AllowTag { diff --git a/server/rpc.go b/server/rpc.go index 383e61639..61ff8648a 100644 --- a/server/rpc.go +++ b/server/rpc.go @@ -55,7 +55,6 @@ var Config = struct { Secrets model.SecretService Registries model.RegistryService Environ model.EnvironService - Limiter model.Limiter } Storage struct { // Users model.UserStore diff --git a/server/sync.go b/server/sync.go index b448ee338..59da137cc 100644 --- a/server/sync.go +++ b/server/sync.go @@ -28,10 +28,9 @@ type Syncer interface { } type syncer struct { - remote remote.Remote - store store.Store - perms model.PermStore - limiter model.Limiter + remote remote.Remote + store store.Store + perms model.PermStore } func (s *syncer) Sync(user *model.User) error { @@ -41,10 +40,6 @@ func (s *syncer) Sync(user *model.User) error { return err } - if s.limiter != nil { - repos = s.limiter.LimitRepos(user, repos) - } - var perms []*model.Perm for _, repo := range repos { perm := model.Perm{ diff --git a/server/user.go b/server/user.go index 24b068277..be4fc663d 100644 --- a/server/user.go +++ b/server/user.go @@ -46,10 +46,9 @@ func GetFeed(c *gin.Context) { store.FromContext(c).UpdateUser(user) sync := syncer{ - remote: remote.FromContext(c), - store: store.FromContext(c), - perms: store.FromContext(c), - limiter: Config.Services.Limiter, + remote: remote.FromContext(c), + store: store.FromContext(c), + perms: store.FromContext(c), } if err := sync.Sync(user); err != nil { logrus.Debugf("sync error: %s: %s", user.Login, err) @@ -89,10 +88,9 @@ func GetRepos(c *gin.Context) { store.FromContext(c).UpdateUser(user) sync := syncer{ - remote: remote.FromContext(c), - store: store.FromContext(c), - perms: store.FromContext(c), - limiter: Config.Services.Limiter, + remote: remote.FromContext(c), + store: store.FromContext(c), + perms: store.FromContext(c), } if err := sync.Sync(user); err != nil { logrus.Debugf("sync error: %s: %s", user.Login, err)