Commit graph

25 commits

Author SHA1 Message Date
wasaga
db00821001
auth: do not strip query parameters in forward auth (#2216) 2021-05-28 17:19:18 -04:00
bobby
c199909032
forward-auth: fix special character support for nginx (#1578) 2020-11-12 13:10:57 -05:00
bobby
d1bab414c5
proxy/forward_auth: copy response headers as request headers (#1577)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-11-05 09:31:01 -08:00
bobby
9b39deabd8
forward-auth: use envoy's ext_authz check (#1482)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-10-04 20:01:06 -07:00
Manatsawin Hanmongkolchai
a47a3a0be6
proxy/forward_auth: don't reset forward auth path if X-Forwarded-Uri is not set (#1447) 2020-09-28 12:28:33 -07:00
Travis Groth
0537dd63d4
proxy: always use https for application callback (#1433) 2020-09-21 15:58:46 -04:00
Caleb Doxsey
d9a224a5e8
proxy: move properties to atomically updated state (#1280)
* authenticate: remove cookie options

* authenticate: remove shared key field

* authenticate: remove shared cipher property

* authenticate: move properties to separate state struct

* proxy: allow local state to be updated on configuration changes

* fix test

* return new connection

* use warn, collapse to single line

* address concerns, fix tests
2020-08-14 11:44:58 -06:00
Cuong Manh Le
e8d3ce1a2e
authorize,proxy: allow traefik forward auth without uri query (#1103)
In #1030, the fix was done without aware of the context that traefik
forward auth mode did allow request without the "?uri=". Previosuly,
this is done in proxy, and by converting the forward auth request to
actual request. The fix is #1030 prevent this conversion, to makre
authorize service aware of which is forward auth request.

But that causes traefik forward auth without "?uri" stop working. Fixing
it by making the authorize service also honor the forwarded uri header,
too.

Fixes #1096
2020-07-21 00:58:14 +07:00
Cuong Manh Le
58fb6ea3c4
proxy: fix invalid session after logout in forward auth mode (#1062)
Currently, authorize service does handle unauthenticated request in
forward auth mode, and return status 401.

But proxy has not handled the response yet, and always returns 403 for
both unauthenticated and unauthorized request. That breaks session
handling in forward auth mode. That said, if user was signed out, or for
any reason, authorize service return 401 status, proxy does not redirect
user to re-signin, but always return 403.

To fix it, proxy is changed to handle envoy check response in more
details, to distinguish between 401 and 403 status.

Thanks to @simbaja for rasing the problem and come up with original fix.

Fixes #1014
Fixes #858
2020-07-14 01:07:49 +07:00
Cuong Manh Le
9821476086 proxy: fix redirect url with traefik forward auth
With Traefik in forward auth mode, when accessing:

	https://example.com/foo

traefik will send a request like this to proxy:

	https://pomerium?uri=https://example.com

The path "/foo" is passed to proxy via "X-Forwarded-Uri" instead of via
query parameters. When proxy redirects request to authenticate, it only
set the "pomerirum_redirect_url" to the value of "uri".

So after authentication success, the user will be redirected to example.com
instead of example.com/foo. If "X-Forwarded-Uri" is present, we should
add it to redirect uri, so the user will be redirected to right place.
2020-07-04 01:23:44 +07:00
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
Caleb Doxsey
268a7067c1
forward-auth: support x-forwarded-uri (#780) 2020-05-26 14:07:20 -06:00
Caleb Doxsey
f40fb3d2ea
envoy: forward claim and assertion headers (#739) 2020-05-20 10:02:12 -06:00
Travis Groth
99e788a9b4 envoy: Initial changes 2020-05-18 17:10:10 -04:00
Travis Groth
b2e3b22f14
Update JWT headers to only be in responses from forward auth endpoint (#642) 2020-05-04 07:26:37 -04:00
Caleb Doxsey
b1d3bbaf56
authorize: add support for .pomerium and unauthenticated routes (#639)
* authorize: add support for .pomerium and unauthenticated routes
integration-tests: add test for forward auth dashboard urls

* proxy: fix ctx error test to return a 200 when authorize allows it
2020-04-29 10:55:46 -06:00
Caleb Doxsey
ea1c6efc24 authorize: fix domain check bug, rewrite url for forward auth, add dev script 2020-04-20 18:24:48 -06:00
branchmispredictor
0de3c431a6
forward-auth: validate using forwarded uri header (#600)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
Co-authored-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-04-20 10:56:30 -07:00
Bobby DeSimone
56e3f92181
proxy: remove unused session unmarshal (#592)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-04-07 19:59:40 -07:00
Bobby DeSimone
ba14ea246d
*: remove import path comments (#545)
- import path comments are obsoleted by the go.mod file's module statement

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-03-16 10:13:47 -07:00
Bobby DeSimone
8d1732582e
authorize: use jwt insead of state struct (#514)
authenticate: unmarshal and verify state from jwt, instead of middleware
authorize: embed opa policy using statik
authorize: have IsAuthorized handle authorization for all routes
authorize: if no signing key is provided, one is generated
authorize: remove IsAdmin grpc endpoint
authorize/client: return authorize decision struct
cmd/pomerium: main logger no longer contains email and group
cryptutil: add ECDSA signing methods
dashboard: have impersonate form show up for all users, but have api gated by authz
docs: fix typo in signed jwt header
encoding/jws: remove unused es256 signer
frontend: namespace static web assets
internal/sessions: remove leeway to match authz policy
proxy:  move signing functionality to authz
proxy: remove jwt attestation from proxy (authZ does now)
proxy: remove non-signed headers from headers
proxy: remove special handling of x-forwarded-host
sessions: do not verify state in middleware
sessions: remove leeway from state to match authz
sessions/{all}: store jwt directly instead of state

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-03-10 11:19:26 -07:00
Bobby DeSimone
2f13488598
authorize: use opa for policy engine (#474)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-02-02 11:18:22 -08:00
Bobby DeSimone
f0d811f2bb
proxy: fix unauthorized redirect loop (fwdauth) (#448)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2020-01-11 10:23:50 -08:00
Bobby DeSimone
b3d3159185
httputil : wrap handlers for additional context (#413)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2019-12-06 11:07:45 -08:00
Bobby DeSimone
0f6a9d7f1d
proxy: fix forward auth, request signing
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
2019-11-25 14:29:52 -08:00