Commit Graph

108 Commits

Author SHA1 Message Date
Monis Khan 6cfe489651 Clear front proxy headers after authentication is complete
This matches the logic we have for the Authorization header as well
as the impersonation headers.

Signed-off-by: Monis Khan <mok@microsoft.com>

Kubernetes-commit: 7b711c5cf4d6721e9742baf5ebfafee42f645789
2023-03-20 13:11:38 -04:00
Dr. Stefan Schimanski 05f43943fa authn: fix cache mutation by AuthenticatedGroupAdder
The cached token authenticator returns a cache value. The group adder changes it.

Kubernetes-commit: 1a74f7ad47f765daae1ec38762b710358c6f521b
2022-05-11 16:17:29 +02:00
Ravi Gudimetla 1ee261d219 API Server Changes
This commit includes all the changes needed for APIServer. Instead of modifying the existing signatures for the methods which either generate or return stopChannel, we generate a context from the channel and use the generated context to be passed to the controllers which are started in APIServer. This ensures we don't have to touch APIServer dependencies.

Kubernetes-commit: 8b84a793b39fed2a62af0876b2eda461a68008c9
2022-03-07 09:20:45 -05:00
Davanum Srinivas 56a3a30ae1 Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9405e9b55ebcd461f161859a698b949ea3bde31d
2021-12-09 21:31:26 -05:00
Abu Kashem d53acfe201 apiserver: store (event, evaluated policy) pair in request context
Kubernetes-commit: 8be823b0b0270e1b979b3d4c6e683e1daa0f2e01
2021-09-20 17:43:16 -04:00
wojtekt b898581360 Migrate to k8s.io/utils/clock in apiserver
Kubernetes-commit: 859a98c0358610e2c127cd2fba1be601ca975188
2021-09-14 20:36:07 +02:00
Lukasz Szaszkiewicz 69433684ce adds metrics for authentication webhook
Kubernetes-commit: 322c18c147da08dd2eea25ba3c2b9630a228cf5f
2021-02-23 08:39:25 +01:00
卢振兴10069964 549cbbf8de fix broken link in some files
Kubernetes-commit: b29a5fb0746f772b38da570cd8fdc77396ffca31
2021-04-13 08:43:24 +08:00
Gautier Delorme af9424d2c9 remove go-openapi/spec
Signed-off-by: Gautier Delorme <gautier.delorme@gmail.com>

Kubernetes-commit: 34b0fcef5fc47e3fcddf7f6ca1b3e6176b2a5323
2021-04-20 17:48:33 +02:00
Mike Danese a6a121887a force implementors of dyanmiccertificates providers to think about notify
Right now, `_, ok := provider.(Notifier); !ok` can mean one of two
things:

1. The provider does not support notification because the provided
   content is static.
2. The implementor of the provider hasn't gotten around to implementing
   Notifier yet.

These have very different implications. We should not force consumers of
these interfaces to have to figure out the static of Notifier across
sometimes numerous different implementations. Instead, we should force
implementors to implement Notifier, even if it's a noop.

Change-Id: Ie7a26697a9a17790bfaa58d67045663bcc71e3cb

Kubernetes-commit: 9b7d654a08d694d20226609f7075b112fb18639b
2021-04-09 16:59:17 -07:00
Shihang Zhang 87ac3f57d4 allow multiple of --service-account-issuer
Kubernetes-commit: 925900317e43e58435082f624f5969e3cfe25c67
2021-04-15 09:50:43 -07:00
Lukasz Szaszkiewicz 49d90ce0ad DelegatingAuthenticationOptions TokenReview request timeout
it turns out that setting a timeout on HTTP client affect watch requests made by the delegated authentication component.
with a 10 second timeout watch requests are being re-established exactly after 10 seconds even though the default request timeout for them is ~5 minutes.

this is because if multiple timeouts were set, the stdlib picks the smaller timeout to be applied, leaving other useless.
for more details see a937729c2c/src/net/http/client.go (L364)

instead of setting a timeout on the HTTP client we should use context for cancellation.

Kubernetes-commit: d690d71d27c78f2f7981b286f5b584455ff30246
2021-04-09 13:20:51 +02:00
Jiaxin Shan dfad5032fb Fix ALPHA stability level reference link
Kubernetes-commit: e01a21469b9719f7d0e84021c032cd8f0016b5d2
2021-01-31 15:37:07 -08:00
yoyinzyc 387f5c3a09 add context to metrics in apiserver/authentication
Kubernetes-commit: 5311d711ecef241ab99266273180be81b373e43a
2020-12-10 12:11:21 -08:00
ialidzhikov 1b82145bb1 Fix staticcheck in staging/src/k8s.io/apiserver/pkg/authentication/request/x509
Signed-off-by: ialidzhikov <i.alidjikov@gmail.com>

Kubernetes-commit: 5771ea733ffbcff823517a4c51ebcadf11122578
2021-01-10 00:32:42 +02:00
Abu Kashem 6ef142596d thorw error if webhook retry backoof is not specified
Kubernetes-commit: c09828e47d0042a547a7eb3ca9f2686038645f04
2020-10-30 10:27:09 -04:00
Abu Kashem 5254108841 make backoff parameters configurable for webhook
Currently webhook retry backoff parameters are hard coded, we want
to have the ability to configure the backoff parameters for webhook
retry logic.

