Repository: h2oai/wave
File: cmd/wave/main.go (Go)

Code before:
	stringVar(&conf.CertFile, "tls-cert-file", "", "path to certificate file (TLS only)")
	stringVar(&conf.KeyFile, "tls-key-file", "", "path to private key file (TLS only)")
	stringVar(&httpHeadersFile, "http-headers-file", "", "path to a MIME-formatted file containing additional HTTP headers to add to responses from the server")
	boolVar(&conf.Editable, "editable", false, "allow users to edit web pages")
	stringVar(&maxRequestSize, "max-request-size", "5M", "maximum allowed size of HTTP requests to the server (e.g. 5M or 5MB or 5MiB)")
	stringVar(&maxCacheRequestSize, "max-cache-request-size", "5M", "maximum allowed size of HTTP requests to the server cache (e.g. 5M or 5MB or 5MiB)")
	boolVar(&conf.Proxy, "proxy", false, "enable HTTP proxy (for IDE / language server support only - not recommended for internet-facing websites)")
	stringVar(&maxProxyRequestSize, "max-proxy-request-size", "5M", "maximum allowed size of proxied HTTP requests (e.g. 5M or 5MB or 5MiB)")
	stringVar(&maxProxyResponseSize, "max-proxy-response-size", "5M", "maximum allowed size of proxied HTTP responses (e.g. 5M or 5MB or 5MiB)")
	stringVar(&sessionExpiry, "session-expiry", "720h", "session cookie lifetime duration (e.g. 1800s or 30m or 0.5h)")
	stringVar(&inactivityTimeout, "session-inactivity-timeout", "30m", "session inactivity timeout duration (e.g. 1800s or 30m or 0.5h)")
	boolVar(&conf.NoStore, "no-store", false, "disable storage (scripts and multicast/broadcast apps will not work)")
	boolVar(&conf.NoLog, "no-log", false, "disable AOF logging (connect/disconnect and diagnostic logging messages are not disabled)")
	// TODO enable when IDE is released
	// boolVar(&conf.IDE, "ide", false, "enable Wave IDE (experimental)")
	boolVar(&conf.Debug, "debug", false, "enable debug mode (profiling, inspection, etc.)")
	stringVar(&auth.ClientID, "oidc-client-id", "", "OIDC client ID")
	stringVar(&auth.ClientSecret, "oidc-client-secret", "", "OIDC client secret")
	stringVar(&auth.ProviderURL, "oidc-provider-url", "", "OIDC provider URL")
	stringVar(&auth.RedirectURL, "oidc-redirect-url", "", "OIDC redirect URL")
	stringVar(&auth.EndSessionURL, "oidc-end-session-url", "", "OIDC end session URL")
	stringVar(&auth.PostLogoutRedirectURL, "oidc-post-logout-redirect-url", "", "OIDC post logout redirect URL")
	stringVar(&rawAuthScopes, "oidc-scopes", "", "OIDC scopes, comma-separated (default \"openid,profile\")")
	stringVar(&rawAuthURLParams, "oidc-auth-url-params", "", "additional URL parameters to pass during OIDC authorization, in the format \"key:value\", comma-separated, e.g. \"foo:bar,qux:42\"")
	boolVar(&auth.SkipLogin, "oidc-skip-login", false, "do not display the login form during OIDC authorization")
	boolVar(&verifyTLS, "verify-tls", true, "do not verify TLS certificates during external communication - DO NOT USE IN PRODUCTION")

	flag.Parse()

	auth.Scopes = strings.Split(rawAuthScopes, ",")
	if len(rawAuthURLParams) > 0 {
		rawAuthURLPairs := strings.Split(rawAuthURLParams, ",")
		for _, rawPair := range rawAuthURLPairs {
			kv := strings.Split(rawPair, ":")
			if len(kv) != 2 {
				panic(fmt.Errorf("bad OIDC authorization url parameter: %v", rawPair))
			}
			k, v := kv[0], kv[1]
			if len(k) == 0 {
				panic(fmt.Errorf("empty OIDC authorization url parameter key: %v", rawPair))
			}
			if len(v) == 0 {
				panic(fmt.Errorf("empty OIDC authorization url parameter value: %v", rawPair))
			}
			auth.URLParameters = append(auth.URLParameters, kv)
		}
	}

	if version {
		fmt.Printf("Wave Daemon\nVersion %s Build %s (%s/%s)\nCopyright (c) H2O.ai, Inc.\n", Version, BuildDate, runtime.GOOS, runtime.GOARCH)
		return

Review comment (suggestion):
Might be more consistent to call this `no-tls-verify` (similar to the other `no-*` flags, default to `false`. Also, define on line 100, right after`tls-*` flags, so that related flags are clustered together.

Code after:
	boolVar(&conf.SkipCertVerification, "no-tls-verify", false, "do not verify TLS certificates during external communication - DO NOT USE IN PRODUCTION")
	stringVar(&httpHeadersFile, "http-headers-file", "", "path to a MIME-formatted file containing additional HTTP headers to add to responses from the server")
	boolVar(&conf.Editable, "editable", false, "allow users to edit web pages")
	stringVar(&maxRequestSize, "max-request-size", "5M", "maximum allowed size of HTTP requests to the server (e.g. 5M or 5MB or 5MiB)")
	stringVar(&maxCacheRequestSize, "max-cache-request-size", "5M", "maximum allowed size of HTTP requests to the server cache (e.g. 5M or 5MB or 5MiB)")
	boolVar(&conf.Proxy, "proxy", false, "enable HTTP proxy (for IDE / language server support only - not recommended for internet-facing websites)")
	stringVar(&maxProxyRequestSize, "max-proxy-request-size", "5M", "maximum allowed size of proxied HTTP requests (e.g. 5M or 5MB or 5MiB)")
	stringVar(&maxProxyResponseSize, "max-proxy-response-size", "5M", "maximum allowed size of proxied HTTP responses (e.g. 5M or 5MB or 5MiB)")
	stringVar(&sessionExpiry, "session-expiry", "720h", "session cookie lifetime duration (e.g. 1800s or 30m or 0.5h)")
	stringVar(&inactivityTimeout, "session-inactivity-timeout", "30m", "session inactivity timeout duration (e.g. 1800s or 30m or 0.5h)")
	boolVar(&conf.NoStore, "no-store", false, "disable storage (scripts and multicast/broadcast apps will not work)")
	boolVar(&conf.NoLog, "no-log", false, "disable AOF logging (connect/disconnect and diagnostic logging messages are not disabled)")
	// TODO enable when IDE is released
	// boolVar(&conf.IDE, "ide", false, "enable Wave IDE (experimental)")
	boolVar(&conf.Debug, "debug", false, "enable debug mode (profiling, inspection, etc.)")
	stringVar(&auth.ClientID, "oidc-client-id", "", "OIDC client ID")
	stringVar(&auth.ClientSecret, "oidc-client-secret", "", "OIDC client secret")
	stringVar(&auth.ProviderURL, "oidc-provider-url", "", "OIDC provider URL")
	stringVar(&auth.RedirectURL, "oidc-redirect-url", "", "OIDC redirect URL")
	stringVar(&auth.EndSessionURL, "oidc-end-session-url", "", "OIDC end session URL")
	stringVar(&auth.PostLogoutRedirectURL, "oidc-post-logout-redirect-url", "", "OIDC post logout redirect URL")
	stringVar(&rawAuthScopes, "oidc-scopes", "", "OIDC scopes, comma-separated (default \"openid,profile\")")
	stringVar(&rawAuthURLParams, "oidc-auth-url-params", "", "additional URL parameters to pass during OIDC authorization, in the format \"key:value\", comma-separated, e.g. \"foo:bar,qux:42\"")
	boolVar(&auth.SkipLogin, "oidc-skip-login", false, "do not display the login form during OIDC authorization")

	flag.Parse()

	auth.Scopes = strings.Split(rawAuthScopes, ",")
	if len(rawAuthURLParams) > 0 {
		rawAuthURLPairs := strings.Split(rawAuthURLParams, ",")
		for _, rawPair := range rawAuthURLPairs {
			kv := strings.Split(rawPair, ":")
			if len(kv) != 2 {
				panic(fmt.Errorf("bad OIDC authorization url parameter: %v", rawPair))
			}
			k, v := kv[0], kv[1]
			if len(k) == 0 {
				panic(fmt.Errorf("empty OIDC authorization url parameter key: %v", rawPair))
			}
			if len(v) == 0 {
				panic(fmt.Errorf("empty OIDC authorization url parameter value: %v", rawPair))
			}
			auth.URLParameters = append(auth.URLParameters, kv)
		}
	}

	if version {
		fmt.Printf("Wave Daemon\nVersion %s Build %s (%s/%s)\nCopyright (c) H2O.ai, Inc.\n", Version, BuildDate, runtime.GOOS, runtime.GOARCH)
		return
	}