Skip to content

Commit 3deedc6

Browse files
committed
remove asyncFetch field and change cacheDuration type to gwapiv1.Duration
Signed-off-by: sachin maurya <[email protected]>
1 parent b100ab8 commit 3deedc6

File tree

15 files changed

+30
-140
lines changed

15 files changed

+30
-140
lines changed

api/v1alpha1/jwt_types.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package v1alpha1
77

88
import (
9-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
1110
)
1211

@@ -116,23 +115,7 @@ type RemoteJWKS struct {
116115
// +kubebuilder:default="300s"
117116
// +kubebuilder:validation:Format=duration
118117
// +optional
119-
CacheDuration *metav1.Duration `json:"cacheDuration,omitempty"`
120-
121-
// Fetch Jwks asynchronously in the main thread before the listener is activated. Fetched Jwks can be used by all worker threads.
122-
// +optional
123-
AsyncFetch *JwksAsyncFetch `json:"asyncFetch,omitempty"`
124-
}
125-
126-
// JwksAsyncFetch is used to Fetch Jwks asynchronously in the main thread before the listener is activated.
127-
type JwksAsyncFetch struct {
128-
// If false, the listener is activated after the initial fetch is completed. The initial fetch result can be either successful or failed.
129-
// If true, it is activated without waiting for the initial fetch to complete.
130-
131-
// +optional
132-
FastListener bool `json:"fastListener,omitempty"`
133-
// The duration to refetch after a failed fetch.
134-
// +optional
135-
FailedRefetchDuration *metav1.Duration `json:"failedRefetchDuration,omitempty"`
118+
CacheDuration *gwapiv1.Duration `json:"cacheDuration,omitempty"`
136119
}
137120

138121
// LocalJWKSType defines the types of values for Local JWKS.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_securitypolicies.yaml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,18 +2770,6 @@ spec:
27702770
RemoteJWKS defines how to fetch and cache JSON Web Key Sets (JWKS) from a remote
27712771
HTTP/HTTPS endpoint.
27722772
properties:
2773-
asyncFetch:
2774-
description: Fetch Jwks asynchronously in the main thread
2775-
before the listener is activated. Fetched Jwks can
2776-
be used by all worker threads.
2777-
properties:
2778-
failedRefetchDuration:
2779-
description: The duration to refetch after a failed
2780-
fetch.
2781-
type: string
2782-
fastListener:
2783-
type: boolean
2784-
type: object
27852773
backendRef:
27862774
description: |-
27872775
BackendRef references a Kubernetes object that represents the
@@ -3775,7 +3763,11 @@ spec:
37753763
type: object
37763764
cacheDuration:
37773765
default: 300s
3766+
description: |-
3767+
Duration is a string value representing a duration in time. The format is as specified
3768+
in GEP-2257, a strict subset of the syntax parsed by Golang time.ParseDuration.
37783769
format: duration
3770+
pattern: ^([0-9]{1,5}(h|m|s|ms)){1,4}$
37793771
type: string
37803772
uri:
37813773
description: |-

charts/gateway-helm/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,18 +2769,6 @@ spec:
27692769
RemoteJWKS defines how to fetch and cache JSON Web Key Sets (JWKS) from a remote
27702770
HTTP/HTTPS endpoint.
27712771
properties:
2772-
asyncFetch:
2773-
description: Fetch Jwks asynchronously in the main thread
2774-
before the listener is activated. Fetched Jwks can
2775-
be used by all worker threads.
2776-
properties:
2777-
failedRefetchDuration:
2778-
description: The duration to refetch after a failed
2779-
fetch.
2780-
type: string
2781-
fastListener:
2782-
type: boolean
2783-
type: object
27842772
backendRef:
27852773
description: |-
27862774
BackendRef references a Kubernetes object that represents the
@@ -3774,7 +3762,11 @@ spec:
37743762
type: object
37753763
cacheDuration:
37763764
default: 300s
3765+
description: |-
3766+
Duration is a string value representing a duration in time. The format is as specified
3767+
in GEP-2257, a strict subset of the syntax parsed by Golang time.ParseDuration.
37773768
format: duration
3769+
pattern: ^([0-9]{1,5}(h|m|s|ms)){1,4}$
37783770
type: string
37793771
uri:
37803772
description: |-