Kubernetes-commit: 53a1307f68ccf6c9ffd252eeea2b333e818c1103
2020-10-30 11:25:32 -04:00
Tomas Nozicka 83e381874d Add context to x509 verify failures
Kubernetes-commit: bf52770e413dc6095203cd5ec1716dc3764eee8e
2020-08-17 14:35:48 +02:00
cici37 4ab24fc5f7 Move client_builder to k8s.io/controller-manager
Kubernetes-commit: 95acec5a3b4c07afba17b526e5cb031f8bb88630
2020-05-26 17:01:36 -07:00
azush26 df032850ea Add an unit test for requests including value after token
Kubernetes-commit: 367214dffdc070706011c6814cb2307749b0503f
2020-09-19 01:04:35 +09:00
azush26 c0d57defce Limit the max number of splitting
Kubernetes-commit: bf516ab99c3c2ce2b4ad6d0acaf122a4d216cc2d
2020-09-15 23:04:57 +09:00
Han Kang 49538db8eb add bootstrap policy for monitoring roles
(we enable metrics and pprof by default, but that doesn't mean
 we should have full cluster-admin access to use those endpoints)

Change-Id: I20cf1a0c817ffe3b7fb8e5d3967f804dc063ab03

remove pprof but add read access to detailed health checks

Change-Id: I96c0997be2a538aa8c689dea25026bba638d6e7d

add base health check endpoints and remove the todo for flowcontrol, as there is an existing ticket

Change-Id: I8a7d6debeaf91e06d8ace3cb2bd04d71ef3e68a9

drop blank line

Change-Id: I691e72e9dee3cf7276c725a12207d64db88f4651

Kubernetes-commit: f57611970c0790b325719e0279bfae334537e2de
2020-07-17 15:10:26 -07:00
Monis Khan 09aff09e1a Force token cache to support audit annotations
Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: 6039451d358c20b8161e08eb1d3626134195026f
2020-04-14 12:46:37 -04:00
Davanum Srinivas 5879417a28 switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Lukasz Szaszkiewicz 513afab811 expose RunOnce method on RequestHeaderAuthRequest controller
Kubernetes-commit: f3a7f057c423caf77b0c5315d7728727c4b35bde
2020-04-28 15:35:17 +02:00
Lukasz Szaszkiewicz 07cdc792bb provides DynamicRequestHeaderController that combines DynamicCAFromConfigMapController and RequestHeaderAuthRequestController into one controller
the unified controller will dynamically fill RequestHeaderConfig struct

Kubernetes-commit: cb4b4cb5a6ffdf1c7f199e644a8b5cac2367d504
2020-04-28 12:48:21 +02:00
Lukasz Szaszkiewicz 259bedd4a2 provides RequestHeaderAuthRequestController for dynamically filling RequestHeaderConfig struct
Kubernetes-commit: 6e0211b3d82c5b3b2f69f6b3c7a7840b42e6e000
2020-04-27 17:41:42 +02:00
Monis Khan 7fa523535d Remove support for basic authentication
This change removes support for basic authn in v1.19 via the
--basic-auth-file flag.  This functionality was deprecated in v1.16
in response to ATR-K8S-002: Non-constant time password comparison.

Similar functionality is available via the --token-auth-file flag
for development purposes.

Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: df292749c9d063b06861d0f4f1741c37b815a2fa
2020-03-11 14:31:31 -04:00
Mike Danese 5b8058738a token cache: make fetch_total a counter
Downstreams assume process restarts when counters decrement. Currently,
the "active" label is expected to decrement but the "ok" and "error"
labels are intended to be handled as counters. This is unneccesary and
hard to deal with. This changes consolidate "blocking" and "in_flight"
tracking into a single guage, which allows fetch completion to be a pure
counter.

Kubernetes-commit: dc5934f58456d95b0264665871c0c48e16ee6469
2020-01-07 08:48:25 -08:00
Mike Danese 882be546f2 rename _count to _total in a few metrics
request_total is fully accumulating, fetch_total is mostly accumulating
except for the active label.

Kubernetes-commit: a84e883e4b39f6a040d479b5be89b0750f4e7bf1
2019-12-18 21:58:13 -08:00
Alvaro Aleman 3d613a7c48 Remove stale comment re making apiserver common names dynamic
Kubernetes-commit: 1d3b6ece63604afb3b6e672f188eb34abc3fed4d
2019-11-29 15:14:29 +01:00
Mike Danese b522e43b1d auth: add metrics to token cache
Kubernetes-commit: 3f3bc37e05879ec97a64b4833a315a3c7b1186a4
2019-12-13 14:03:05 -08:00
Mike Danese 24aa429484 shared authenticator lookups
Kubernetes-commit: 8647e75cec684fce64280b6079ef174643548c53
2019-11-11 22:15:40 -08:00
Mike Danese 8d1e73feab inline GC in expiring cache
This allows us to drop the background goroutine with negligable
difference in performance.

