mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-19 00:15:48 +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:
@@ -28,9 +28,10 @@ type GitHub struct {
|
||||
Private bool
|
||||
SkipVerify bool
|
||||
Orgs []string
|
||||
Open bool
|
||||
}
|
||||
|
||||
func New(url, api, client, secret string, private, skipVerify bool, orgs []string) *GitHub {
|
||||
func New(url, api, client, secret string, private, skipVerify bool, orgs []string, open bool) *GitHub {
|
||||
var github = GitHub{
|
||||
URL: url,
|
||||
API: api,
|
||||
@@ -39,6 +40,7 @@ func New(url, api, client, secret string, private, skipVerify bool, orgs []strin
|
||||
Private: private,
|
||||
SkipVerify: skipVerify,
|
||||
Orgs: orgs,
|
||||
Open: open,
|
||||
}
|
||||
// the API must have a trailing slash
|
||||
if !strings.HasSuffix(github.API, "/") {
|
||||
@@ -51,8 +53,8 @@ func New(url, api, client, secret string, private, skipVerify bool, orgs []strin
|
||||
return &github
|
||||
}
|
||||
|
||||
func NewDefault(client, secret string, orgs []string) *GitHub {
|
||||
return New(DefaultURL, DefaultAPI, client, secret, false, false, orgs)
|
||||
func NewDefault(client, secret string, orgs []string, open bool) *GitHub {
|
||||
return New(DefaultURL, DefaultAPI, client, secret, false, false, orgs, open)
|
||||
}
|
||||
|
||||
// Authorize handles GitHub API Authorization.
|
||||
@@ -305,3 +307,7 @@ func (r *GitHub) ParsePullRequestHook(req *http.Request) (*model.Hook, error) {
|
||||
|
||||
return &hook, nil
|
||||
}
|
||||
|
||||
func (r *GitHub) OpenRegistration() bool {
|
||||
return r.Open
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user