examples/kubernetes/jwt/jwt.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ spec:
1313
remoteJWKS:
1414
uri: https://raw.githubusercontent.com/envoyproxy/gateway/main/examples/kubernetes/jwt/jwks.json
1515
cacheDuration: 60s
16-
asyncFetch:
17-
fastListener: true
18-
failedRefetchDuration: 2s
1916
---
2017
apiVersion: gateway.networking.k8s.io/v1
2118
kind: HTTPRoute

internal/gatewayapi/resource/testdata/all-resources.out.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ securityPolicies:
383383
providers:
384384
- name: example
385385
remoteJWKS:
386-
cacheDuration: 5m0s
386+
cacheDuration: 300s
387387
uri: https://raw.githubusercontent.com/envoyproxy/gateway/main/examples/kubernetes/jwt/jwks.json
388388
targetRef:
389389
group: gateway.networking.k8s.io

internal/gatewayapi/securitypolicy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,6 @@ func (t *Translator) buildRemoteJWKS(
10161016
Traffic: traffic,
10171017
URI: remoteJWKS.URI,
10181018
CacheDuration: remoteJWKS.CacheDuration,
1019-
AsyncFetch: (*ir.JwksAsyncFetch)(remoteJWKS.AsyncFetch),
10201019
}, nil
10211020
}
10221021

internal/ir/xds.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,7 @@ type RemoteJWKS struct {
10791079
URI string `json:"uri"`
10801080

10811081
// Duration after which the cached JWKS should be expired. If not specified, default cache duration is 5 minutes.
1082-
CacheDuration *metav1.Duration `json:"cacheDuration,omitempty"`
1083-
1084-
// Fetch Jwks asynchronously in the main thread before the listener is activated. Fetched Jwks can be used by all worker threads.
1085-
AsyncFetch *JwksAsyncFetch `json:"asyncFetch,omitempty"`
1082+
CacheDuration *gwapiv1.Duration `json:"cacheDuration,omitempty"`
10861083
}
10871084

10881085
// JwksAsyncFetch is used to Fetch Jwks asynchronously in the main thread before the listener is activated.

internal/ir/zz_generated.deepcopy.go

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/xds/translator/jwt.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"google.golang.org/protobuf/types/known/anypb"
2020
"google.golang.org/protobuf/types/known/durationpb"
2121
"google.golang.org/protobuf/types/known/emptypb"
22-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2322
"k8s.io/utils/ptr"
23+
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
2424

2525
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
2626
"github.com/envoyproxy/gateway/internal/ir"
@@ -151,18 +151,14 @@ func buildJWTAuthn(irListener *ir.HTTPListener) (*jwtauthnv3.JwtAuthentication,
151151
jwksCluster = cluster.name
152152
}
153153

154-
var duration *metav1.Duration
154+
var duration *gwapiv1.Duration
155155
if jwks.CacheDuration != nil {
156156
duration = jwks.CacheDuration
157157
}
158158

159-
var asyncFetch jwtauthnv3.JwksAsyncFetch
160-
161-
if jwks.AsyncFetch != nil {
162-
asyncFetch = jwtauthnv3.JwksAsyncFetch{
163-
FastListener: jwks.AsyncFetch.FastListener,
164-
FailedRefetchDuration: durationpb.New(jwks.AsyncFetch.FailedRefetchDuration.Duration),
165-
}
159+
timeDuration, err := time.ParseDuration(string(*duration))
160+
if err != nil {
161+
return nil, err
166162
}
167163

168164
remote := &jwtauthnv3.JwtProvider_RemoteJwks{
@@ -174,7 +170,8 @@ func buildJWTAuthn(irListener *ir.HTTPListener) (*jwtauthnv3.JwtAuthentication,
174170
},
175171
Timeout: durationpb.New(defaultExtServiceRequestTimeout),
176172
},
177-
CacheDuration: &durationpb.Duration{Seconds: 5 * 60},
173+
174+
CacheDuration: durationpb.New(timeDuration),
178175
AsyncFetch: &jwtauthnv3.JwksAsyncFetch{},
179176
},
180177
}

0 commit comments

Comments
 (0)