mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-20 17:05:37 +01:00
Move open registration setting into remote plugins
...so that it's possible to enable or disable open registration on a per-remote basis. For example, the `DRONE_REGISTRATION_OPEN` environment variable now becomes `DRONE_GITHUB_OPEN` when using GitHub as a remote. The default for open registration in this commit is `false` (disabled), which matches the existing behaviour. This is useful if you need to support both public and private remotes, e.g. GitHub.com and GitHub Enterprise, where you trust all of the private users and want to allow open registration for those but would not want all GitHub.com users to run builds on your server. Tested with GitHub and GitLab.
This commit is contained in:
@@ -16,10 +16,11 @@ import (
|
||||
type Gogs struct {
|
||||
URL string
|
||||
Secret string
|
||||
Open bool
|
||||
}
|
||||
|
||||
func New(url string, secret string) *Gogs {
|
||||
return &Gogs{URL: url, Secret: secret}
|
||||
func New(url string, secret string, open bool) *Gogs {
|
||||
return &Gogs{URL: url, Secret: secret, Open: open}
|
||||
}
|
||||
|
||||
// Authorize handles Gogs authorization
|
||||
@@ -181,3 +182,7 @@ func (r *Gogs) ParseHook(req *http.Request) (*model.Hook, error) {
|
||||
Message: payload.Commits[0].Message,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Gogs) OpenRegistration() bool {
|
||||
return r.Open
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
var (
|
||||
gogsUrl = config.String("gogs-url", "")
|
||||
gogsSecret = config.String("gogs-secret", "")
|
||||
gogsOpen = config.Bool("gogs-open", false)
|
||||
)
|
||||
|
||||
// Registers the Gogs plugin using the default
|
||||
@@ -18,6 +19,6 @@ func Register() {
|
||||
return
|
||||
}
|
||||
remote.Register(
|
||||
New(*gogsUrl, *gogsSecret),
|
||||
New(*gogsUrl, *gogsSecret, *gogsOpen),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user