Commit Graph

16 Commits

Author SHA1 Message Date
Ralf Haferkamp
dcf78f7f3d proxy(router): Allow to set some outgoing headers
This introduces the "additional_headers", "remote_user_header" and
"skip_x_access_token" config keys to allow configuring routes to
external services that require addtional headers to be set.

"remote_user_header": defines the name of a Header that will carry the
userid of the authenticated user on the outgoing request.

"additional_headers": defines a list of header names and values that will
be added to outgoing requests on matching routes.

"skip_x_access_token": when set to true the reva access token will not
be added to the outgoing request.

Needed for #206
2025-04-30 10:17:58 +02:00
Ralf Haferkamp
eb1ee57db9 fix: reset 'method' loop
The method var needs to be reset to "" when handling a route that is not
method specific.
2025-04-30 10:17:58 +02:00
Jörn Friedrich Dreyer
747b2879d7 proxy
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-16 17:31:51 +01:00
Jörn Friedrich Dreyer
b07b5a1149 use plain pkg module
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-13 16:42:19 +01:00
Jörn Friedrich Dreyer
8e028f17e9 change module name
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-13 09:58:18 +01:00
Jörn Friedrich Dreyer
4511f875d2 fix tests
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-08-06 13:33:18 +02:00
Jörn Friedrich Dreyer
4c6551501e use less selectors
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2024-08-06 12:55:42 +02:00
Ralf Haferkamp
07a718dc8e proxy: User ReverseProxy.Rewrite instead of Director
With Go 1.20 the "Rewrite" hook for ReverseProxy was introduced to
supersede of the "Director" hook (see:
a55793835f)

The Rewrite hooks allows for better separation between the incoming and
outgoing request. In particular it makes it pretty easy to set the
correct X-Forwarded-* Headers on the outgoing request.
The need for using "Rewrite" came up when trying to embed
authelia. It uses the X-Forwarded-Host and X-Forwared-Proto headers to
e.g. compute the correct return values for the various endpoints in
.well-known/openid-configuration.
2023-10-16 10:31:39 +02:00
Ralf Haferkamp
b24d126b30 Introduce TLS Settings for go-micro based http services
TLS for the services can be configure by setting the "OCIS_HTTP_TLS_ENABLED",
"OCIS_HTTP_TLS_CERTIFICATE" and "OCIS_HTTP_TLS_KEY" environment variables.
Currently the ocis proxy is this only service that directly accesses backend
services. It determines whether to use TLS or not by looking a the new registry
metadata "use_tls". As specific CA Cert for certificate verification
can be set with the "PROXY_HTTPS_CACERT" environment variable.
2022-11-03 11:58:53 +01:00
Ralf Haferkamp
8ee8842e88 proxy: Avoid sorting endpoints for every single request
The endpoints are no longer hashed by path name in the directors map since
that made iterating over the endpoints unstable. They are now stored in a
slice in the order in which the are defined in the configuration.

Closes: #4497
2022-09-07 14:30:19 +02:00
Ralf Haferkamp
30f4d788f3 proxy: Initialize logger for router 2022-09-07 14:30:19 +02:00
Ralf Haferkamp
fed62d4a1e Evaluate routing rules ordered by path-length
This is a quickfix for #4497. Before evaluating, we now sort the rules
of a specific type by the length of the endpoints and start evaluation
with the most specific endpoint first. There's obviously quite a bit
room for optimization here and this will only fix the issue for routes
of type `PrefixRoute`. But it should solve the immediate issue.
2022-09-01 17:07:17 +02:00
David Christofas
bfb26cc660 update tests 2022-09-01 12:43:32 +02:00
David Christofas
69de4616b5 fix linting issues 2022-09-01 12:43:32 +02:00
David Christofas
69ba80562e add unprotected flag to the proxy routes
I added an unprotected flag to the proxy routes which is evaluated by
the authentication middleware. This way we won't have to maintain a
hardcoded list of unprotected paths and path prefixes and we will
hopefully reduce the times we encounter the basic auth prompt by web
browsers.
2022-09-01 12:43:32 +02:00
David Christofas
4d4f3a16e1 refactor proxy code
I refactored the proxy so that we execute the routing before the
authentication middleware. This is necessary so that we can determine
which routes are considered unprotected i.e. which routes don't need
authentication.
2022-09-01 12:43:32 +02:00