Kubernetes-commit: d16dde36a3edf5cdb89c5d5b56d4e3c9af849c1c
2019-11-15 17:04:28 -08:00
Mike Danese 0326ed9810 migrate token cache to cache.Expiring
Kubernetes-commit: 3f194d5b413daeba93063f4610b9951069eaf13c
2019-11-06 16:23:21 -08:00
Mike Danese d8f26fe9f3 report cache mises in cached token authenticator benchmark
Kubernetes-commit: c5bfea65b9b45c01a09dfefeedffd13b8927140a
2019-11-12 12:40:19 -08:00
Jordan Liggitt 086ad4b0b9 Switch kubelet/aggregated API servers to use v1 tokenreviews
Kubernetes-commit: 5ef4fe959a45e423d2b992e9c21e6e9db4b950c5
2019-11-04 22:41:32 -05:00
Mike Danese 61dd52533e adjust token cache benchmarks to get more accurate behavior
b.N is adjusted by pkg/testing using an internal heuristic:

> The benchmark function must run the target code b.N times. During
> benchmark execution, b.N is adjusted until the benchmark function
> lasts long enough to be timed reliably.

Using b.N to seed other parameters makes the benchmark behavior
difficult to reason about. Before this change, thread count in the
CachedTokenAuthenticator benchmark is always 5000, and batch size is
almost always 1 when I run this locally. SimpleCache and StripedCache
benchmarks had similarly strange scaling.

After modifying CachedTokenAuthenticator to only adjust iterations based
on b.N, the batch chan was an point of contention and I wasn't able to
see any significant CPU consumption. This was fixed by using
ParallelBench to do the batching, rather than using a chan.

Kubernetes-commit: 43d34882c9b3612d933b97b6e470fd8d36fe492b
2019-10-26 14:12:41 -07:00
David Eads 80b16c1ce7 allow a verifyoptionsfunc to indicate that no certpool is available
Kubernetes-commit: c672affad176c22da66c7ac17cc8805f08533ce9
2019-11-06 10:38:45 -05:00
Mike Danese 44b9fc84ab migrate callers to g/g/uuid
Kubernetes-commit: a4ca9e6c93e45b4a97e7d04df37362299088f64a
2019-11-04 23:15:20 -08:00
Daniel Smith 168addcfe5 Add an authn cache benchmark
Kubernetes-commit: 420a44da0138cb64fa5d4e9fab79d8be3527ffd8
2019-10-08 13:34:51 -07:00
David Eads 84d21cfff4 wire up a means to dynamically reload ca bundles for kube-apiserver
Kubernetes-commit: 6beb96261e29754f2b7d0e44829eb6d15422cebf
2019-10-07 14:06:42 -04:00
Monis Khan c2289feb1e Hash keys used in cached token authenticator
It is possible to configure the token cache to cache failures.  We
allow 1 MB of headers per request, meaning a malicious actor could
cause the cache to use a large amount of memory by filling it with
large invalid tokens.  This change hashes the token before using it
as a key.  Measures have been taken to prevent precomputation
attacks.  SHA 256 is used as the hash to prevent collisions.

Signed-off-by: Monis Khan <mkhan@redhat.com>

Kubernetes-commit: 9a547bca8e6e15273bfafd3496aa6524fd7d35bd
2019-10-11 15:21:34 -04:00
David Eads 703545a3db add the ability for dynamic header names in delegated authentication
Kubernetes-commit: 58256346693717fd12f121f0cf74fe1e003edb0f
2019-10-03 12:56:42 -04:00
Daniel Smith 344ca1b3a8 increase auth cache size
Kubernetes-commit: 236112c6af9b22b02e35914fe8fbbdbfe856f975
2019-10-08 14:27:28 -07:00
David Eads eee025a27a add ability to authenticators for dynamic update of certs
Kubernetes-commit: 51195dd86012c4c4b17a1707ef50a46fa046f74f
2019-09-05 09:59:59 -04:00
Ted Yu 7e547519cf Add note on the role of BenchmarkSimpleCache
Kubernetes-commit: dd48a022c063e9f507ff62e1796a273d38036cb4
2019-09-11 14:39:57 -07:00
Han Kang 3e6e1db500 add some documentation around the metrics stability migration changes for clarity
Kubernetes-commit: 4e5d906c4d008f914b0ede26ea91533d6343dec5
2019-08-26 19:15:30 -07:00
Han Kang b9084e350a migrate kube-apiserver metrics to stability framework
Kubernetes-commit: 466980dd747e06e55451301c624eecccfa505123
2019-08-22 15:38:42 -07:00
Clayton Coleman 49ac3bd853 Avoid allocating when performing VisitRulesFor on service accounts
Service account authorization checks are done frequently and were
observed to perform 7% of allocations on a system running e2e tests.
The allocation comes from when we walk the authorization rules to
find matching service accounts.

Optimize the check for service account names to avoid allocating.

Kubernetes-commit: 4c87a14e6b1809359fcb6566d883a169ff0db259
2019-03-11 11:50:44 -04:00