Exemple #1
0
func New(e *empire.Empire, options Options) http.Handler {
	r := httpx.NewRouter()

	if options.GitHub.Webhooks.Secret != "" {
		// Mount GitHub webhooks
		g := github.New(e, github.Options{
			Secret:        options.GitHub.Webhooks.Secret,
			Environment:   options.GitHub.Deployments.Environment,
			ImageTemplate: options.GitHub.Deployments.ImageTemplate,
			TugboatURL:    options.GitHub.Deployments.TugboatURL,
		})
		r.Match(githubWebhook, g)
	}

	// Mount the heroku api
	h := heroku.New(e, options.Authenticator)
	r.Headers("Accept", heroku.AcceptHeader).Handler(h)

	// Mount health endpoint
	r.Handle("/health", NewHealthHandler(e))

	return middleware.Common(r, middleware.CommonOpts{
		Reporter: e.Reporter,
		Logger:   e.Logger,
	})
}
Exemple #2
0
func newServer(c *Context, e *empire.Empire) http.Handler {
	var opts server.Options
	opts.GitHub.Webhooks.Secret = c.String(FlagGithubWebhooksSecret)
	opts.GitHub.Deployments.Environments = strings.Split(c.String(FlagGithubDeploymentsEnvironments), ",")
	opts.GitHub.Deployments.ImageBuilder = newImageBuilder(c)
	opts.GitHub.Deployments.TugboatURL = c.String(FlagGithubDeploymentsTugboatURL)

	s := server.New(e, opts)
	s.URL = c.URL(FlagURL)
	s.Heroku.Auth = newAuth(c, e)
	s.Heroku.Secret = []byte(c.String(FlagSecret))

	sp, err := c.SAMLServiceProvider()
	if err != nil {
		panic(err)
	}

	if sp != nil {
		s.ServiceProvider = sp
		s.Heroku.Unauthorized = heroku.SAMLUnauthorized(c.String(FlagURL) + "/saml/login")
	}

	h := middleware.Common(s)
	return middleware.Handler(c, h)
}
Exemple #3
0
func newServer(c *Context, e *empire.Empire) http.Handler {
	var opts server.Options
	opts.Authenticator = newAuthenticator(c, e)
	opts.GitHub.Webhooks.Secret = c.String(FlagGithubWebhooksSecret)
	opts.GitHub.Deployments.Environments = strings.Split(c.String(FlagGithubDeploymentsEnvironments), ",")
	opts.GitHub.Deployments.ImageBuilder = newImageBuilder(c)
	opts.GitHub.Deployments.TugboatURL = c.String(FlagGithubDeploymentsTugboatURL)

	h := middleware.Common(server.New(e, opts))
	return middleware.Handler(c, h)
}
Exemple #4
0
func newServer(c *cli.Context, e *empire.Empire) (http.Handler, error) {
	rootCtx, err := newRootContext(c)
	if err != nil {
		return nil, err
	}

	var opts server.Options
	opts.Authenticator = newAuthenticator(c, e)
	opts.GitHub.Webhooks.Secret = c.String(FlagGithubWebhooksSecret)
	opts.GitHub.Deployments.Environments = strings.Split(c.String(FlagGithubDeploymentsEnvironments), ",")
	opts.GitHub.Deployments.ImageBuilder = newImageBuilder(c)
	opts.GitHub.Deployments.TugboatURL = c.String(FlagGithubDeploymentsTugboatURL)

	h := middleware.Common(server.New(e, opts))
	return middleware.Handler(rootCtx, h), nil
}
Exemple #5
0
func New(e *empire.Empire, options Options) http.Handler {
	r := httpx.NewRouter()

	auth := NewAuthorizer(
		options.GitHub.ClientID,
		options.GitHub.ClientSecret,
		options.GitHub.Organization,
		options.GitHub.ApiURL,
	)

	// Mount the heroku api
	h := heroku.New(e, auth)
	r.Headers("Accept", heroku.AcceptHeader).Handler(h)

	// Mount health endpoint
	r.Handle("/health", NewHealthHandler(e))

	return middleware.Common(r, middleware.CommonOpts{
		Reporter: e.Reporter,
		Logger:   e.Logger,
	})
}