pomerium/proxy
Cuong Manh Le 846d709ba4 proxy: fix wrong forward auth request
When proxy receives forward auth request, it should forward the request
as-is to authorize for verification. Currently, it composes the check
request with actual path, then send the request to authorize service.

It makes the request works accidently, because the composed check
request will satisfy the policy un-intentionally. Example, for forward
auth request:

	http://pomerium/?uri=https://httpbin.localhost.pomerium.io

the composed request will look like:

	&envoy_service_auth_v2.AttributeContext_HttpRequest{
		Method:   "GET",
		Headers:  map[string]string{},
		Path:     "",
		Host:     "httpbin.localhost.pomerium.io",
		Scheme:   "https",
	}

This check request has at least two problems.

First, it will make authorize.handleForwardAuth always returns false,
even though this is a real forward auth request. Because the "Host"
field in check request is not the forward auth host, which is "pomerium"
in this case.

Second, it will accidently matches rule like:

	policy:
	  - from: https://httpbin.localhost.pomerium.io
	    to: https://httpbin
	    allowed_domains:
	      - pomerium.io

If the rule contains other conditions, like "prefix", or "regex":

	policy:
	  - from: https://httpbin.localhost.pomerium.io
	    prefix: /headers
	    to: https://httpbin
	    allowed_domains:
	      - pomerium.io

Then the rule will never be triggered, because the "/headers" path can
be passed in request via "X-Forwarded-Uri" (traefik), instead of
directly from the path (nginx).

To fix this, we just pass the forward auth request as-is to authorize.

Fixes #873
2020-07-03 00:00:20 +07:00
..
forward_auth.go proxy: fix wrong forward auth request 2020-07-03 00:00:20 +07:00
forward_auth_test.go feature/databroker: user data and session refactor project (#926) 2020-06-19 07:52:44 -06:00
handlers.go cryptutil: move to pkg dir, add token generator (#1029) 2020-06-30 15:55:33 -06:00
handlers_test.go cryptutil: move to pkg dir, add token generator (#1029) 2020-06-30 15:55:33 -06:00
middleware.go proxy: fix wrong forward auth request 2020-07-03 00:00:20 +07:00
middleware_test.go feature/databroker: user data and session refactor project (#926) 2020-06-19 07:52:44 -06:00
proxy.go cryptutil: move to pkg dir, add token generator (#1029) 2020-06-30 15:55:33 -06:00
proxy_test.go envoy: Initial changes 2020-05-18 17:10:10 -04:00