13 "github.com/justinas/alice"
14 "github.com/oauth2-proxy/oauth2-proxy/pkg/apis/options"
15 "github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
16 "github.com/oauth2-proxy/oauth2-proxy/pkg/middleware"
17 "github.com/oauth2-proxy/oauth2-proxy/pkg/validation"
21 logger.SetFlags(logger.Lshortfile)
22 flagSet := options.NewFlagSet()
24 config := flagSet.String("config", "", "path to config file")
25 showVersion := flagSet.Bool("version", false, "print version string")
27 err := flagSet.Parse(os.Args[1:])
29 logger.Printf("ERROR: Failed to parse flags: %v", err)
34 fmt.Printf("oauth2-proxy %s (built with %s)\n", VERSION, runtime.Version())
38 legacyOpts := options.NewLegacyOptions()
39 err = options.Load(*config, flagSet, legacyOpts)
41 logger.Errorf("ERROR: Failed to load config: %v", err)
45 opts, err := legacyOpts.ToOptions()
47 logger.Errorf("ERROR: Failed to convert config: %v", err)
51 err = validation.Validate(opts)
53 logger.Printf("%s", err)
57 validator := NewValidator(opts.EmailDomains, opts.AuthenticatedEmailsFile)
58 oauthproxy, err := NewOAuthProxy(opts, validator)
60 logger.Errorf("ERROR: Failed to initialise OAuth2 Proxy: %v", err)
64 rand.Seed(time.Now().UnixNano())
69 _, httpsPort, err := net.SplitHostPort(opts.HTTPSAddress)
71 logger.Fatalf("FATAL: invalid HTTPS address %q: %v", opts.HTTPAddress, err)
73 chain = chain.Append(middleware.NewRedirectToHTTPS(httpsPort))
76 healthCheckPaths := []string{opts.PingPath}
77 healthCheckUserAgents := []string{opts.PingUserAgent}
78 if opts.GCPHealthChecks {
79 healthCheckPaths = append(healthCheckPaths, "/liveness_check", "/readiness_check")
80 healthCheckUserAgents = append(healthCheckUserAgents, "GoogleHC/1.0")
83 // To silence logging of health checks, register the health check handler before
84 // the logging handler
85 if opts.Logging.SilencePing {
86 chain = chain.Append(middleware.NewHealthCheck(healthCheckPaths, healthCheckUserAgents), LoggingHandler)
88 chain = chain.Append(LoggingHandler, middleware.NewHealthCheck(healthCheckPaths, healthCheckUserAgents))
92 Handler: chain.Then(oauthproxy),
94 stop: make(chan struct{}, 1),
96 // Observe signals in background goroutine.
98 sigint := make(chan os.Signal, 1)
99 signal.Notify(sigint, os.Interrupt, syscall.SIGTERM)
101 s.stop <- struct{}{} // notify having caught signal
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list