Skip to content

Commit 921267e

Browse files
ritazhpalnabarun
authored andcommitted
Address review comments
Signed-off-by: Rita Zhang <[email protected]>
1 parent 7f8a28c commit 921267e

File tree

1 file changed

+57
-15
lines changed
  • keps/sig-auth/3221-structured-authorization-configuration

1 file changed

+57
-15
lines changed

keps/sig-auth/3221-structured-authorization-configuration/README.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ be achieved through Authorization Webhooks. However since `kube-apiserver`
153153
only allows specifying a single webhook, this would result in cluster
154154
administrators being not able to specify their own. Support for multiple
155155
webhooks would make this possible. Moreover, RBAC rules can't be used here
156-
since RBAC allows to one add permissions but not deny them. We won't be able
156+
since RBAC allows one to add permissions but not deny them. We won't be able
157157
to add restrictions on 'non-system' users only for a set of resources using
158158
RBAC; 'non-system' users here refers to anyone who shouldn't be able to
159159
update/delete the protected set of CRDs.
@@ -202,12 +202,53 @@ Consider a system administrator who would like to apply a set of validations
202202
to certain requests before handing it off to webhooks defined using frameworks
203203
like Open Policy Agent.
204204

205-
They would have to nested webhooks within the one added to the auth chain to
205+
They would have to run nested webhooks within the one added to the auth chain to
206206
have the intended effect. This enhancement allows the administrator to configure
207207
this behaviour via a structured API and invoke the additional webhook only when
208208
relevant. This also allows administrators to define `failurePolicy` behaviours for
209209
separate webhooks, leading to more predictable outcomes.
210210

211+
The below example is only for demonstration purposes.
212+
```yaml
213+
apiVersion: apiserver.config.k8s.io/v1alpha1
214+
kind: AuthorizationConfiguration
215+
authorizers:
216+
- type: Webhook
217+
webhook:
218+
unauthorizedTTL: 30s
219+
timeout: 3s
220+
subjectAccessReviewVersion: v1
221+
failurePolicy: Deny
222+
connectionInfo:
223+
type: KubeConfig
224+
kubeConfigFile: /kube-system-authz-webhook.yaml
225+
matchConditions:
226+
# only send resource requests to the webhook
227+
- expression: has(request.resourceAttributes)
228+
# only intercept requests to kube-system
229+
- expression: request.resourceAttributes.namespace == 'kube-system'
230+
# don't intercept requests from kube-system service accounts
231+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
232+
- type: Node
233+
- type: RBAC
234+
- type: Webhook
235+
webhook:
236+
unauthorizedTTL: 30s
237+
timeout: 3s
238+
subjectAccessReviewVersion: v1
239+
failurePolicy: Deny
240+
connectionInfo:
241+
type: KubeConfig
242+
kubeConfigFile: /opa-kube-system-authz-webhook.yaml
243+
matchConditions:
244+
# only send resource requests to the webhook
245+
- expression: has(request.resourceAttributes)
246+
# only intercept requests to kube-system
247+
- expression: request.resourceAttributes.namespace == 'kube-system'
248+
# don't intercept requests from kube-system service accounts
249+
- expression: !('system:serviceaccounts:kube-system' in request.user.groups)
250+
```
251+
211252
#### Story 3: Denying requests on certain scenarios
212253

213254
The authorizer chain should be powerful enough to deny anyone making a request
@@ -249,7 +290,8 @@ will not be able to start. This can be mitigated by fixing the malformed values.
249290
We would like to introduce a structured file format which allows authorization
250291
to be configured using a flag (`--authorization-config-file`) which accepts a
251292
path to a file on the disk. Setting both `--authorization-config-file` and
252-
configuring an authorization webhook will not be allowed. If the user does that,
293+
configuring an authorization webhook using the `--authorization-webhook-*`
294+
command line flags will not be allowed. If the user does that,
253295
there will be an error and API Server would exit right away.
254296

255297
The configuration would be validated at startup and the API server will fail to
@@ -259,7 +301,8 @@ The API server will periodically reload the configuration. If it changes, the
259301
new configuration will be used for the Authorizer chain. If the new configuration
260302
is invalid, the last known valid configuration will be used. Logging and metrics
261303
would be used to signal success/failure of a config reload so that cluster admins
262-
can have observability over this process.
304+
can have observability over this process. Reload must not add or remove Node or RBAC
305+
authorizers. They can be reordered, but cannot be added or removed.
263306

264307
The proposed structure is illustrated below:
265308

@@ -321,7 +364,7 @@ authorizers:
321364
# Path to KubeConfigFile for connection info
322365
# Required, if connectionInfo.Type is KubeConfig
323366
kubeConfigFile: /kube-system-authz-webhook.yaml
324-
# matchConditions is a list of conditions that must be met for a request to be sent to this
367+
# matchConditions is a list of conditions that must be met for a request to be sent to this
325368
# webhook. An empty list of matchConditions matches all requests.
326369
# There are a maximum of 64 match conditions allowed.
327370
#
@@ -377,9 +420,8 @@ to the authz webhook for which the expression has been defined. The user would h
377420
to a `request` variable containing a `SubjectAccessReview` object in the version specified
378421
by `subjectAccessReviewVersion`.
379422

380-
The code path for enabling the above will only be triggered if the feature flag will
381-
be enabled until the time the feature flag is removed and configuring authorizer
382-
through a file becomes GA.
423+
The code path for enabling the above will only be triggered if the feature flag is enabled until
424+
the feature flag is removed and this feature graduates to GA.
383425

384426
### Monitoring
385427

@@ -458,14 +500,14 @@ We should benchmark the cost of some common CEL expressions inside
458500
##### Integration tests
459501

460502
Integration tests would be added to ensure the following:
461-
- Authorization of requests work in the existing flag based mode (feature flag
462-
turned off)
503+
- Authorization of requests work in the existing command line flag
504+
based mode (feature flag turned off)
463505
- Authorization of requests work with an apiserver bootstrapped with
464506
authorization configuration file (feature flag turned on)
465-
- without an webhook
466-
- with an webhook - successful request
467-
- with an webhook - error on request with `failurePolicy: Deny`
468-
- with an webhook - error on request with `failurePolicy: NoOpinion`
507+
- without a webhook
508+
- with a webhook - successful request
509+
- with a webhook - error on request with `failurePolicy: Deny`
510+
- with a webhook - error on request with `failurePolicy: NoOpinion`
469511

470512
There will be a mix and match of various authorization mechanisms to ensure all
471513
desired functionality works.
@@ -592,7 +634,7 @@ Or, they can look at the metrics exposed by `kube-apiserver`.
592634
###### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
593635

594636
The amount of errors denoted by `apiserver_authorization_step_webhook_error_total`
595-
is within reasonable limits. A rising value indicate issues with either the
637+
is within reasonable limits. A rising value indicates issues with either the
596638
authorizer chain or the webhook itself.
597639

598640
###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service?

0 commit comments

Comments
 (0)