Commit graph

420 commits

Author SHA1 Message Date
Caleb Doxsey
20a9be891f
envoyconfig: cleanup (#5350)
* envoyconfig: cleanup

* remove listener access log for mtls for insecure server which can't use mtls

* use new functions

* rename method

* refactor common code
2024-11-18 09:50:23 -07:00
Joe Kralicky
177f789e63
change Policy.Matches to accept a URL pointer (#5360) 2024-11-07 14:55:44 -05:00
Joe Kralicky
ebd9eea30e
Optimize Policy RouteID (#5359) 2024-11-06 12:31:52 -05:00
Joe Kralicky
c8b6b8f1a9
config: only validate redirect response code when non-nil (#5358)
* config: only validate redirect response code when non-nil

* update unit tests

---------

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
2024-11-05 15:57:59 -05:00
Joe Kralicky
526e2a58d6
New integration test fixtures (#5233)
* Initial test environment implementation

* linter pass

* wip: update request latency test

* bugfixes

* Fix logic race in envoy process monitor when canceling context

* skip tests using test environment on non-linux
2024-11-05 14:31:40 -05:00
Kenneth Jenkins
3d958ff9c5
config: fix redirect response code (#5346) 2024-11-05 10:38:02 -08:00
Joe Kralicky
fe31799eb5
Fix many instances of contexts and loggers not being propagated (#5340)
This also replaces instances where we manually write "return ctx.Err()"
with "return context.Cause(ctx)" which is functionally identical, but
will also correctly propagate cause errors if present.
2024-10-25 14:50:56 -04:00
Joe Kralicky
a42e286637
Add new jwt issuer format route option (#5338) 2024-10-25 13:07:47 -04:00
Caleb Doxsey
9e9ed8853f
ppl: more flexible matchers (#5336)
* ppl: more flexible matchers

* make the string list matcher "is" match arrays with only a single item

* re-use has

* default list matcher to has
2024-10-25 07:56:57 -06:00
Caleb Doxsey
d2c14cd6d2
logging: remove ctx from global log methods (#5337)
* log: remove warn

* log: update debug

* log: update info

* remove level, log

* remove contextLogger function
2024-10-23 14:18:52 -06:00
Joe Kralicky
1ccaf1b22b
config: suppress unused warnings for all fields in embedded route envoy options (#5330) 2024-10-22 16:46:22 -04:00
Kenneth Jenkins
11054a943d
config: set_response_headers is not unknown (#5326)
Most fields in the config.Options struct are populated by the
mapstructure package, but the SetResponseHeaders field is handled
separately. As a result, when the set_response_headers key is present,
it also shows up as an unknown config option.

Add this key to the ignoreConfigFields map, to avoid logging an
incorrect "unknown config option" message when set.
2024-10-15 12:40:14 -07:00
Caleb Doxsey
075ea01b0a
core/config: allow websockets and spdy by default for k8s urls (#5325) 2024-10-10 17:55:34 -06:00
Caleb Doxsey
27947b19cb
core/config: add kubernetes_service_account_token_file (#5322)
* core/config: add kubernetes_service_account_token_file

* fix loading of token file
2024-10-10 14:53:45 -06:00
Joe Kralicky
0e13248685
Core-Zero Import (#5288)
* initial core-zero import implementation

* Update /config/import openapi description and use PUT instead of POST

* update import ui tests

* Add 413 as a possible response for /config/import

* Options/Settings type conversion tests and related bugfixes

* Fixes for proto type conversion and tests

* Update core-zero import client

* Update core-zero import client

* Update import api and environment detection

* update go.mod

* remove old testdata

* Remove usage of deleted setting after merge

* remove extra newline from --version output
2024-10-09 18:51:56 -04:00
Caleb Doxsey
410354bc00
core/go: use hashicorp/go-set (#5278) 2024-10-03 12:59:11 -06:00
Kenneth Jenkins
01d375f0bc
config: remove unused gRPC setting (#5308)
Remove the grpc_client_dns_roundrobin option as it appears to be unused
since commit bbec2cae9f.
2024-10-03 10:14:54 -07:00
Caleb Doxsey
bfc782ff06
core/zero: add pseudonymization key (#5290) 2024-09-19 14:43:01 -06:00
Caleb Doxsey
52d4899d4c
core/proxy: support loading sessions from headers and query string (#5291)
* core/proxy: support loading sessions from headers and query string

* update test
2024-09-19 09:23:13 -06:00
Joe Kralicky
d06a101f79
ppl: fix empty/no-op allow block added in some cases to converted PPL policies (#5289)
Fix empty/no-op allow block added in some cases to converted PPL policies
2024-09-16 18:52:54 -04:00
Kenneth Jenkins
6171c09596
config: remove unused databroker storage settings (#5285)
Config options concerning the TLS connection from databroker to storage
backend are now unused. TLS options for this connection can instead be
set directly in the databroker storage connection string.
2024-09-16 11:58:57 -07:00
Caleb Doxsey
10e1746471
core/authorize: remove default header logging in debug (#5287) 2024-09-13 13:04:33 -06:00
Caleb Doxsey
790c11b368
core/zero: add organization id and cluster id to bootstrap config (#5275) 2024-09-10 11:31:45 -06:00
Joe Kralicky
653d8f9594
Revert "config: allow overriding port numbers using environment variables (#5194)" (#5273)
This reverts commit fdefcf9a16.

This was originally intended for a specific integration test use case,
but it did not end up being needed. Additionally, the environment
variable names can conflict with Kubernetes service environment variables.
2024-09-09 19:30:48 -04:00
Caleb Doxsey
dad954ae16
core/logging: change log.Error function (#5251)
* core/logging: change log.Error function

* use request id
2024-09-05 15:42:46 -06:00
Caleb Doxsey
073d1564ba
core/envoy: allow TLS 1.3 (#5263) 2024-09-05 06:00:18 -06:00
Kenneth Jenkins
014824b525
proxy: deprecate the /.pomerium/jwt endpoint (#5254)
Disable the /.pomerium/jwt endpoint by default. Add a runtime flag to
temporarily opt out of the deprecation.
2024-09-04 11:22:18 -07:00
Kenneth Jenkins
2b84111058
config: sort runtime flags, name consistency (#5255)
Sort the runtime flag definitions alphabetically. Rename
envoy_resource_manager_enabled to just envoy_resource_manager for
consistency with the other flag names. (This flag hasn't been released
yet, so it should be OK to rename it.) Also add a doc comment.
2024-09-03 13:37:19 -07:00
Caleb Doxsey
f3620cf6e9
core/config: add databroker_storage_connection_string_file (#5242)
* core/config: add databroker_storage_connection_string_file

* add file to file list
2024-08-27 09:42:14 -06:00
Caleb Doxsey
d062f9d68d
core/logs: remove warnings (#5235)
* core/logs: remove warnings

* switch to error
2024-08-27 09:38:50 -06:00
Joe Kralicky
56ba07e53e
Optimize policy iterators (#5184)
* Optimize policy iterators (go1.23)

This modifies (*Options).GetAllPolicies() to use a go 1.23 iterator
instead of copying all policies on every call, which can be extremely
expensive. All existing usages of this function were updated as
necessary.

Additionally, a new (*Options).NumPolicies() method was added which
quickly computes the number of policies that would be given by
GetAllPolicies(), since there were several usages where only the
number of policies was needed.

* Fix race condition when assigning default envoy opts to a policy
2024-08-20 12:35:10 -04:00
Joe Kralicky
332932b7a8
Replace usages of x/exp/maps + bump golang.org/x/exp (#5221)
Bump golang.org/x/exp; replace usages of x/exp/maps with stdlib equivalents
2024-08-15 17:49:24 -04:00
Joe Kralicky
e3e7de741c
envoy: support http2 prior knowledge for insecure upstream targets (#5205)
This allows using the scheme 'h2c' to indicate http2 prior knowledge for
insecure upstream servers. This can be used to perform TLS termination for
GRPC servers configured with insecure credentials.

As an example, this allows the following route configuration:

routes:
  - from: https://grpc.localhost.pomerium.io
    to: h2c://localhost:9090
2024-08-13 13:40:44 -04:00
Joe Kralicky
554e77bc7c
envoy: log mtls failures (#5210)
envoy: log mtls failures

This implements limited listener-based access logging for downstream
transport failures, only enabled when downstream_mtls.enforcement is
set to 'reject_connection'. Client certificate details and the error
message will be logged.

Additionally, the new key 'client-certificate' can be set in the
access_log_fields list in the configuration, which will add peer
certificate properties (issuer, subject, SANs) to the existing
per-request http logs.

---------

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
2024-08-09 14:05:10 -04:00
Joe Kralicky
fdefcf9a16
config: allow overriding port numbers using environment variables (#5194) 2024-08-01 14:55:52 -04:00
Kenneth Jenkins
dbedfc586f
add mTLS UserPrincipalName SAN match (#5177)
Add a new 'user_principal_name' type to the downstream mTLS
match_subject_alt_names option. This corresponds to the 'OtherName' type
with type-id 1.3.6.1.4.1.311.20.2.3 and a UTF8String value.
Add support for UserPrincipalName SAN matching to the policy evaluator.
2024-07-26 10:23:19 -07:00
Caleb Doxsey
e5e6558de6
core/authorize: require new login when authenticate url changes (#5165) 2024-07-12 10:57:41 -06:00
Caleb Doxsey
9ebf42ad53
core/autocert: fix filter chain, handshake (#5150)
* core/autocert: fix filter chain, handshake

* only enable http challenges on port 80
2024-06-26 11:17:35 -06:00
Denis Mishin
c1dec06afa
zero/telemetry: internal envoy stats scraper and metrics producer (#5136) 2024-06-16 20:41:05 -04:00
Joe Kralicky
c3534df885
Add runtime flag to allow disabling config hot-reload (#5079) (#5112)
* Add runtime flag to allow disabling config hot-reload (#5079)

* Add unit tests

* Log at info level instead of warning
2024-06-12 23:20:30 -04:00
Joe Kralicky
927f24e1ff
Envoy resource monitoring & overload manager configuration (#5106)
* Initial envoy cgroup resource monitor implementation

* Add cgroupv1 support; add metrics instrumentation

* Slight refactor for more efficient memory limit detection

Instead of reading memory.max/limit_in_bytes on every tick, we
read it once, then again only when it is modified.

To support this change, logic for computing the saturation was moved out
of the cgroup driver and into the resource monitor, and the driver
interface now has separate methods for reading memory usage and limit.

* Code cleanup/lint fixes

* Add platform build tags

* Add unit tests

* Fix lint issues

* Add runtime flag to allow disabling resource monitor

* Clamp saturation values to the range [0.0, 1.0]

* Switch to x/sys/unix; handle inotify IN_IGNORED events
2024-05-28 16:57:09 -04:00
Caleb Doxsey
568e99fdd4
core/envoy: exclude unauthorized access from local replies (#5108)
* core/envoy: exclude unauthorized access from local replies

* fix test
2024-05-09 11:09:38 -06:00
Caleb Doxsey
d225288ab3
core/identity: dynamic authenticator registration (#5105) 2024-05-07 16:45:39 -06:00
Caleb Doxsey
1a5b8b606f
core/lint: upgrade golangci-lint, replace interface{} with any (#5099)
* core/lint: upgrade golangci-lint, replace interface{} with any

* regen proto
2024-05-02 14:33:52 -06:00
Caleb Doxsey
a95423b310
core/identity: refactor identity manager (#5091)
* core/identity: add data store for thread-safe storage of sessions and users

* wip

* add test

* wip

* clean up context

* fix nil session error

* add stop message

* remove log

* use origin context

* use base context for manager calls

* use manager context for syncers too

* add runtime flag

* rename legacy lease

* add comment

* use NotSame

* add comment

* Update internal/identity/manager/manager.go

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>

* lint

---------

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
2024-05-02 10:27:06 -06:00
Kenneth Jenkins
a3149363a6
envoyconfig: address strconv.Atoi warnings (#5076)
Replace Atoi() calls with ParseUint(), and update the buildAddress()
defaultPort parameter to be a uint32. (A uint16 would arguably make more
sense for a port number, but uint32 matches the Envoy proto field.)

Delete a ParseAddress() method that appears to be unused.
2024-04-26 09:38:41 -07:00
Caleb Doxsey
5373e25ac4
core/config: add support for stripping the port for matching routes (#5085)
* core/config: add support for stripping the port for matching routes

* fix test

* rename option, improve port detection

* add more test cases
2024-04-26 08:24:46 -06:00
Kenneth Jenkins
498c3aa108
config: add support for TCP proxy chaining (#5053)
Add a distinction between TCP routes depending on whether the To URL(s)
have the scheme tcp://. For routes with a TCP upstream, configure Envoy
to terminate CONNECT requests and open a TCP tunnel to the upstream
service (this is the current behavior). For routes without a TCP
upstream, configure Envoy to proxy CONNECT requests to the upstream.

This new mode can allow an upstream proxy server to terminate a CONNECT
request and open its own TCP tunnel to the final destination server.
(Note that this will typically require setting the preserve_host_header
option as well.)

Note that this requires Envoy 1.30 or later.
2024-04-24 16:35:18 -07:00
Kenneth Jenkins
05e077fe04
envoy: migrate deprecated overload setting (#5082)
Migrate from overload.global_downstream_max_connections to the suggested
envoy.resource_monitors.global_downstream_max_connections replacement.
2024-04-22 18:53:24 -07:00
Caleb Doxsey
494dc4accc
core/envoy: format envoy local replies (#5067) 2024-04-18 09:22:15 -06:00