diff --git a/README.md b/README.md index 9dd451e..4271305 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,6 @@ The following flags are available: --auto-login-ignore-paths strings Comma separated list of absolute paths to ignore when 'auto-login' is enabled. Supports basic wildcard matching with glob-style asterisks. Invalid patterns are ignored. --bind-address string Listen address for public connections. (default "127.0.0.1:3000") --encryption-key string Base64 encoded 256-bit cookie encryption key; must be identical in instances that share session store. ---error-path string Absolute path to redirect user to on errors for custom error handling. --ingress strings Comma separated list of ingresses used to access the main application. --log-format string Log format, either 'json' or 'text'. (default "json") --log-level string Logging verbosity level. (default "info") diff --git a/pkg/config/config.go b/pkg/config/config.go index 474fb7e..844ee7b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -22,7 +22,6 @@ type Config struct { AutoLogin bool `json:"auto-login"` AutoLoginIgnorePaths []string `json:"auto-login-ignore-paths"` EncryptionKey string `json:"encryption-key"` - ErrorPath string `json:"error-path"` Ingresses []string `json:"ingress"` Session Session `json:"session"` UpstreamHost string `json:"upstream-host"` @@ -73,7 +72,6 @@ const ( AutoLogin = "auto-login" AutoLoginIgnorePaths = "auto-login-ignore-paths" EncryptionKey = "encryption-key" - ErrorPath = "error-path" Ingress = "ingress" UpstreamHost = "upstream-host" @@ -106,7 +104,6 @@ func Initialize() (*Config, error) { flag.Bool(AutoLogin, false, "Automatically redirect all HTTP GET requests to login if the user does not have a valid session for all matching upstream paths.") flag.StringSlice(AutoLoginIgnorePaths, []string{}, "Comma separated list of absolute paths to ignore when 'auto-login' is enabled. Supports basic wildcard matching with glob-style asterisks. Invalid patterns are ignored.") flag.String(EncryptionKey, "", "Base64 encoded 256-bit cookie encryption key; must be identical in instances that share session store.") - flag.String(ErrorPath, "", "Absolute path to redirect user to on errors for custom error handling.") flag.StringSlice(Ingress, []string{}, "Comma separated list of ingresses used to access the main application.") flag.String(UpstreamHost, "127.0.0.1:8080", "Address of upstream host.") diff --git a/pkg/handler/error/error.go b/pkg/handler/error/error.go index dfc479a..7038299 100644 --- a/pkg/handler/error/error.go +++ b/pkg/handler/error/error.go @@ -4,7 +4,6 @@ import ( "context" "errors" "net/http" - "net/url" "strconv" "strings" @@ -29,7 +28,6 @@ const ( type Source interface { GetCookieOptsPathAware(r *http.Request) cookie.Options GetCrypter() crypto.Crypter - GetErrorPath() string GetPath(r *http.Request) string GetRedirectHandler() redirect.Handler } @@ -112,14 +110,6 @@ func (h Handler) respondError(w http.ResponseWriter, r *http.Request, statusCode } logger.Info("errorhandler: maximum retry attempts exceeded; executing error template...") - - if len(h.GetErrorPath()) > 0 { - err := h.customErrorRedirect(w, r, statusCode) - if err == nil { - return - } - } - h.defaultErrorResponse(w, r, statusCode) } @@ -141,27 +131,6 @@ func (h Handler) defaultErrorResponse(w http.ResponseWriter, r *http.Request, st } } -func (h Handler) customErrorRedirect(w http.ResponseWriter, r *http.Request, statusCode int) error { - override, err := url.ParseRequestURI(h.GetErrorPath()) - if err != nil { - return err - } - - // strip scheme and host to avoid cross-domain redirects - override.Scheme = "" - override.Host = "" - - query := override.Query() - query.Add("correlation_id", middleware.GetReqID(r.Context())) - query.Add("status_code", strconv.Itoa(statusCode)) - - override.RawQuery = query.Encode() - - errorRedirectURI := override.String() - http.Redirect(w, r, errorRedirectURI, http.StatusFound) - return nil -} - func getRetryAttempts(r *http.Request) (int, bool) { c, err := cookie.Get(r, cookie.Retry) if err != nil { diff --git a/pkg/handler/handler_default.go b/pkg/handler/handler_default.go index 2b21044..495d7e8 100644 --- a/pkg/handler/handler_default.go +++ b/pkg/handler/handler_default.go @@ -112,10 +112,6 @@ func (d *DefaultHandler) GetErrorHandler() errorhandler.Handler { return errorhandler.New(d) } -func (d *DefaultHandler) GetErrorPath() string { - return d.Config.ErrorPath -} - func (d *DefaultHandler) GetIngresses() *ingress.Ingresses { return d.Ingresses }