Introduce ProxyRawPath flag

Setting this flag will configure the upstream proxy to pass encoded urls
as-is.
This commit is contained in:
Fabian Stelzer 2021-08-09 14:57:40 +00:00
parent 733b3fe642
commit d51556515e
No known key found for this signature in database
4 changed files with 10 additions and 0 deletions

View File

@ -35,6 +35,7 @@
- [#1317](https://github.com/oauth2-proxy/oauth2-proxy/pull/1317) Fix incorrect `</form>` tag on the sing_in page when *not* using a custom template (@jord1e) - [#1317](https://github.com/oauth2-proxy/oauth2-proxy/pull/1317) Fix incorrect `</form>` tag on the sing_in page when *not* using a custom template (@jord1e)
- [#1330](https://github.com/oauth2-proxy/oauth2-proxy/pull/1330) Allow specifying URL as input for custom sign in logo (@MaikuMori) - [#1330](https://github.com/oauth2-proxy/oauth2-proxy/pull/1330) Allow specifying URL as input for custom sign in logo (@MaikuMori)
- [#1357](https://github.com/oauth2-proxy/oauth2-proxy/pull/1357) Fix unsafe access to session variable (@harzallah) - [#1357](https://github.com/oauth2-proxy/oauth2-proxy/pull/1357) Fix unsafe access to session variable (@harzallah)
- [#997](https://github.com/oauth2-proxy/oauth2-proxy/pull/997) Allow passing the raw url path when proxying upstream requests - e.g. /%2F/ (@FStelzer)
# V7.1.3 # V7.1.3

View File

@ -27,6 +27,7 @@ client_secret="b2F1dGgyLXByb3h5LWNsaWVudC1zZWNyZXQK"
const testAlphaConfig = ` const testAlphaConfig = `
upstreams: upstreams:
proxyrawpath: false
configs: configs:
- id: / - id: /
path: / path: /

View File

@ -9,6 +9,10 @@ const (
// Upstreams is a collection of definitions for upstream servers. // Upstreams is a collection of definitions for upstream servers.
type Upstreams struct { type Upstreams struct {
// ProxyRawPath will pass the raw url path to upstream allowing for url's
// like: "/%2F/" which would otherwise be redirected to "/"
ProxyRawPath bool `json:"proxyRawPath,omitempty"`
// Upstream represents the configuration for an upstream server. // Upstream represents the configuration for an upstream server.
// Requests will be proxied to this upstream if the path matches the request path. // Requests will be proxied to this upstream if the path matches the request path.
Configs []Upstream `json:"configs,omitempty"` Configs []Upstream `json:"configs,omitempty"`

View File

@ -27,6 +27,10 @@ func NewProxy(upstreams options.Upstreams, sigData *options.SignatureData, write
serveMux: mux.NewRouter(), serveMux: mux.NewRouter(),
} }
if upstreams.ProxyRawPath {
m.serveMux.UseEncodedPath()
}
for _, upstream := range sortByPathLongest(upstreams.Configs) { for _, upstream := range sortByPathLongest(upstreams.Configs) {
if upstream.Static { if upstream.Static {
if err := m.registerStaticResponseHandler(upstream, writer); err != nil { if err := m.registerStaticResponseHandler(upstream, writer); err != nil {