You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/admin/authorization.md
+107
Original file line number
Diff line number
Diff line change
@@ -49,10 +49,12 @@ The following implementations are available, and are selected by flag:
49
49
-`--authorization-mode=AlwaysDeny`
50
50
-`--authorization-mode=AlwaysAllow`
51
51
-`--authorization-mode=ABAC`
52
+
-`--authorization-mode=Webhook`
52
53
53
54
`AlwaysDeny` blocks all requests (used in tests).
54
55
`AlwaysAllow` allows all requests; use if you don't need authorization.
55
56
`ABAC` allows for user-configured authorization policy. ABAC stands for Attribute-Based Access Control.
57
+
`Webhook` allows for authorization to be driven by a remote service using REST.
56
58
57
59
## ABAC Mode
58
60
@@ -167,6 +169,111 @@ For example, if you wanted to grant the default service account in the kube-syst
167
169
168
170
The apiserver will need to be restarted to pickup the new policy lines.
169
171
172
+
## Webhook Mode
173
+
174
+
When specified, mode `Webhook` causes Kubernetes to query an outside REST service when determining user privileges.
175
+
176
+
### Configuration File Format
177
+
178
+
Mode `Webhook` requires a file for HTTP configuration, specify by the `--authorization-webhook-config-file=SOME_FILENAME` flag.
179
+
180
+
The configuration file uses the [kubeconfig](../user-guide/kubeconfig-file.md) file format. Within the file "users" refers to the API Server webhook and "clusters" refers to the remote service.
181
+
182
+
A configuration example which uses HTTPS client auth:
183
+
184
+
```yaml
185
+
# clusters refers to the remote service.
186
+
clusters:
187
+
- name: name-of-remote-authz-service
188
+
cluster:
189
+
certificate-authority: /path/to/ca.pem # CA for verifying the remote service.
190
+
server: https://authz.example.com/authorize # URL of remote service to query. Must use 'https'.
191
+
192
+
# users refers to the API Server's webhook configuration.
193
+
users:
194
+
- name: name-of-api-server
195
+
user:
196
+
client-certificate: /path/to/cert.pem # cert for the webhook plugin to use
197
+
client-key: /path/to/key.pem # key matching the cert
198
+
```
199
+
200
+
### Request Payloads
201
+
202
+
When faced with an authorization decision, the API Server POSTs a JSON serialized api.authorization.v1beta1.SubjectAccessReview object describing the action. This object contains fields describing the user attempting to make the request, and either details about the resource being accessed or requests attributes.
203
+
204
+
Note that webhook API objects are subject to the same [versioning compatibility rules](../api.md) as other Kubernetes API objects. Implementers should be aware of loser compatibility promises for beta objects and check the "apiVersion" field of the request to ensure correct deserialization. Additionally, the API Server must enable the `authorization.k8s.io/v1beta1` API extensions group (`--runtime-config=authorization.k8s.io/v1beta1=true`).
205
+
206
+
An example request body:
207
+
208
+
```json
209
+
{
210
+
"apiVersion": "authorization.k8s.io/v1beta1",
211
+
"kind": "SubjectAccessReview",
212
+
"spec": {
213
+
"resourceAttributes": {
214
+
"namespace": "kittensandponies",
215
+
"verb": "GET",
216
+
"group": "*",
217
+
"resource": "pods"
218
+
},
219
+
"user": "jane",
220
+
"group": [
221
+
"group1",
222
+
"group2"
223
+
]
224
+
}
225
+
}
226
+
```
227
+
228
+
The remote service is expected to fill the SubjectAccessReviewStatus field of the request and respond to either allow or disallow access. The response body's "spec" field is ignored and may be omitted. A permissive response would return:
229
+
230
+
```json
231
+
{
232
+
"apiVersion": "authorization.k8s.io/v1beta1",
233
+
"kind": "SubjectAccessReview",
234
+
"status": {
235
+
"allowed": true
236
+
}
237
+
}
238
+
```
239
+
240
+
To disallow access, the remote service would return:
241
+
242
+
```json
243
+
{
244
+
"apiVersion": "authorization.k8s.io/v1beta1",
245
+
"kind": "SubjectAccessReview",
246
+
"status": {
247
+
"allowed": false,
248
+
"reason": "user does not have read access to the namespace"
249
+
}
250
+
}
251
+
```
252
+
253
+
Access to non-resource paths are sent as:
254
+
255
+
```json
256
+
{
257
+
"apiVersion": "authorization.k8s.io/v1beta1",
258
+
"kind": "SubjectAccessReview",
259
+
"spec": {
260
+
"nonResourceAttributes": {
261
+
"path": "/debug",
262
+
"verb": "GET"
263
+
},
264
+
"user": "jane",
265
+
"group": [
266
+
"group1",
267
+
"group2"
268
+
]
269
+
}
270
+
}
271
+
```
272
+
273
+
Non-resource paths include: `/api`, `/apis`, `/metrics`, `/resetMetrics`, `/logs`, `/debug`, `/healthz`, `/swagger-ui/`, `/swaggerapi/`, `/ui`, and `/version.` Clients require access to `/api`, `/api/*/`, `/apis/`, `/apis/*`, `/apis/*/*`, and `/version` to discover what resources and versions are present on the server. Access to other non-resource paths can be disallowed without restricting access to the REST api.
274
+
275
+
For further documentation refer to the authorization.v1beta1 API objects and plugin/pkg/auth/authorizer/webhook/webhook.go.
276
+
170
277
## Plugin Development
171
278
172
279
Other implementations can be developed fairly easily.
Copy file name to clipboardExpand all lines: docs/admin/kube-apiserver.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -56,8 +56,9 @@ kube-apiserver
56
56
--advertise-address=<nil>: The IP address on which to advertise the apiserver to members of the cluster. This address must be reachable by the rest of the cluster. If blank, the --bind-address will be used. If --bind-address is unspecified, the host's default interface will be used.
57
57
--allow-privileged[=false]: If true, allow privileged containers.
58
58
--apiserver-count=1: The number of apiservers running in the cluster
59
-
--authorization-mode="AlwaysAllow": Ordered list of plug-ins to do authorization on secure port. Comma-delimited list of: AlwaysAllow,AlwaysDeny,ABAC
59
+
--authorization-mode="AlwaysAllow": Ordered list of plug-ins to do authorization on secure port. Comma-delimited list of: AlwaysAllow,AlwaysDeny,ABAC,Webhook
60
60
--authorization-policy-file="": File with authorization policy in csv format, used with --authorization-mode=ABAC, on the secure port.
61
+
--authorization-webhook-config-file="": File with webhook configuration in kubeconfig format, used with --authorization-mode=Webhook. The API server will query the remote service to determine access on the API server's secure port.
61
62
--basic-auth-file="": If set, the file that will be used to admit requests to the secure port of the API server via http basic authentication.
62
63
--bind-address=0.0.0.0: The IP address on which to listen for the --secure-port port. The associated interface(s) must be reachable by the rest of the cluster, and by CLI/web clients. If blank, all interfaces will be used (0.0.0.0).
63
64
--cert-dir="/var/run/kubernetes": The directory where the TLS certs are located (by default /var/run/kubernetes). If --tls-cert-file and --tls-private-key-file are provided, this flag will be ignored.
0 commit comments