Skip to content

Commit 7804d1f

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

File tree

15 files changed

+31
-141
lines changed

15 files changed

+31
-141
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
@@ -2774,18 +2774,6 @@ spec:
27742774
RemoteJWKS defines how to fetch and cache JSON Web Key Sets (JWKS) from a remote
27752775
HTTP/HTTPS endpoint.
27762776
properties:
2777-
asyncFetch:
2778-
description: Fetch Jwks asynchronously in the main thread
2779-
before the listener is activated. Fetched Jwks can
2780-
be used by all worker threads.
2781-
properties:
2782-
failedRefetchDuration:
2783-
description: The duration to refetch after a failed
2784-
fetch.
2785-
type: string
2786-
fastListener:
2787-
type: boolean
2788-
type: object
27892777
backendRef:
27902778
description: |-
27912779
BackendRef references a Kubernetes object that represents the
@@ -3781,7 +3769,11 @@ spec:
37813769
type: object
37823770
cacheDuration:
37833771
default: 300s
3772+
description: |-
3773+
Duration is a string value representing a duration in time. The format is as specified
3774+
in GEP-2257, a strict subset of the syntax parsed by Golang time.ParseDuration.
37843775
format: duration
3776+
pattern: ^([0-9]{1,5}(h|m|s|ms)){1,4}$
37853777
type: string
37863778
uri:
37873779
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
@@ -2773,18 +2773,6 @@ spec:
27732773
RemoteJWKS defines how to fetch and cache JSON Web Key Sets (JWKS) from a remote
27742774
HTTP/HTTPS endpoint.
27752775
properties:
2776-
asyncFetch:
2777-
description: Fetch Jwks asynchronously in the main thread
2778-
before the listener is activated. Fetched Jwks can
2779-
be used by all worker threads.
2780-
properties:
2781-
failedRefetchDuration:
2782-
description: The duration to refetch after a failed
2783-
fetch.
2784-
type: string
2785-
fastListener:
2786-
type: boolean
2787-
type: object
27882776
backendRef:
27892777
description: |-
27902778
BackendRef references a Kubernetes object that represents the
@@ -3780,7 +3768,11 @@ spec:
37803768
type: object
37813769
cacheDuration:
37823770
default: 300s
3771+
description: |-
3772+
Duration is a string value representing a duration in time. The format is as specified
3773+
in GEP-2257, a strict subset of the syntax parsed by Golang time.ParseDuration.
37833774
format: duration
3775+
pattern: ^([0-9]{1,5}(h|m|s|ms)){1,4}$
37843776
type: string
37853777
uri:
37863778
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
@@ -1069,10 +1069,7 @@ type RemoteJWKS struct {
10691069
URI string `json:"uri"`
10701070

10711071
// Duration after which the cached JWKS should be expired. If not specified, default cache duration is 5 minutes.
1072-
CacheDuration *metav1.Duration `json:"cacheDuration,omitempty"`
1073-
1074-
// Fetch Jwks asynchronously in the main thread before the listener is activated. Fetched Jwks can be used by all worker threads.
1075-
AsyncFetch *JwksAsyncFetch `json:"asyncFetch,omitempty"`
1072+
CacheDuration *gwapiv1.Duration `json:"cacheDuration,omitempty"`
10761073
}
10771074

10781075
// 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: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package translator
88
import (
99
"errors"
1010
"fmt"
11+
"time"
1112

1213
corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
1314
routev3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
@@ -18,8 +19,8 @@ import (
1819
"google.golang.org/protobuf/types/known/anypb"
1920
"google.golang.org/protobuf/types/known/durationpb"
2021
"google.golang.org/protobuf/types/known/emptypb"
21-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/utils/ptr"
23+
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
2324

2425
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
2526
"github.com/envoyproxy/gateway/internal/ir"
@@ -150,18 +151,14 @@ func buildJWTAuthn(irListener *ir.HTTPListener) (*jwtauthnv3.JwtAuthentication,
150151
jwksCluster = cluster.name
151152
}
152153

153-
var duration *metav1.Duration
154+
var duration *gwapiv1.Duration
154155
if jwks.CacheDuration != nil {
155156
duration = jwks.CacheDuration
156157
}
157158

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

167164
remote := &jwtauthnv3.JwtProvider_RemoteJwks{
@@ -174,8 +171,8 @@ func buildJWTAuthn(irListener *ir.HTTPListener) (*jwtauthnv3.JwtAuthentication,
174171
Timeout: &durationpb.Duration{Seconds: defaultExtServiceRequestTimeout},
175172
},
176173

177-
CacheDuration: durationpb.New(duration.Duration),
178-
AsyncFetch: &asyncFetch,
174+
CacheDuration: durationpb.New(timeDuration),
175+
AsyncFetch: &jwtauthnv3.JwksAsyncFetch{},
179176
},
180177
}
181178

0 commit comments

Comments
 (0)