Skip to content

Commit 65c1adc

Browse files
committed
Update secret ref to use LocalObjectReferenceWithKey struct
1 parent 21b5611 commit 65c1adc

File tree

1 file changed

+49
-53
lines changed

1 file changed

+49
-53
lines changed

docs/proposals/authentication-filter.md

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,8 @@ const (
136136

137137
// BasicAuth configures HTTP Basic Authentication.
138138
type BasicAuth struct {
139-
// SecretRef allows referencing a Secret in the same or different namespace.
140-
// When namespace is set and differs from the filter's namespace, a ReferenceGrant in the target namespace is required.
141-
//
142-
// +optional
143-
SecretRef *SecretObjectReference `json:"secretRef,omitempty"`
139+
// SecretRef allows referencing a Secret in the same namespace
140+
SecretRef LocalObjectReferenceWithKey `json:"secretRef,omitempty"`
144141

145142
// Realm used by NGINX `auth_basic` directive.
146143
// https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic
@@ -230,7 +227,7 @@ type JWTAuth struct {
230227
// FileKeySource specifies local JWKS key configuration.
231228
type FileKeySource struct {
232229
// SecretRef references a Secret containing the JWKS.
233-
SecretRef SecretObjectReference `json:"secretRef,omitempty"`
230+
SecretRef LocalObjectReferenceWithKey `json:"secretRef,omitempty"`
234231

235232
// KeyCache is the cache duration for keys.
236233
// Configures `auth_jwt_key_cache` directive.
@@ -241,6 +238,13 @@ type FileKeySource struct {
241238
KeyCache *v1alpha1.Duration `json:"keyCache,omitempty"`
242239
}
243240

241+
// LocalObjectReferenceWithKey sepcifies as local kubernetes object
242+
// with required `key` field to extract data.
243+
type LocalObjectReferenceWithKey struct {
244+
v1.LocalObjectReference
245+
Key string
246+
}
247+
244248
// RemoteKeySource specifies remote JWKS configuration.
245249
type RemoteKeySource struct {
246250
// URL is the JWKS endpoint, e.g. "https://issuer.example.com/.well-known/jwks.json".
@@ -395,6 +399,7 @@ spec:
395399
basic:
396400
secretRef:
397401
name: basic-auth-users # Secret containing htpasswd data
402+
key: htpasswd
398403
realm: "Restricted" # Optional. Helps with logging
399404
onFailure: # Optional. These setting may be defaults.
400405
statusCode: 401
@@ -512,6 +517,7 @@ spec:
512517
file:
513518
secretRef:
514519
name: jwt-keys-secure
520+
key: jwks.json
515521
keyCache: 10m # Optional cache time for keys (auth_jwt_key_cache)
516522
# Acceptable clock skew for exp/nbf
517523
leeway: 60s # Configures auth_jwt_leeway
@@ -859,52 +865,6 @@ Users that attach an `AuthenticationFilter` to an HTTPRoute/GRPCRoute should be
859865

860866
Any example configurations and deployments for the `AuthenticationFilter` should enable HTTPS at the Gateway level by default.
861867

862-
### Namespace isolataion and cross-namespace references
863-
Both Auth and Local JWKS should only have access to Secrets and ConfigMaps in the same namespace by default.
864-
865-
Cross-namespace references are allowed only when authorized via a Gateway API ReferenceGrant in the target namespace.
866-
867-
Controller behavior:
868-
- Same-namespace references are permitted without a grant.
869-
- For cross-namespace references, the controller MUST verify a ReferenceGrant exists in the target namespace:
870-
- from: group=gateway.nginx.org, kind=AuthenticationFilter, namespace=<filter-namespace>
871-
- to: group="", kind=(Secret|ConfigMap), name=<target-name>
872-
- If no valid grant is found, the filter status should update the status to `Accepted=False` with `reason=RefNotPermitted` and a clear message. We should avoid rendering any NGINX configuration in this scenario.
873-
874-
Example: Grant BasicAuth in app-ns to read a Secret in security-ns
875-
```yaml
876-
apiVersion: gateway.networking.k8s.io/v1
877-
kind: ReferenceGrant
878-
metadata:
879-
name: allow-basic-auth-secret
880-
namespace: security-ns # target namespace where the Secret lives
881-
spec:
882-
from:
883-
- group: gateway.nginx.org
884-
kind: AuthenticationFilter
885-
namespace: app-ns
886-
to:
887-
- group: "" # core API group
888-
kind: Secret
889-
name: basic-auth-users
890-
```
891-
892-
AuthenticationFilter referencing the cross-namespace Secret
893-
```yaml
894-
apiVersion: gateway.nginx.org/v1alpha1
895-
kind: AuthenticationFilter
896-
metadata:
897-
name: basic-auth
898-
namespace: app-ns
899-
spec:
900-
type: Basic
901-
basic:
902-
secretRef:
903-
namespace: security-ns
904-
name: basic-auth-users
905-
realm: "Restricted"
906-
```
907-
908868
### Remote JWKS
909869

910870
Proxy cache TTL should be configurable and set to a reasonable default, reducing periods of stale cached JWKs.
@@ -981,7 +941,7 @@ document that behavior.
981941

982942
## Stretch Goals
983943

984-
### Cross namespace acess
944+
### Cross namespace access
985945

986946
When referencing secrets for Basic Auth and JWT Auth, the initial implementation will use `LocalObjectReference`.
987947

@@ -1001,6 +961,42 @@ type NamespacedSecretKeyReference struct {
1001961
}
1002962
```
1003963

964+
For initial implementaion, both Basic Auth and Local JWKS should will only have access to Secrets in the same namespace.
965+
966+
Example: Grant BasicAuth in app-ns to read a Secret in security-ns
967+
```yaml
968+
apiVersion: gateway.networking.k8s.io/v1
969+
kind: ReferenceGrant
970+
metadata:
971+
name: allow-basic-auth-secret
972+
namespace: security-ns # target namespace where the Secret lives
973+
spec:
974+
from:
975+
- group: gateway.nginx.org
976+
kind: AuthenticationFilter
977+
namespace: app-ns
978+
to:
979+
- group: "" # core API group
980+
kind: Secret
981+
name: basic-auth-users
982+
```
983+
984+
AuthenticationFilter referencing the cross-namespace Secret
985+
```yaml
986+
apiVersion: gateway.nginx.org/v1alpha1
987+
kind: AuthenticationFilter
988+
metadata:
989+
name: basic-auth
990+
namespace: app-ns
991+
spec:
992+
type: Basic
993+
basic:
994+
secretRef:
995+
namespace: security-ns
996+
name: basic-auth-users
997+
realm: "Restricted"
998+
```
999+
10041000
### Additional Fields for JWT
10051001
10061002
`require`, `tokenSource` and `propagation` are some additional fields that may be incldued in future updates to the API.

0 commit comments

Comments
 (0)