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
The Gatewy API currently has an `implementable` HTTP Auth mechanism exposed using the `ExternalAuth` field in the `HTTPRoute` resource. This uses Envoy's `ext_authz` protocol to reach out to an External Service to both `Authenticate` and `Authorize` requests.
9
-
10
-
See https://gateway-api.sigs.k8s.io/geps/gep-1494/ for more details
11
-
12
-
This GEP also describes a [two phased approach](https://gateway-api.sigs.k8s.io/geps/gep-1494/#why-two-phases), which includes starting first with a Filter at the `rule` level, and then providing a top level Policy attachment that can be overridden by lower level Auth Filters.
13
-
14
-
From initial discussion, we decided to go forward with exposing our own authentication filter.
15
-
16
-
This was decided for the following reasons:
17
-
- Given the timeline of `ExternalAuth` eventually being supported and implented by all other Gateway API implementations, it may be many months before this enchancement is available on the main channel within the Gateway API
18
-
- Exposing our own form of authentication through an authenticaiton filter does not exclude the possibility of eventually supporting the `ExternalAuth` field
19
-
- Given the expressed complexity of the [two phased approach](https://gateway-api.sigs.k8s.io/geps/gep-1494/#why-two-phases), `ExternalAuth` has the potential to go through may iterations before becoming stable
20
-
- Recent conversations with the Gateway API maintainers suggest that implementation of `ExternalAuth` is still speculative
21
-
22
6
## Summary
23
7
24
8
Design and implement a means for users of NGINX Gateway Fabric to enable authenticaiton on requests to their backend applications.
@@ -32,6 +16,10 @@ This new filter should eventually expose all forms of authentication avaialbe th
32
16
- Authentication failures return appropriate status by default (e.g., 401/403)
33
17
- Ensure response codes are configurable
34
18
19
+
## Non-Goals
20
+
21
+
- Design for all forms of authentication
22
+
- An Auth filter for GRPC, TCP and UDP routes
35
23
36
24
## Introduction
37
25
@@ -53,7 +41,7 @@ This document also focus on Basic Authentication. Other authentication methods s
53
41
|**JWT (JSON Web Token)**| ❌ | ✅ |[ngx_http_auth_jwt_module](https://docs.nginx.com/nginx/admin-guide/security-controls/authentication/#jwt-authentication)| Tokens are used for stateless authentication between client and server. |
54
42
|**OpenID Connect**| ❌ | ✅ |[ngx_http_oidc_module](https://nginx.org/en/docs/http/ngx_http_oidc_module.html)| Allows authentication through third-party providers like Google. |
55
43
56
-
## Design and Proposal
44
+
## API, Customer Driven Interfaces, and User Experience
57
45
58
46
When designing a means of configuring authentication for NGF, we can consider these approaches:
59
47
1. An `AuthenticationFilter` CRD which is responsible for providing a specification for each form of authentication within a single resource.
- Functional tests to validate behavioural scenarios when referncing filters in different combinations. The details of these tests are out of scope for this document.
200
+
201
+
## Security Considerations
202
+
203
+
### Validation
204
+
205
+
If we chose to go forward with creation of our own `AuthenticationFilter`, it is important that we ensure all configurable fields are validated, and that the resulting NGINX configuration is correct and secure
206
+
207
+
All fields in the `AuthenticationFilter` will be validated with Open API Schema.
208
+
We should also include [CEL](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) validation where required.
209
+
210
+
211
+
## Alternatives
212
+
213
+
The Gatewy API currently has an `implementable` HTTP Auth mechanism exposed using the `ExternalAuth` filter in the `HTTPRoute` resource using the [HTTPExternalAuthFilter](https://gateway-api.sigs.k8s.io/reference/spec/?h=externalauth#httpexternalauthfilter). This uses Envoy's `ext_authz` protocol to reach out to an External Service to both `Authenticate` and `Authorize` requests.
214
+
215
+
See https://gateway-api.sigs.k8s.io/geps/gep-1494/ for more details
216
+
217
+
This GEP also describes a [two phased approach](https://gateway-api.sigs.k8s.io/geps/gep-1494/#why-two-phases), which includes starting first with a Filter at the `rule` level, and then providing a top level Policy attachment that can be overridden by lower level Auth Filters.
218
+
219
+
From initial discussion, we decided to go forward with exposing our own authentication filter.
220
+
221
+
This was decided for the following reasons:
222
+
- Given the timeline of `ExternalAuth` eventually being supported and implented by all other Gateway API implementations, it may be many months before this enchancement is available on the main channel within the Gateway API
223
+
- Exposing our own form of authentication through an authenticaiton filter does not exclude the possibility of eventually supporting the `ExternalAuth` field
224
+
- Given the expressed complexity of the [two phased approach](https://gateway-api.sigs.k8s.io/geps/gep-1494/#why-two-phases), `ExternalAuth` has the potential to go through may iterations before becoming stable
225
+
- Recent conversations with the Gateway API maintainers suggest that implementation of `ExternalAuth` is still speculative
226
+
227
+
Example HTTPRoute using [HTTPExternalAuthFilter](https://gateway-api.sigs.k8s.io/reference/spec/?h=externalauth#httpexternalauthfilter)
228
+
229
+
```yaml
230
+
apiVersion: gateway.networking.k8s.io/v1
231
+
kind: HTTPRoute
232
+
metadata:
233
+
name: api-with-external-auth
234
+
namespace: default
235
+
spec:
236
+
parentRefs:
237
+
- name: gateway
238
+
hostnames:
239
+
- api.example.com
240
+
rules:
241
+
- matches:
242
+
- path:
243
+
type: PathPrefix
244
+
value: /api
245
+
filters:
246
+
- type: ExternalAuth
247
+
externalAuth:
248
+
protocol: HTTP
249
+
backendRef:
250
+
# BackendObjectReference: defaults to core group and kind=Service if omitted
251
+
name: ext-authz-svc
252
+
port: 8080
253
+
http:
254
+
# Prepend a prefix when forwarding the client path to the auth server
255
+
path: /authorize
256
+
# Additional request headers to send to the auth server (core headers are always sent)
257
+
allowedHeaders:
258
+
- X-Request-Id
259
+
- X-User-Agent
260
+
- X-Correlation-Id
261
+
# Headers from the auth server response to copy into the backend request
262
+
allowedResponseHeaders:
263
+
- X-Authz-Trace
264
+
- WWW-Authenticate
265
+
- Set-Cookie
266
+
forwardBody:
267
+
# Buffer and forward up to 16 KiB of the client request body to the auth server
268
+
maxSize: 16384
269
+
backendRefs:
270
+
- name: backend-svc
271
+
port: 80
272
+
```
273
+
274
+
## Additional considerations
275
+
276
+
### Path Type Behaviour
211
277
212
278
The `auth_basic` directive can be applied at the `http`, `server` and `location` contexts in NGINX.
213
279
As the intention is to provide this capabilitiy as a filter, which is attached at the `rules[].filters` level, this implementation aims to keep this behaviour at the `location` level.
@@ -218,6 +284,9 @@ If a match uses `PathPrefix`, the filter applies to the entire prefix subtree (t
218
284
Given this behaviour, we may need to consider to construct the final `http.conf` file given combinations of `Exact` and `PathPrefix` path types.
219
285
220
286
Example HTTPRoute
287
+
<details>
288
+
<summary> >> (click to expand) << </summary>
289
+
221
290
```yaml
222
291
apiVersion: gateway.networking.k8s.io/v1
223
292
kind: HTTPRoute
@@ -278,9 +347,9 @@ spec:
278
347
- name: reports-svc
279
348
port: 8080
280
349
```
350
+
</details>
281
351
282
-
283
-
## Potential HTTPRoute behaviour
352
+
### Potential HTTPRoute behaviour
284
353
285
354
An authentication based filter may be referenced by multiple HTTPRoutes, and multiple rules within those routes.
0 commit comments