mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 08:46:48 +00:00
Add config options for auth proxy
Adds two new environment variables and unit tests to validate positive and default use-cases. auth_proxy_url auth_proxy_pass_body Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
5b2a037e7e
commit
a66097a9f9
@ -137,6 +137,9 @@ func (ReadConfig) Read(hasEnv HasEnv) GatewayConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.AuthProxyURL = hasEnv.Getenv("auth_proxy_url")
|
||||||
|
cfg.AuthProxyPassBody = parseBoolValue(hasEnv.Getenv("auth_proxy_pass_body"))
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,9 +185,17 @@ type GatewayConfig struct {
|
|||||||
// Enable the gateway to scale any service from 0 replicas to its configured "min replicas"
|
// Enable the gateway to scale any service from 0 replicas to its configured "min replicas"
|
||||||
ScaleFromZero bool
|
ScaleFromZero bool
|
||||||
|
|
||||||
|
// MaxIdleConns with a default value of 1024, can be used for tuning HTTP proxy performance
|
||||||
MaxIdleConns int
|
MaxIdleConns int
|
||||||
|
|
||||||
|
// MaxIdleConnsPerHost with a default value of 1024, can be used for tuning HTTP proxy performance
|
||||||
MaxIdleConnsPerHost int
|
MaxIdleConnsPerHost int
|
||||||
|
|
||||||
|
// AuthProxyURL specifies URL for an authenticating proxy, disabled when blank, enabled when valid URL i.e. http://basic-auth.openfaas:8080/validate
|
||||||
|
AuthProxyURL string
|
||||||
|
|
||||||
|
// AuthProxyPassBody pass body to validation proxy
|
||||||
|
AuthProxyPassBody bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseNATS Use NATSor not
|
// UseNATS Use NATSor not
|
||||||
|
@ -299,3 +299,45 @@ func TestRead_MaxIdleConns_Override(t *testing.T) {
|
|||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRead_AuthProxy_Defaults(t *testing.T) {
|
||||||
|
defaults := NewEnvBucket()
|
||||||
|
|
||||||
|
readConfig := ReadConfig{}
|
||||||
|
wantURL := ""
|
||||||
|
wantBody := false
|
||||||
|
|
||||||
|
config := readConfig.Read(defaults)
|
||||||
|
|
||||||
|
if config.AuthProxyPassBody != wantBody {
|
||||||
|
t.Logf("config.AuthProxyPassBody, want: %t, got: %t\n", wantBody, config.AuthProxyPassBody)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.AuthProxyURL != wantURL {
|
||||||
|
t.Logf("config.AuthProxyURL, want: %s, got: %s\n", wantURL, config.AuthProxyURL)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRead_AuthProxy_DefaultsOverrides(t *testing.T) {
|
||||||
|
defaults := NewEnvBucket()
|
||||||
|
|
||||||
|
readConfig := ReadConfig{}
|
||||||
|
wantURL := "http://auth.openfaas:8080/validate"
|
||||||
|
wantBody := true
|
||||||
|
defaults.Setenv("auth_proxy_url", wantURL)
|
||||||
|
defaults.Setenv("auth_proxy_pass_body", fmt.Sprintf("%t", wantBody))
|
||||||
|
|
||||||
|
config := readConfig.Read(defaults)
|
||||||
|
|
||||||
|
if config.AuthProxyPassBody != wantBody {
|
||||||
|
t.Logf("config.AuthProxyPassBody, want: %t, got: %t\n", wantBody, config.AuthProxyPassBody)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.AuthProxyURL != wantURL {
|
||||||
|
t.Logf("config.AuthProxyURL, want: %s, got: %s\n", wantURL, config.AuthProxyURL)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user