Skip to content

Commit 8747546

Browse files
authored
feat: add spaceDelimitedClaims field to RequestAuthentication API (#3547)
Signed-off-by: Francisco Herrera <fjglira@gmail.com>
1 parent 4f6a6c5 commit 8747546

File tree

8 files changed

+178
-6
lines changed

8 files changed

+178
-6
lines changed

kubernetes/customresourcedefinitions.gen.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: release-notes/v2
2+
kind: feature
3+
area: security
4+
issue:
5+
- https://github.com/istio/istio/issues/56873
6+
7+
releaseNotes:
8+
- |
9+
**Added** `spaceDelimitedClaims` field in `RequestAuthentication` under `spec.jwtRules.` to configure custom JWT claims
10+
that should be treated as space-delimited strings.
11+
This allows authorization policies to match individual values within space-separated claim strings,
12+
extending beyond the default `scope` and `permission` claims.
13+
This addresses compatibility issues when upgrading from older Istio versions with custom space-delimited JWT claim fields.

security/v1/request_authentication_alias.gen.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

security/v1beta1/request_authentication.pb.go

Lines changed: 49 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

security/v1beta1/request_authentication.pb.html

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

security/v1beta1/request_authentication.proto

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,21 @@ message RequestAuthentication {
318318
// fromHeaders:
319319
// - "x-goog-iap-jwt-assertion"
320320
// ```
321+
//
322+
// This example shows how to configure custom claims to be treated as space-delimited strings.
323+
// This is useful when JWT tokens contain custom claims with multiple space-separated values
324+
// that should be available for individual matching in authorization policies.
325+
//
326+
// ```yaml
327+
// issuer: https://example.com
328+
// spaceDelimitedClaims:
329+
// - "custom_scope"
330+
// - "provider.login.scope"
331+
// - "roles"
332+
// ```
333+
//
334+
// With this configuration, a JWT containing `"custom_scope": "read write admin"` will allow
335+
// authorization policies to match against individual values like "read", "write", or "admin".
321336
// +kubebuilder:validation:XValidation:message="only one of jwks or jwksUri can be set",rule="oneof(self.jwksUri, self.jwks_uri, self.jwks)"
322337
message JWTRule {
323338
// Identifies the issuer that issued the JWT. See
@@ -450,8 +465,30 @@ message JWTRule {
450465
// will spend waiting for the JWKS to be fetched. Default is 5s.
451466
google.protobuf.Duration timeout = 13;
452467

468+
// List of JWT claim names that should be treated as space-delimited strings.
469+
// These claims will be split on whitespace and each individual value will be available
470+
// for matching in authorization policies. This extends the default behavior that only
471+
// treats 'scope' and 'permission' claims as space-delimited.
472+
//
473+
// Example usage for custom claims:
474+
// ```yaml
475+
// spaceDelimitedClaims:
476+
// - "custom_scope"
477+
// - "provider.login.scope"
478+
// - "roles"
479+
// ```
480+
//
481+
// This allows authorization policies to match individual values within space-separated
482+
// claim strings, maintaining compatibility with existing JWT token formats.
483+
//
484+
// Note: The default claims 'scope' and 'permission' are always treated as space-delimited
485+
// regardless of this setting.
486+
// +protoc-gen-crd:list-value-validation:MinLength=1
487+
// +kubebuilder:validation:MaxItems=64
488+
repeated string space_delimited_claims = 14;
489+
453490
// $hide_from_docs
454-
// Next available field number: 14
491+
// Next available field number: 15
455492
}
456493

457494
// This message specifies a header location to extract JWT token.

tests/testdata/reqauth-invalid.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,14 @@ spec:
210210
- issuer: example
211211
timeout: "apple"
212212
---
213+
_err: 'spaceDelimitedClaims[0] in body should be at least 1 chars long'
214+
apiVersion: security.istio.io/v1
215+
kind: RequestAuthentication
216+
metadata:
217+
name: invalid-space-delimited-claims
218+
spec:
219+
jwtRules:
220+
- issuer: example
221+
spaceDelimitedClaims:
222+
- ""
223+
---

tests/testdata/reqauth-valid.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ spec:
2020
header: def
2121
timeout: 5s
2222
outputPayloadToHeader: header
23+
spaceDelimitedClaims:
24+
- "custom_scope"
25+
- "provider.login.scope"

0 commit comments

Comments
 (0)