Skip to content

Commit 529c2f6

Browse files
Merge pull request #407 from tboerger/feat/gateway-rule-name
feat: add optional name to httproute rules
2 parents 491fdd4 + 256bde1 commit 529c2f6

5 files changed

Lines changed: 52 additions & 10 deletions

File tree

helm/oauth2-proxy/Chart.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: oauth2-proxy
2-
version: 10.5.0
2+
version: 10.6.0
33
apiVersion: v2
44
appVersion: 7.15.2
55
home: https://oauth2-proxy.github.io/oauth2-proxy/
@@ -31,11 +31,7 @@ kubeVersion: ">=1.16.0-0"
3131
annotations:
3232
artifacthub.io/changes: |
3333
- kind: added
34-
description: >
35-
Add deploymentLabels to allow setting deployment specific labels.
36-
Add tpl support for ingress.labels, ingress.extraPaths and nodeSelector. This is a
37-
behavior change: any values containing `{{ ... }}` will now be evaluated as templates.
38-
To keep literal `{{` sequences, escape them (for example, use `{{"{{"}}`).
34+
description: Added name attribute for HTTPRoute rules
3935
links:
4036
- name: GitHub PR
41-
url: https://github.com/oauth2-proxy/manifests/pull/400
37+
url: https://github.com/oauth2-proxy/manifests/pull/407

helm/oauth2-proxy/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ gatewayApi:
361361
hostnames:
362362
- oauth.example.com
363363
rules:
364-
- matches:
364+
- name: oauth2
365+
matches:
365366
- path:
366367
type: PathPrefix
367368
value: /oauth2
@@ -380,6 +381,31 @@ gatewayApi:
380381
If you don't specify custom rules, the chart will create a default rule that matches all paths with `PathPrefix: /` and routes to the oauth2-proxy service.
381382
If you don't specify a sectionName, the rules will be applied to all listeners of the referenced Gateway.
382383

384+
### Targeting Rules with Policies via `sectionName`
385+
386+
The optional `name` field on each rule (e.g. `rules[].name: oauth2`) lets policies such as `SecurityPolicy`, `BackendTrafficPolicy`, or any other Gateway API policy that supports `sectionName` target a specific HTTPRoute rule rather than the entire route. Example:
387+
388+
```yaml
389+
apiVersion: gateway.envoyproxy.io/v1alpha1
390+
kind: SecurityPolicy
391+
metadata:
392+
name: oauth2-proxy-policy
393+
spec:
394+
targetRefs:
395+
- group: gateway.networking.k8s.io
396+
kind: HTTPRoute
397+
name: oauth2-proxy
398+
sectionName: oauth2 # matches rules[].name above
399+
jwt:
400+
providers:
401+
- name: example
402+
issuer: https://issuer.example.com
403+
remoteJWKS:
404+
uri: https://issuer.example.com/.well-known/jwks.json
405+
```
406+
407+
Without a rule `name`, policies cannot target individual rules and must apply to the whole HTTPRoute.
408+
383409
## TLS Configuration
384410

385411
See: [TLS Configuration](https://oauth2-proxy.github.io/oauth2-proxy/configuration/tls/).
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Gateway API configuration with rule name
2+
gatewayApi:
3+
enabled: true
4+
gatewayRef:
5+
name: test-gateway
6+
rules:
7+
- name: service
8+
matches:
9+
- path:
10+
type: PathPrefix
11+
value: /
12+
- name: metrics
13+
matches:
14+
- path:
15+
type: PathPrefix
16+
value: /metrics

helm/oauth2-proxy/templates/httproute.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ spec:
3030
rules:
3131
{{- if .Values.gatewayApi.rules }}
3232
{{- range .Values.gatewayApi.rules }}
33-
- matches:
33+
- {{- if .name }}
34+
name: {{ .name | quote }}
35+
{{- end }}
36+
matches:
3437
{{- if .matches }}
3538
{{- toYaml .matches | nindent 4 }}
3639
{{- else }}

helm/oauth2-proxy/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ gatewayApi:
361361
gatewayRef: {}
362362
# HTTPRoute rule configuration
363363
# rules:
364-
# - matches:
364+
# - name: service # optional: enables targeting by sectionName in policies
365+
# matches:
365366
# - path:
366367
# type: PathPrefix
367368
# value: /

0 commit comments

Comments
 (0)