Add support for https in proxy request for external authentication
This commit is contained in:
parent
db4cbac2e8
commit
ab1f04b9c2
2 changed files with 24 additions and 4 deletions
|
@ -199,6 +199,8 @@ http {
|
||||||
# In case of errors try the next upstream server before returning an error
|
# In case of errors try the next upstream server before returning an error
|
||||||
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504{{ if $cfg.RetryNonIdempotent }} non_idempotent{{ end }};
|
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504{{ if $cfg.RetryNonIdempotent }} non_idempotent{{ end }};
|
||||||
|
|
||||||
|
proxy_ssl_session_reuse on;
|
||||||
|
|
||||||
{{range $name, $upstream := $backends}}
|
{{range $name, $upstream := $backends}}
|
||||||
upstream {{$upstream.Name}} {
|
upstream {{$upstream.Name}} {
|
||||||
{{ if eq $upstream.SessionAffinity.AffinityType "cookie" }}
|
{{ if eq $upstream.SessionAffinity.AffinityType "cookie" }}
|
||||||
|
@ -278,6 +280,9 @@ http {
|
||||||
proxy_set_header X-Scheme $pass_access_scheme;
|
proxy_set_header X-Scheme $pass_access_scheme;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
proxy_pass_request_headers on;
|
proxy_pass_request_headers on;
|
||||||
|
proxy_set_header Host {{ $location.ExternalAuth.Host }};
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
|
||||||
set $target {{ $location.ExternalAuth.URL }};
|
set $target {{ $location.ExternalAuth.URL }};
|
||||||
proxy_pass $target;
|
proxy_pass $target;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ const (
|
||||||
// External returns external authentication configuration for an Ingress rule
|
// External returns external authentication configuration for an Ingress rule
|
||||||
type External struct {
|
type External struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
|
// Host contains the hostname defined in the URL
|
||||||
|
Host string `json:"host"`
|
||||||
SigninURL string `json:"signinUrl"`
|
SigninURL string `json:"signinUrl"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
SendBody bool `json:"sendBody"`
|
SendBody bool `json:"sendBody"`
|
||||||
|
@ -129,9 +131,22 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
|
|
||||||
return &External{
|
return &External{
|
||||||
URL: str,
|
URL: str,
|
||||||
|
Host: stripPort(ur.Host),
|
||||||
SigninURL: signin,
|
SigninURL: signin,
|
||||||
Method: m,
|
Method: m,
|
||||||
SendBody: sb,
|
SendBody: sb,
|
||||||
ResponseHeaders: h,
|
ResponseHeaders: h,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove after upgrade to Go 1.8
|
||||||
|
func stripPort(hostport string) string {
|
||||||
|
colon := strings.IndexByte(hostport, ':')
|
||||||
|
if colon == -1 {
|
||||||
|
return hostport
|
||||||
|
}
|
||||||
|
if i := strings.IndexByte(hostport, ']'); i != -1 {
|
||||||
|
return strings.TrimPrefix(hostport[:i], "[")
|
||||||
|
}
|
||||||
|
return hostport[:colon]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue