pomerium/authorize
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
..
evaluator cryptutil: move to pkg dir, add token generator (#1029) 2020-06-30 15:55:33 -06:00
authorize.go cryptutil: move to pkg dir, add token generator (#1029) 2020-06-30 15:55:33 -06:00
authorize_test.go feature/databroker: user data and session refactor project (#926) 2020-06-19 07:52:44 -06:00
check_response.go authorize: get claims from signed jwt (#954) 2020-06-22 09:51:32 +07:00
grpc.go proxy: fix wrong forward auth request 2020-07-03 00:00:20 +07:00
grpc_test.go authorize: honor X-Forwarded-Uri in forward auth mode 2020-07-03 00:00:20 +07:00
run.go grpc: rename internal/grpc to pkg/grpc (#1010) 2020-06-26 09:17:02 -06:00
session.go authorize: get claims from signed jwt (#954) 2020-06-22 09:51:32 +07:00
session_test.go feature/databroker: user data and session refactor project (#926) 2020-06-19 07:52:44 -06:00