Commit graph

737 commits

Author SHA1 Message Date
Denis Mishin
d610b9c25c
zero/core: set drwx------ for cache dir (#4764) 2023-11-27 10:36:25 -05:00
Denis Mishin
7e2532f644
zero/bundle-reconciler: better code reuse (#4758) 2023-11-21 14:32:52 -05:00
Kenneth Jenkins
14b13bb791
zero: use os.UserCacheDir for boostrap config path (#4744) 2023-11-17 14:44:32 -08:00
Caleb Doxsey
6810091d38
core/zero: add support for managed mode from config file (#4756) 2023-11-17 09:04:59 -07:00
Kenneth Jenkins
59bd8b3dfa
zero/reconciler: fix restart behavior (#4753)
Currently the RunWithRestart() loop may not exit when execFn returns an
error unrelated to its context cancellation. Add an additional check for
this case.
2023-11-15 14:03:22 -08:00
Caleb Doxsey
3c2dc5e0a2 core/zero: fix urls (#4743) 2023-11-15 09:21:56 -08:00
Denis Mishin
86e4ad65d1 zero: derive signing key first thing (#4631) 2023-11-15 09:21:56 -08:00
Denis Mishin
0e1061d813 zero: restart config reconciliation when databroker storage is changed (#4623) 2023-11-15 09:21:56 -08:00
Denis Mishin
60ab9dafbe zero: report resource bundle reconciliation status (#4618)
* zero: report resource bundle reconciliation status

* use latest zero-sdk
2023-11-15 09:21:56 -08:00
Denis Mishin
e64e682853 zero: rm extra call on start (#4474) 2023-11-15 09:21:56 -08:00
Denis Mishin
e0236d3737 zero: managed mode controller (#4459) 2023-11-15 09:21:56 -08:00
Denis Mishin
ea8762d706 zero: resource bundle reconciler (#4445) 2023-11-15 09:21:56 -08:00
Denis Mishin
c0b1309e90 zero: bootstrap config (#4444) 2023-11-15 09:21:56 -08:00
Denis Mishin
5ddfc74645 add retry package (#4458) 2023-11-15 09:21:56 -08:00
Denis Mishin
bf1cd0aa18
authorize: build evaluators cache in parallel (#4722)
* authorize: build evaluators cache in parallel

* session: add unit tests for gRPC wrapper methods (#4713)

* core/config: add support for maps in environments (#4717)

* reconciler: allow custom comparison function (#4726)

* add loopvar alias

---------

Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
2023-11-09 11:49:34 -05:00
Denis Mishin
bfcc970839
databroker: build config concurrently, option to bypass validation (#4655)
* validation: option to bypass

* concurrently build config

* add regex_priority_order and route sorting

* rm mutex
2023-11-06 13:21:29 -05:00
Kenneth Jenkins
ab104a643a
rework session updates to use new patch method (#4705)
Update the AccessTracker, WebAuthn handlers, and identity manager
refresh loop to perform their session record updates using the
databroker Patch() method.

This should prevent any of these updates from conflicting.
2023-11-06 09:43:07 -08:00
Caleb Doxsey
2771a5ae87
core/config: refactor file watcher (#4702)
* core/config: refactor file watcher

* add comments

* updates

* only use the polling watcher

* fix test

* fix test

* try to fix test again

* remove batching

* dont rely on file modification timestamp

* remove benchmark

* try fix again
2023-11-03 15:53:20 -06:00
Kenneth Jenkins
d5da872157
databroker: add patch method (#4704)
Add a Patch() method to the databroker gRPC service.

Update the storage.Backend interface to include the Patch() method now
that all the storage.Backend implementations include it.

Add a test to exercise the patch method under concurrent usage.
2023-11-02 15:07:37 -07:00
Kenneth Jenkins
4f648e9ac1
databroker: remove redis storage backend (#4699)
Remove the Redis databroker backend. According to
https://www.pomerium.com/docs/internals/data-storage#redis it has been
discouraged since Pomerium v0.18.

Update the config options validation to return an error if "redis" is 
set as the databroker storage backend type.
2023-11-02 11:53:25 -07:00
Caleb Doxsey
5f4e13e130
core/events: fix flaky test (#4700)
* core/events: use synchronous channel to fix flaky test

* switch to mutexes

* remove test
2023-11-02 11:28:28 -06:00
Denis Mishin
0b79a28328
xds: add type url to log (#4696) 2023-11-01 16:50:59 -04:00
Caleb Doxsey
e0693e54f0
core/config: refactor change dispatcher (#4657)
* core/config: refactor change dispatcher

* update test

* close listener go routine when context is canceled

* use cancel cause

* use context

* add more time

* more time
2023-11-01 13:52:23 -06:00
Caleb Doxsey
53573dc046
core/config: remove version (#4653)
* core/config: remove version

* lint

* fix
2023-11-01 10:19:55 -06:00
Caleb Doxsey
6511440c2f
core/controlplane: apply configuration changes in a background thread (#4649)
* core/controlplane: apply configuration changes in a background thread

* core/controlplane: build envoy resources in goroutines

* tracing
2023-10-31 16:47:13 -06:00
Caleb Doxsey
ae420f01c6
core/config: add config version, additional telemetry (#4645)
* core/config: add config version, additional telemetry

* typo
2023-10-27 15:16:40 -06:00
Caleb Doxsey
818f3926bf
core/grpc: fix deprecated protobuf package, remove tools (#4643) 2023-10-26 11:38:54 -06:00
Kenneth Jenkins
1d2c525b1a
identity: rework session refresh error handling (#4638)
Currently, if a temporary error occurs while attempting to refresh an
OAuth2 token, the identity manager won't schedule another attempt.

Instead, update the session refresh logic so that it will retry after
temporary errors. Extract the bulk of this logic into a separate method
that returns a boolean indicating whether to schedule another refresh.

Update the unit test to simulate a temporary error during OAuth2 token
refresh.
2023-10-24 15:44:51 -07:00
Kenneth Jenkins
fa7dc469a3
identity: preserve session refresh schedule (#4633)
The databroker identity manager is responsible for refreshing session
records, to account for overall session expiration as well as OAuth2
access token expiration.

Refresh events are scheduled subject to a coolOffDuration (10 seconds,
by default) relative to a lastRefresh timestamp. Currently, any update
to a session record will reset the associated lastRefresh value and
reschedule any pending refresh event for that session. If an update
occurs close before a scheduled refresh event, this will push back the
scheduled refresh event to 10 seconds from that time.

This means that if a session is updated frequently enough (e.g. if there
is a steady stream of requests that cause constant updates via the
AccessTracker), the access token may expire before a refresh ever runs.

To avoid this problem, do not update the lastRefresh time upon every
session record update, but only if it hasn't yet been set. Instead,
update the lastRefresh during the refresh attempt itself.

Add unit tests to exercise these changes. There is a now() function as
part of the manager configuration (to allow unit tests to set a fake
time); update the Manager to use this function throughout.
2023-10-24 14:46:33 -07:00
Kenneth Jenkins
39a477c510
identity: override TokenSource expiry behavior (#4632)
The current session refresh loop attempts to refresh access tokens when
they are due to expire in less than one minute. However, the code to
perform the refresh relies on a TokenSource from the x/oauth2 package,
which has its own internal 'expiryDelta' threshold, with a default of
10 seconds. As a result, the first four or five attempts to refresh a
particular access token will not actually refresh the token. The refresh
will happen only when the access token is within 10 seconds of expiring.

Instead, before we obtain a new TokenSource, first clear any existing
access token. This causes the TokenSource to consider the token invalid,
triggering a refresh. This should give the refresh loop more control
over when refreshes happen.

Consolidate this logic in a new Refresh() method in the oidc package.
Add unit tests for this new method.
2023-10-23 08:20:04 -07:00
Caleb Doxsey
a0c92896ef
core/authenticate: refactor idp sign out (#4582) 2023-09-28 08:41:19 -07:00
Sylvain Rabot
7211a8d819
Add metric request error in log (#4585)
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
2023-09-21 15:29:35 -06:00
Caleb Doxsey
723bd91e4b
core/identity: fix slow restart (#4542) 2023-09-15 12:14:24 -06:00
Caleb Doxsey
2220d1edf0
logs: add ip address to access logs (#4391) 2023-08-09 07:09:00 -06:00
Kenneth Jenkins
0affd9268b
autocert: use new OCSP error type (#4437) 2023-08-04 14:41:25 -07:00
dependabot[bot]
7851830c69
chore(deps): bump github.com/caddyserver/certmagic from 0.18.2 to 0.19.1 (#4401)
* chore(deps): bump github.com/caddyserver/certmagic from 0.18.2 to 0.19.1

Bumps [github.com/caddyserver/certmagic](https://github.com/caddyserver/certmagic) from 0.18.2 to 0.19.1.
- [Release notes](https://github.com/caddyserver/certmagic/releases)
- [Commits](https://github.com/caddyserver/certmagic/compare/v0.18.2...v0.19.1)

---
updated-dependencies:
- dependency-name: github.com/caddyserver/certmagic
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* autocert: update cache method invocation

The method CacheUnmanagedTLSCertificate() now returns a certificate hash
in addition to an error value.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
2023-08-01 15:21:56 -07:00
Caleb Doxsey
6c1416fc0f
authorize: log id token claims separately from id token (#4394) 2023-07-26 11:45:10 -06:00
Caleb Doxsey
1aa8187a4b
authorize: add support for logging id token (#4392) 2023-07-25 15:44:25 -06:00
Caleb Doxsey
baf8918676
logs: add support for logging the http query (#4390)
* config: add customization options for logging

* config: validate log fields

* proxy: add support for logging http request headers

* log subset of headers

* add support for logging the http query

* fix test name

* use strings.Cut, add unit tests
2023-07-25 12:56:49 -06:00
Caleb Doxsey
638d9f3d6c
proxy: add support for logging http request headers (#4388)
* config: add customization options for logging

* config: validate log fields

* proxy: add support for logging http request headers

* log subset of headers

* fix test name

* dont use log.HTTPHeaders for access logs

* canonicalize http/2 headers
2023-07-25 09:46:42 -06:00
Caleb Doxsey
438aecd7bc
config: add customization options for logging (#4383)
* config: add customization options for logging

* config: validate log fields

* allocate slices once
2023-07-24 13:17:03 -06:00
Kenneth Jenkins
8d09567fd7
authorize: incorporate mTLS validation from Envoy (#4374)
Configure Envoy to validate client certificates, using the union of all
relevant client CA bundles (that is, a bundle of the main client CA
setting together with all per-route client CAs). Pass the validation
status from Envoy through to the authorize service, by configuring Envoy
to use the newly-added SetClientCertificateMetadata filter, and by also
adding the relevant metadata namespace to the ExtAuthz configuration.

Remove the existing 'include_peer_certificate' setting from the ExtAuthz
configuration, as the metadata from the Lua filter will include the full
certificate chain (when it validates successfully by Envoy).

Update policy evaluation to consider the validation status from Envoy,
in addition to its own certificate chain validation. (Policy evaluation
cannot rely solely on the Envoy validation status while we still support
the per-route client CA setting.)
2023-07-21 12:17:01 -07:00
Caleb Doxsey
df8ff26332
autocert: suppress OCSP stapling errors (#4371)
* autocert: suppress OCSP stapling errors

* check level, add test
2023-07-19 13:56:36 -06:00
Caleb Doxsey
78e7a3e7d0
config: validate log levels (#4367)
* config: validate log levels

* fix SetLevel

* document unset, merge warn/warning
2023-07-17 16:41:48 -06:00
Kenneth Jenkins
a1388592d8
stub out HPKE public key fetch for self-hosted authenticate (#4360)
Fetch the HPKE public key only when configured to use the hosted
authenticate service. Determine whether we are using the hosted
authenticate service by comparing the resolved authenticate domain with
a hard-coded list of hosted authenticate domains.

Extract this list of hosted authenticate domains to the internal/urlutil
package in order to keep a single source of truth for this data.
2023-07-13 10:04:34 -07:00
Kenneth Jenkins
2bf83e20d8
Allow clearing default Azure and Google auth code options (#4315)
Allow users to clear the default IdP auth code options, by explicitly
setting an empty idp_request_params map.

To do this in a YAML config file, set:

    idp_request_params: {}
2023-06-27 09:11:54 -07:00
Caleb Doxsey
baf964f44a
config: update logic for checking overlapping certificates (#4216)
* config: update logic for checking overlapping certificates

* add test

* go mod tidy
2023-06-01 09:30:46 -06:00
Caleb Doxsey
10662d7034
databroker: fix fast forward (#4192)
* databroker: sort configs

* databroker: fix fast-forward

* newest not oldest
2023-05-23 15:30:27 -06:00
Caleb Doxsey
fe8e788076
databroker: sort configs (#4190) 2023-05-23 10:08:29 -06:00
Denis Mishin
2db2d66eba
authenticate: add aws cognito (#4137) 2023-05-16 12:28:12 -04:00