oauth_start.go 639 B

12345678910111213141516171819202122232425
  1. package gitinstallation
  2. import (
  3. "net/http"
  4. "github.com/porter-dev/porter/api/server/handlers"
  5. "github.com/porter-dev/porter/api/server/shared/config"
  6. "golang.org/x/oauth2"
  7. )
  8. type GithubAppOAuthStartHandler struct {
  9. handlers.PorterHandler
  10. }
  11. func NewGithubAppOAuthStartHandler(
  12. config *config.Config,
  13. ) *GithubAppOAuthStartHandler {
  14. return &GithubAppOAuthStartHandler{
  15. PorterHandler: handlers.NewDefaultPorterHandler(config, nil, nil),
  16. }
  17. }
  18. func (c *GithubAppOAuthStartHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  19. http.Redirect(w, r, c.Config().GithubAppConf.AuthCodeURL("", oauth2.AccessTypeOffline), 302)
  20. }