Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Commit 93852a2

Browse files
authored
Merge pull request #362 from jehiah/ssl_insecure_skip_verify_362
Option to skip SSL verification
2 parents bb9b607 + dcf62d0 commit 93852a2

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Usage of oauth2_proxy:
200200
-signature-key="": GAP-Signature request signature key (algorithm:secretkey)
201201
-skip-auth-regex=: bypass authentication for requests path's that match (may be given multiple times)
202202
-skip-provider-button=false: will skip sign-in-page to directly reach the next step: oauth/start
203+
-ssl-insecure-skip-verify: skip validation of certificates presented when using HTTPS
203204
-tls-cert="": path to certificate file
204205
-tls-key="": path to private key file
205206
-upstream=: the http url(s) of the upstream endpoint or file:// paths for static files. Routing is based on the path

contrib/oauth2_proxy.cfg.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
## optional directory with custom sign_in.html and error.html
5555
# custom_templates_dir = ""
5656

57+
## skip SSL checking for HTTPS requests
58+
# ssl_insecure_skip_verify = false
59+
60+
5761
## Cookie Settings
5862
## Name - the cookie name
5963
## Secret - the seed string for secure cookies; should be 16, 24, or 32 bytes

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func main() {
3838
flagSet.Bool("pass-host-header", true, "pass the request Host Header to upstream")
3939
flagSet.Var(&skipAuthRegex, "skip-auth-regex", "bypass authentication for requests path's that match (may be given multiple times)")
4040
flagSet.Bool("skip-provider-button", false, "will skip sign-in-page to directly reach the next step: oauth/start")
41+
flagSet.Bool("ssl-insecure-skip-verify", false, "skip validation of certificates presented when using HTTPS")
4142

4243
flagSet.Var(&emailDomains, "email-domain", "authenticate emails with the specified domain (may be given multiple times). Use * to authenticate any email")
4344
flagSet.String("azure-tenant", "common", "go to a tenant-specific or common (tenant-independent) endpoint.")

options.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"crypto"
5+
"crypto/tls"
56
"encoding/base64"
67
"fmt"
78
"net/http"
@@ -47,14 +48,15 @@ type Options struct {
4748
CookieSecure bool `flag:"cookie-secure" cfg:"cookie_secure"`
4849
CookieHttpOnly bool `flag:"cookie-httponly" cfg:"cookie_httponly"`
4950

50-
Upstreams []string `flag:"upstream" cfg:"upstreams"`
51-
SkipAuthRegex []string `flag:"skip-auth-regex" cfg:"skip_auth_regex"`
52-
PassBasicAuth bool `flag:"pass-basic-auth" cfg:"pass_basic_auth"`
53-
BasicAuthPassword string `flag:"basic-auth-password" cfg:"basic_auth_password"`
54-
PassAccessToken bool `flag:"pass-access-token" cfg:"pass_access_token"`
55-
PassHostHeader bool `flag:"pass-host-header" cfg:"pass_host_header"`
56-
SkipProviderButton bool `flag:"skip-provider-button" cfg:"skip_provider_button"`
57-
PassUserHeaders bool `flag:"pass-user-headers" cfg:"pass_user_headers"`
51+
Upstreams []string `flag:"upstream" cfg:"upstreams"`
52+
SkipAuthRegex []string `flag:"skip-auth-regex" cfg:"skip_auth_regex"`
53+
PassBasicAuth bool `flag:"pass-basic-auth" cfg:"pass_basic_auth"`
54+
BasicAuthPassword string `flag:"basic-auth-password" cfg:"basic_auth_password"`
55+
PassAccessToken bool `flag:"pass-access-token" cfg:"pass_access_token"`
56+
PassHostHeader bool `flag:"pass-host-header" cfg:"pass_host_header"`
57+
SkipProviderButton bool `flag:"skip-provider-button" cfg:"skip_provider_button"`
58+
PassUserHeaders bool `flag:"pass-user-headers" cfg:"pass_user_headers"`
59+
SSLInsecureSkipVerify bool `flag:"ssl-insecure-skip-verify" cfg:"ssl_insecure_skip_verify"`
5860

5961
// These options allow for other providers besides Google, with
6062
// potential overrides.
@@ -99,7 +101,6 @@ func NewOptions() *Options {
99101
PassUserHeaders: true,
100102
PassAccessToken: false,
101103
PassHostHeader: true,
102-
SkipProviderButton: false,
103104
ApprovalPrompt: "force",
104105
RequestLogging: true,
105106
}
@@ -205,6 +206,13 @@ func (o *Options) Validate() error {
205206
msgs = parseSignatureKey(o, msgs)
206207
msgs = validateCookieName(o, msgs)
207208

209+
if o.SSLInsecureSkipVerify {
210+
insecureTransport := &http.Transport{
211+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
212+
}
213+
http.DefaultClient = &http.Client{Transport: insecureTransport}
214+
}
215+
208216
if len(msgs) != 0 {
209217
return fmt.Errorf("Invalid configuration:\n %s",
210218
strings.Join(msgs, "\n "))

0 commit comments

Comments
 (0)