New flag "-ssl-upstream-insecure-skip-validation" (#234)
* New flag "-ssl-upstream-insecure-skip-validation" to skip SSL validation for upstreams with self generated / invalid SSL certificates. * Fix tests for modified NewReverseProxy method. * Added change to the changelog. * Remove duplicate entries from changelog.
This commit is contained in:
		
							parent
							
								
									d85660248c
								
							
						
					
					
						commit
						7134d22bcc
					
				|  | @ -36,6 +36,7 @@ | ||||||
| 
 | 
 | ||||||
| ## Changes since v3.2.0 | ## Changes since v3.2.0 | ||||||
| 
 | 
 | ||||||
|  | - [#234](https://github.com/pusher/oauth2_proxy/pull/234) Added option `-ssl-upstream-insecure-skip-validation` to skip validation of upstream SSL certificates (@jansinger) | ||||||
| - [#224](https://github.com/pusher/oauth2_proxy/pull/224) Check Google group membership using hasMember to support nested groups and external users (@jpalpant) | - [#224](https://github.com/pusher/oauth2_proxy/pull/224) Check Google group membership using hasMember to support nested groups and external users (@jpalpant) | ||||||
| - [#231](https://github.com/pusher/oauth2_proxy/pull/231) Add optional group membership and email domain checks to the GitLab provider (@Overv) | - [#231](https://github.com/pusher/oauth2_proxy/pull/231) Add optional group membership and email domain checks to the GitLab provider (@Overv) | ||||||
| - [#178](https://github.com/pusher/outh2_proxy/pull/178) Add Silence Ping Logging and Exclude Logging Paths flags (@kskewes) | - [#178](https://github.com/pusher/outh2_proxy/pull/178) Add Silence Ping Logging and Exclude Logging Paths flags (@kskewes) | ||||||
|  |  | ||||||
|  | @ -99,7 +99,8 @@ Usage of oauth2_proxy: | ||||||
|   -skip-jwt-bearer-tokens: will skip requests that have verified JWT bearer tokens |   -skip-jwt-bearer-tokens: will skip requests that have verified JWT bearer tokens | ||||||
|   -skip-oidc-discovery: bypass OIDC endpoint discovery. login-url, redeem-url and oidc-jwks-url must be configured in this case |   -skip-oidc-discovery: bypass OIDC endpoint discovery. login-url, redeem-url and oidc-jwks-url must be configured in this case | ||||||
|   -skip-provider-button: will skip sign-in-page to directly reach the next step: oauth/start |   -skip-provider-button: will skip sign-in-page to directly reach the next step: oauth/start | ||||||
|   -ssl-insecure-skip-verify: skip validation of certificates presented when using HTTPS |   -ssl-insecure-skip-verify: skip validation of certificates presented when using HTTPS providers | ||||||
|  |   -ssl-upstream-insecure-skip-verify: skip validation of certificates presented when using HTTPS upstreams | ||||||
|   -standard-logging: Log standard runtime information (default true) |   -standard-logging: Log standard runtime information (default true) | ||||||
|   -standard-logging-format string: Template for standard log lines (see "Logging Configuration" paragraph below) |   -standard-logging-format string: Template for standard log lines (see "Logging Configuration" paragraph below) | ||||||
|   -tls-cert-file string: path to certificate file |   -tls-cert-file string: path to certificate file | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								main.go
								
								
								
								
							
							
						
						
									
										3
									
								
								main.go
								
								
								
								
							|  | @ -47,7 +47,8 @@ func main() { | ||||||
| 	flagSet.Var(&skipAuthRegex, "skip-auth-regex", "bypass authentication for requests path's that match (may be given multiple times)") | 	flagSet.Var(&skipAuthRegex, "skip-auth-regex", "bypass authentication for requests path's that match (may be given multiple times)") | ||||||
| 	flagSet.Bool("skip-provider-button", false, "will skip sign-in-page to directly reach the next step: oauth/start") | 	flagSet.Bool("skip-provider-button", false, "will skip sign-in-page to directly reach the next step: oauth/start") | ||||||
| 	flagSet.Bool("skip-auth-preflight", false, "will skip authentication for OPTIONS requests") | 	flagSet.Bool("skip-auth-preflight", false, "will skip authentication for OPTIONS requests") | ||||||
| 	flagSet.Bool("ssl-insecure-skip-verify", false, "skip validation of certificates presented when using HTTPS") | 	flagSet.Bool("ssl-insecure-skip-verify", false, "skip validation of certificates presented when using HTTPS providers") | ||||||
|  | 	flagSet.Bool("ssl-upstream-insecure-skip-verify", false, "skip validation of certificates presented when using HTTPS upstreams") | ||||||
| 	flagSet.Duration("flush-interval", time.Duration(1)*time.Second, "period between response flushing when streaming responses") | 	flagSet.Duration("flush-interval", time.Duration(1)*time.Second, "period between response flushing when streaming responses") | ||||||
| 	flagSet.Bool("skip-jwt-bearer-tokens", false, "will skip requests that have verified JWT bearer tokens (default false)") | 	flagSet.Bool("skip-jwt-bearer-tokens", false, "will skip requests that have verified JWT bearer tokens (default false)") | ||||||
| 	flagSet.Var(&jwtIssuers, "extra-jwt-issuers", "if skip-jwt-bearer-tokens is set, a list of extra JWT issuer=audience pairs (where the issuer URL has a .well-known/openid-configuration or a .well-known/jwks.json)") | 	flagSet.Var(&jwtIssuers, "extra-jwt-issuers", "if skip-jwt-bearer-tokens is set, a list of extra JWT issuer=audience pairs (where the issuer URL has a .well-known/openid-configuration or a .well-known/jwks.json)") | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ package main | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
|  | 	"crypto/tls" | ||||||
| 	b64 "encoding/base64" | 	b64 "encoding/base64" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | @ -128,9 +129,14 @@ func (u *UpstreamProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||||||
| 
 | 
 | ||||||
| // NewReverseProxy creates a new reverse proxy for proxying requests to upstream
 | // NewReverseProxy creates a new reverse proxy for proxying requests to upstream
 | ||||||
| // servers
 | // servers
 | ||||||
| func NewReverseProxy(target *url.URL, flushInterval time.Duration) (proxy *httputil.ReverseProxy) { | func NewReverseProxy(target *url.URL, opts *Options) (proxy *httputil.ReverseProxy) { | ||||||
| 	proxy = httputil.NewSingleHostReverseProxy(target) | 	proxy = httputil.NewSingleHostReverseProxy(target) | ||||||
| 	proxy.FlushInterval = flushInterval | 	proxy.FlushInterval = opts.FlushInterval | ||||||
|  | 	if opts.SSLUpstreamInsecureSkipVerify { | ||||||
|  | 		proxy.Transport = &http.Transport{ | ||||||
|  | 			TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	return proxy | 	return proxy | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -163,7 +169,7 @@ func NewFileServer(path string, filesystemPath string) (proxy http.Handler) { | ||||||
| // NewWebSocketOrRestReverseProxy creates a reverse proxy for REST or websocket based on url
 | // NewWebSocketOrRestReverseProxy creates a reverse proxy for REST or websocket based on url
 | ||||||
| func NewWebSocketOrRestReverseProxy(u *url.URL, opts *Options, auth hmacauth.HmacAuth) http.Handler { | func NewWebSocketOrRestReverseProxy(u *url.URL, opts *Options, auth hmacauth.HmacAuth) http.Handler { | ||||||
| 	u.Path = "" | 	u.Path = "" | ||||||
| 	proxy := NewReverseProxy(u, opts.FlushInterval) | 	proxy := NewReverseProxy(u, opts) | ||||||
| 	if !opts.PassHostHeader { | 	if !opts.PassHostHeader { | ||||||
| 		setProxyUpstreamHostHeader(proxy, u) | 		setProxyUpstreamHostHeader(proxy, u) | ||||||
| 	} else { | 	} else { | ||||||
|  |  | ||||||
|  | @ -122,7 +122,7 @@ func TestNewReverseProxy(t *testing.T) { | ||||||
| 	backendHost := net.JoinHostPort(backendHostname, backendPort) | 	backendHost := net.JoinHostPort(backendHostname, backendPort) | ||||||
| 	proxyURL, _ := url.Parse(backendURL.Scheme + "://" + backendHost + "/") | 	proxyURL, _ := url.Parse(backendURL.Scheme + "://" + backendHost + "/") | ||||||
| 
 | 
 | ||||||
| 	proxyHandler := NewReverseProxy(proxyURL, time.Second) | 	proxyHandler := NewReverseProxy(proxyURL, &Options{FlushInterval: time.Second}) | ||||||
| 	setProxyUpstreamHostHeader(proxyHandler, proxyURL) | 	setProxyUpstreamHostHeader(proxyHandler, proxyURL) | ||||||
| 	frontend := httptest.NewServer(proxyHandler) | 	frontend := httptest.NewServer(proxyHandler) | ||||||
| 	defer frontend.Close() | 	defer frontend.Close() | ||||||
|  | @ -144,7 +144,7 @@ func TestEncodedSlashes(t *testing.T) { | ||||||
| 	defer backend.Close() | 	defer backend.Close() | ||||||
| 
 | 
 | ||||||
| 	b, _ := url.Parse(backend.URL) | 	b, _ := url.Parse(backend.URL) | ||||||
| 	proxyHandler := NewReverseProxy(b, time.Second) | 	proxyHandler := NewReverseProxy(b, &Options{FlushInterval: time.Second}) | ||||||
| 	setProxyDirector(proxyHandler) | 	setProxyDirector(proxyHandler) | ||||||
| 	frontend := httptest.NewServer(proxyHandler) | 	frontend := httptest.NewServer(proxyHandler) | ||||||
| 	defer frontend.Close() | 	defer frontend.Close() | ||||||
|  |  | ||||||
							
								
								
									
										33
									
								
								options.go
								
								
								
								
							
							
						
						
									
										33
									
								
								options.go
								
								
								
								
							|  | @ -62,22 +62,23 @@ type Options struct { | ||||||
| 	// Embed SessionOptions
 | 	// Embed SessionOptions
 | ||||||
| 	options.SessionOptions | 	options.SessionOptions | ||||||
| 
 | 
 | ||||||
| 	Upstreams             []string      `flag:"upstream" cfg:"upstreams" env:"OAUTH2_PROXY_UPSTREAMS"` | 	Upstreams                     []string      `flag:"upstream" cfg:"upstreams" env:"OAUTH2_PROXY_UPSTREAMS"` | ||||||
| 	SkipAuthRegex         []string      `flag:"skip-auth-regex" cfg:"skip_auth_regex" env:"OAUTH2_PROXY_SKIP_AUTH_REGEX"` | 	SkipAuthRegex                 []string      `flag:"skip-auth-regex" cfg:"skip_auth_regex" env:"OAUTH2_PROXY_SKIP_AUTH_REGEX"` | ||||||
| 	SkipJwtBearerTokens   bool          `flag:"skip-jwt-bearer-tokens" cfg:"skip_jwt_bearer_tokens" env:"OAUTH2_PROXY_SKIP_JWT_BEARER_TOKENS"` | 	SkipJwtBearerTokens           bool          `flag:"skip-jwt-bearer-tokens" cfg:"skip_jwt_bearer_tokens" env:"OAUTH2_PROXY_SKIP_JWT_BEARER_TOKENS"` | ||||||
| 	ExtraJwtIssuers       []string      `flag:"extra-jwt-issuers" cfg:"extra_jwt_issuers" env:"OAUTH2_PROXY_EXTRA_JWT_ISSUERS"` | 	ExtraJwtIssuers               []string      `flag:"extra-jwt-issuers" cfg:"extra_jwt_issuers" env:"OAUTH2_PROXY_EXTRA_JWT_ISSUERS"` | ||||||
| 	PassBasicAuth         bool          `flag:"pass-basic-auth" cfg:"pass_basic_auth" env:"OAUTH2_PROXY_PASS_BASIC_AUTH"` | 	PassBasicAuth                 bool          `flag:"pass-basic-auth" cfg:"pass_basic_auth" env:"OAUTH2_PROXY_PASS_BASIC_AUTH"` | ||||||
| 	BasicAuthPassword     string        `flag:"basic-auth-password" cfg:"basic_auth_password" env:"OAUTH2_PROXY_BASIC_AUTH_PASSWORD"` | 	BasicAuthPassword             string        `flag:"basic-auth-password" cfg:"basic_auth_password" env:"OAUTH2_PROXY_BASIC_AUTH_PASSWORD"` | ||||||
| 	PassAccessToken       bool          `flag:"pass-access-token" cfg:"pass_access_token" env:"OAUTH2_PROXY_PASS_ACCESS_TOKEN"` | 	PassAccessToken               bool          `flag:"pass-access-token" cfg:"pass_access_token" env:"OAUTH2_PROXY_PASS_ACCESS_TOKEN"` | ||||||
| 	PassHostHeader        bool          `flag:"pass-host-header" cfg:"pass_host_header" env:"OAUTH2_PROXY_PASS_HOST_HEADER"` | 	PassHostHeader                bool          `flag:"pass-host-header" cfg:"pass_host_header" env:"OAUTH2_PROXY_PASS_HOST_HEADER"` | ||||||
| 	SkipProviderButton    bool          `flag:"skip-provider-button" cfg:"skip_provider_button" env:"OAUTH2_PROXY_SKIP_PROVIDER_BUTTON"` | 	SkipProviderButton            bool          `flag:"skip-provider-button" cfg:"skip_provider_button" env:"OAUTH2_PROXY_SKIP_PROVIDER_BUTTON"` | ||||||
| 	PassUserHeaders       bool          `flag:"pass-user-headers" cfg:"pass_user_headers" env:"OAUTH2_PROXY_PASS_USER_HEADERS"` | 	PassUserHeaders               bool          `flag:"pass-user-headers" cfg:"pass_user_headers" env:"OAUTH2_PROXY_PASS_USER_HEADERS"` | ||||||
| 	SSLInsecureSkipVerify bool          `flag:"ssl-insecure-skip-verify" cfg:"ssl_insecure_skip_verify" env:"OAUTH2_PROXY_SSL_INSECURE_SKIP_VERIFY"` | 	SSLInsecureSkipVerify         bool          `flag:"ssl-insecure-skip-verify" cfg:"ssl_insecure_skip_verify" env:"OAUTH2_PROXY_SSL_INSECURE_SKIP_VERIFY"` | ||||||
| 	SetXAuthRequest       bool          `flag:"set-xauthrequest" cfg:"set_xauthrequest" env:"OAUTH2_PROXY_SET_XAUTHREQUEST"` | 	SSLUpstreamInsecureSkipVerify bool          `flag:"ssl-upstream-insecure-skip-verify" cfg:"ssl_upstream_insecure_skip_verify" env:"OAUTH2_PROXY_SSL_UPSTREAM_INSECURE_SKIP_VERIFY"` | ||||||
| 	SetAuthorization      bool          `flag:"set-authorization-header" cfg:"set_authorization_header" env:"OAUTH2_PROXY_SET_AUTHORIZATION_HEADER"` | 	SetXAuthRequest               bool          `flag:"set-xauthrequest" cfg:"set_xauthrequest" env:"OAUTH2_PROXY_SET_XAUTHREQUEST"` | ||||||
| 	PassAuthorization     bool          `flag:"pass-authorization-header" cfg:"pass_authorization_header" env:"OAUTH2_PROXY_PASS_AUTHORIZATION_HEADER"` | 	SetAuthorization              bool          `flag:"set-authorization-header" cfg:"set_authorization_header" env:"OAUTH2_PROXY_SET_AUTHORIZATION_HEADER"` | ||||||
| 	SkipAuthPreflight     bool          `flag:"skip-auth-preflight" cfg:"skip_auth_preflight" env:"OAUTH2_PROXY_SKIP_AUTH_PREFLIGHT"` | 	PassAuthorization             bool          `flag:"pass-authorization-header" cfg:"pass_authorization_header" env:"OAUTH2_PROXY_PASS_AUTHORIZATION_HEADER"` | ||||||
| 	FlushInterval         time.Duration `flag:"flush-interval" cfg:"flush_interval" env:"OAUTH2_PROXY_FLUSH_INTERVAL"` | 	SkipAuthPreflight             bool          `flag:"skip-auth-preflight" cfg:"skip_auth_preflight" env:"OAUTH2_PROXY_SKIP_AUTH_PREFLIGHT"` | ||||||
|  | 	FlushInterval                 time.Duration `flag:"flush-interval" cfg:"flush_interval" env:"OAUTH2_PROXY_FLUSH_INTERVAL"` | ||||||
| 
 | 
 | ||||||
| 	// These options allow for other providers besides Google, with
 | 	// These options allow for other providers besides Google, with
 | ||||||
| 	// potential overrides.
 | 	// potential overrides.
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue