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

Add flag to skip upstream validation and proxying. #649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func main() {

flagSet.String("signature-key", "", "GAP-Signature request signature key (algorithm:secretkey)")

flagSet.Bool("auth-request-mode",false, "proxy used with NGINX auth_request, so no upstream needed")

flagSet.Parse(os.Args[1:])

if *showVersion {
Expand Down
20 changes: 12 additions & 8 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type Options struct {

SignatureKey string `flag:"signature-key" cfg:"signature_key" env:"OAUTH2_PROXY_SIGNATURE_KEY"`

AuthRequestMode bool `flag:"auth-request-mode" cfg:"auth_request_mode" env:"OAUTH2_PROXY_AUTH_REQUEST_MODE"`

// internal values that are set after config validation
redirectURL *url.URL
proxyURLs []*url.URL
Expand Down Expand Up @@ -167,15 +169,17 @@ func (o *Options) Validate() error {

o.redirectURL, msgs = parseURL(o.RedirectURL, "redirect", msgs)

for _, u := range o.Upstreams {
upstreamURL, err := url.Parse(u)
if err != nil {
msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err))
} else {
if upstreamURL.Path == "" {
upstreamURL.Path = "/"
if o.AuthRequestMode == false {
for _, u := range o.Upstreams {
upstreamURL, err := url.Parse(u)
if err != nil {
msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err))
} else {
if upstreamURL.Path == "" {
upstreamURL.Path = "/"
}
o.proxyURLs = append(o.proxyURLs, upstreamURL)
}
o.proxyURLs = append(o.proxyURLs, upstreamURL)
}
}

Expand Down