git.iko.soy/typeable/oauth2-proxy
on master help sign in
Introduce ProxyRawPath flag

Setting this flag will configure the upstream proxy to pass encoded urls as-is.

commitd51556515e73ed6e3245cabf0e2c5196e62489ee authorFabian Stelzer <fs@gigacodes.de> dateMon 9 Aug 2021, 14:57 (5 years ago) parent733b3fe
4 files changed+10
CHANGELOG.md+1 main_test.go+1 pkg/apis/options/upstreams.go+4 pkg/upstream/proxy.go+4
CHANGELOG.md+1
@@ -35,6 +35,7 @@
3535- [#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)
3636- [#1330](https://github.com/oauth2-proxy/oauth2-proxy/pull/1330) Allow specifying URL as input for custom sign in logo (@MaikuMori)
3737- [#1357](https://github.com/oauth2-proxy/oauth2-proxy/pull/1357) Fix unsafe access to session variable (@harzallah)
38+- [#997](https://github.com/oauth2-proxy/oauth2-proxy/pull/997) Allow passing the raw url path when proxying upstream requests - e.g. /%2F/ (@FStelzer)
3839
3940# V7.1.3
4041
main_test.go+1
@@ -27,6 +27,7 @@ client_secret="b2F1dGgyLXByb3h5LWNsaWVudC1zZWNyZXQK"
2727
2828 const testAlphaConfig = `
2929upstreams:
30+ proxyrawpath: false
3031 configs:
3132 - id: /
3233 path: /
pkg/apis/options/upstreams.go+4
@@ -9,6 +9,10 @@ const (
99
1010// Upstreams is a collection of definitions for upstream servers.
1111type Upstreams struct {
12+ // ProxyRawPath will pass the raw url path to upstream allowing for url's
13+ // like: "/%2F/" which would otherwise be redirected to "/"
14+ ProxyRawPath bool `json:"proxyRawPath,omitempty"`
15+
1216 // Upstream represents the configuration for an upstream server.
1317 // Requests will be proxied to this upstream if the path matches the request path.
1418 Configs []Upstream `json:"configs,omitempty"`
pkg/upstream/proxy.go+4
@@ -27,6 +27,10 @@ func NewProxy(upstreams options.Upstreams, sigData *options.SignatureData, write
2727 serveMux: mux.NewRouter(),
2828 }
2929
30+ if upstreams.ProxyRawPath {
31+ m.serveMux.UseEncodedPath()
32+ }
33+
3034 for _, upstream := range sortByPathLongest(upstreams.Configs) {
3135 if upstream.Static {
3236 if err := m.registerStaticResponseHandler(upstream, writer); err != nil {