Skip to content

Commit edac8d2

Browse files
committed
address codex comments
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
1 parent c6cd09a commit edac8d2

4 files changed

Lines changed: 51 additions & 10 deletions

File tree

internal/gatewayapi/securitypolicy.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,10 +1669,12 @@ func (t *Translator) buildOIDC(
16691669
disableTokenEncryption = *oidc.DisableTokenEncryption
16701670
}
16711671

1672+
oidcOwner := policyOwnerOr(owners.oidc, policy)
1673+
16721674
// Generate a unique cookie suffix for oauth filters.
16731675
// This is to avoid cookie name collision when multiple security policies are applied
16741676
// to the same route.
1675-
suffix := utils.Digest32(string(policy.UID))
1677+
suffix := utils.Digest32(string(oidcOwner.UID))
16761678

16771679
// Get the HMAC secret.
16781680
// HMAC secret is generated by the CertGen job and stored in a secret
@@ -1688,7 +1690,6 @@ func (t *Translator) buildOIDC(
16881690
"HMAC secret not found in secret %s/%s", t.ControllerNamespace, oidcHMACSecretName)
16891691
}
16901692

1691-
oidcOwner := policyOwnerOr(owners.oidc, policy)
16921693
irOIDC := &ir.OIDC{
16931694
Name: irConfigName(oidcOwner),
16941695
Provider: *provider,

internal/gatewayapi/testdata/securitypolicy-with-merge-needs-fieldowner.in.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ services:
4242
- port: 9000
4343
name: grpc
4444
protocol: TCP
45+
- apiVersion: v1
46+
kind: Service
47+
metadata:
48+
namespace: default
49+
name: grpc-backend
50+
spec:
51+
ports:
52+
- port: 9000
53+
name: grpc
54+
protocol: TCP
4555
endpointSlices:
4656
- apiVersion: discovery.k8s.io/v1
4757
kind: EndpointSlice
@@ -60,12 +70,30 @@ endpointSlices:
6070
- 8.8.8.8
6171
conditions:
6272
ready: true
73+
- apiVersion: discovery.k8s.io/v1
74+
kind: EndpointSlice
75+
metadata:
76+
namespace: default
77+
name: endpointslice-grpc-backend
78+
labels:
79+
kubernetes.io/service-name: grpc-backend
80+
addressType: IPv4
81+
ports:
82+
- name: grpc
83+
protocol: TCP
84+
port: 9000
85+
endpoints:
86+
- addresses:
87+
- 9.9.9.9
88+
conditions:
89+
ready: true
6390
securityPolicies:
6491
- apiVersion: gateway.envoyproxy.io/v1alpha1
6592
kind: SecurityPolicy
6693
metadata:
6794
namespace: envoy-gateway
6895
name: policy-for-gateway
96+
uid: "aaaaaaaa-0000-0000-0000-000000000001" # check: oidc suffix value [c3556d06]
6997
spec:
7098
targetRefs:
7199
- group: gateway.networking.k8s.io
@@ -121,13 +149,18 @@ securityPolicies:
121149
metadata:
122150
namespace: default
123151
name: policy-for-route
152+
uid: "bbbbbbbb-0000-0000-0000-000000000002" # check: oidc suffix value [6ac6170b]
124153
spec:
125154
mergeType: StrategicMerge
126155
targetRefs:
127156
- group: gateway.networking.k8s.io
128157
kind: HTTPRoute
129158
name: httproute-1
130159
extAuth:
160+
grpc:
161+
backendRefs:
162+
- name: grpc-backend
163+
port: 9000
131164
contextExtensions:
132165
- name: shared
133166
type: ValueRef

internal/gatewayapi/testdata/securitypolicy-with-merge-needs-fieldowner.out.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ securityPolicies:
117117
metadata:
118118
name: policy-for-route
119119
namespace: default
120+
uid: bbbbbbbb-0000-0000-0000-000000000002
120121
spec:
121122
extAuth:
122123
contextExtensions:
@@ -134,6 +135,10 @@ securityPolicies:
134135
key: data
135136
kind: ConfigMap
136137
name: context-extension-for-route
138+
grpc:
139+
backendRefs:
140+
- name: grpc-backend
141+
port: 9000
137142
mergeType: StrategicMerge
138143
targetRefs:
139144
- group: gateway.networking.k8s.io
@@ -164,6 +169,7 @@ securityPolicies:
164169
metadata:
165170
name: policy-for-gateway
166171
namespace: envoy-gateway
172+
uid: aaaaaaaa-0000-0000-0000-000000000001
167173
spec:
168174
basicAuth:
169175
users:
@@ -312,31 +318,31 @@ xdsIR:
312318
- name: parent-only
313319
value: '[redacted]'
314320
grpc:
315-
authority: grpc-backend.envoy-gateway:9000
321+
authority: grpc-backend.default:9000
316322
destination:
317323
metadata:
318324
kind: SecurityPolicy
319-
name: policy-for-gateway
320-
namespace: envoy-gateway
321-
name: securitypolicy/envoy-gateway/policy-for-gateway/extauth/0
325+
name: policy-for-route
326+
namespace: default
327+
name: securitypolicy/default/policy-for-route/extauth/0
322328
settings:
323329
- addressType: IP
324330
endpoints:
325-
- host: 8.8.8.8
331+
- host: 9.9.9.9
326332
port: 9000
327333
metadata:
328334
kind: Service
329335
name: grpc-backend
330-
namespace: envoy-gateway
336+
namespace: default
331337
sectionName: "9000"
332-
name: securitypolicy/envoy-gateway/policy-for-gateway/extauth/0/backend/0
338+
name: securitypolicy/default/policy-for-route/extauth/0/backend/0
333339
protocol: GRPC
334340
weight: 1
335341
name: securitypolicy/default/policy-for-route
336342
oidc:
337343
clientID: client1.apps.googleusercontent.com
338344
clientSecret: '[redacted]'
339-
cookieSuffix: 811c9dc5
345+
cookieSuffix: c3556d06
340346
hmacSecret: '[redacted]'
341347
logoutPath: /logout
342348
name: securitypolicy/envoy-gateway/policy-for-gateway

release-notes/current.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ date: Pending
22

33
# Changes that are expected to cause an incompatibility with previous versions, such as deletions or modifications to existing APIs.
44
breaking changes: |
5+
Merged SecurityPolicy IR/xDS resource names (OIDC, BasicAuth, ExtAuth, JWT) now derive from the policy that contributes the field (parent or route) rather than always using the route-level policy. EnvoyPatchPolicy users who reference those generated names must update their patch targets.
56
67
# Updates addressing vulnerabilities, security flaws, or compliance requirements.
78
security updates: |

0 commit comments

Comments
 (0)