woodpecker/plugin/remote/github/register.go
Dan Carley 8fa473b07a Support org whitelists for GitHub+GHE remotes
Allow the GitHub and GitHub Enterprise remotes to restrict who can login
based on a user's organisation membership. This can be used as a safe
addition to open registration and also ensures that access is revoked when a
user is subsequently removed from the org. The default is not to restrict at
all.
2015-01-15 17:05:53 +00:00

61 lines
1.7 KiB
Go

package github
import (
"github.com/drone/config"
"github.com/drone/drone/plugin/remote"
)
var (
// GitHub cloud configuration details
githubClient = config.String("github-client", "")
githubSecret = config.String("github-secret", "")
githubOrgs = config.Strings("github-orgs")
// GitHub Enterprise configuration details
githubEnterpriseURL = config.String("github-enterprise-url", "")
githubEnterpriseAPI = config.String("github-enterprise-api", "")
githubEnterpriseClient = config.String("github-enterprise-client", "")
githubEnterpriseSecret = config.String("github-enterprise-secret", "")
githubEnterprisePrivate = config.Bool("github-enterprise-private-mode", true)
githubEnterpriseSkipVerify = config.Bool("github-enterprise-skip-verify", false)
githubEnterpriseOrgs = config.Strings("github-enterprise-orgs")
)
// Registers the GitHub plugins using the default
// settings from the config file or environment
// variables.
func Register() {
registerGitHub()
registerGitHubEnterprise()
}
// registers the GitHub (github.com) plugin
func registerGitHub() {
if len(*githubClient) == 0 || len(*githubSecret) == 0 {
return
}
remote.Register(
NewDefault(*githubClient, *githubSecret, *githubOrgs),
)
}
// registers the GitHub Enterprise plugin
func registerGitHubEnterprise() {
if len(*githubEnterpriseURL) == 0 ||
len(*githubEnterpriseAPI) == 0 ||
len(*githubEnterpriseClient) == 0 ||
len(*githubEnterpriseSecret) == 0 {
return
}
remote.Register(
New(
*githubEnterpriseURL,
*githubEnterpriseAPI,
*githubEnterpriseClient,
*githubEnterpriseSecret,
*githubEnterprisePrivate,
*githubEnterpriseSkipVerify,
*githubEnterpriseOrgs,
),
)
}