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/validation"
20 logger.SetFlags(logger.Lshortfile)
21 flagSet := options.NewFlagSet()
23 config := flagSet.String("config", "", "path to config file")
24 showVersion := flagSet.Bool("version", false, "print version string")
26 flagSet.Parse(os.Args[1:])
29 fmt.Printf("oauth2-proxy %s (built with %s)\n", VERSION, runtime.Version())
33 opts := options.NewOptions()
34 err := options.Load(*config, flagSet, opts)
36 logger.Printf("ERROR: Failed to load config: %v", err)
40 err = validation.Validate(opts)
42 logger.Printf("%s", err)
46 validator := NewValidator(opts.EmailDomains, opts.AuthenticatedEmailsFile)
47 oauthproxy := NewOAuthProxy(opts, validator)
49 if len(opts.Banner) >= 1 {
50 if opts.Banner == "-" {
51 oauthproxy.SignInMessage = ""
53 oauthproxy.SignInMessage = opts.Banner
55 } else if len(opts.EmailDomains) != 0 && opts.AuthenticatedEmailsFile == "" {
56 if len(opts.EmailDomains) > 1 {
57 oauthproxy.SignInMessage = fmt.Sprintf("Authenticate using one of the following domains: %v", strings.Join(opts.EmailDomains, ", "))
58 } else if opts.EmailDomains[0] != "*" {
59 oauthproxy.SignInMessage = fmt.Sprintf("Authenticate using %v", opts.EmailDomains[0])
63 if opts.HtpasswdFile != "" {
64 logger.Printf("using htpasswd file %s", opts.HtpasswdFile)
65 oauthproxy.HtpasswdFile, err = NewHtpasswdFromFile(opts.HtpasswdFile)
66 oauthproxy.DisplayHtpasswdForm = opts.DisplayHtpasswdForm
68 logger.Fatalf("FATAL: unable to open %s %s", opts.HtpasswdFile, err)
72 rand.Seed(time.Now().UnixNano())
74 var handler http.Handler
75 if opts.GCPHealthChecks {
76 handler = redirectToHTTPS(opts, gcpHealthcheck(LoggingHandler(oauthproxy)))
78 handler = redirectToHTTPS(opts, LoggingHandler(oauthproxy))
83 stop: make(chan struct{}, 1),
85 // Observe signals in background goroutine.
87 sigint := make(chan os.Signal, 1)
88 signal.Notify(sigint, os.Interrupt, syscall.SIGTERM)
90 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