Skip to content

Commit 6f57f25

Browse files
committed
Shrinking spec for CORS to avoid exceeding CRD size limit
1 parent db04fdb commit 6f57f25

File tree

7 files changed

+420
-1050
lines changed

7 files changed

+420
-1050
lines changed

apis/v1/httproute_types.go

Lines changed: 77 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,49 +1303,40 @@ type HTTPRequestMirrorFilter struct {
13031303
// HTTPCORSFilter defines a filter that that configures Cross-Origin Request
13041304
// Sharing (CORS).
13051305
type HTTPCORSFilter struct {
1306-
// AllowOrigins indicates whether the response can be shared with
1307-
// requested resource from the given `Origin`.
1306+
// AllowOrigins indicates whether the response can be shared with requested
1307+
// resource from the given `Origin`.
13081308
//
1309-
// The `Origin` consists of a scheme and a host, with an optional
1310-
// port, and takes the form `<scheme>://<host>(:<port>)`.
1309+
// The `Origin` consists of a scheme and a host, with an optional port, and
1310+
// takes the form `<scheme>://<host>(:<port>)`.
13111311
//
13121312
// Valid values for scheme are: `http` and `https`.
13131313
//
1314-
// Valid values for port are any integer between 1 and 65535
1315-
// (the list of available TCP/UDP ports). Note that, if not included,
1316-
// port `80` is assumed for `http` scheme origins, and port `443`
1317-
// is assumed for `https` origins. This may affect origin matching.
1314+
// Valid values for port are any integer between 1 and 65535 (the list of
1315+
// available TCP/UDP ports). Note that, if not included, port `80` is
1316+
// assumed for `http` scheme origins, and port `443` is assumed for `https`
1317+
// origins. This may affect origin matching.
13181318
//
1319-
// The host part of the origin may contain the wildcard character `*`.
1320-
// These wildcard characters behave as follows:
1319+
// The host part of the origin may contain the wildcard character `*`. These
1320+
// wildcard characters behave as follows:
13211321
//
13221322
// * `*` is a greedy match to the _left_, including any number of
13231323
// DNS labels to the left of its position. This also means that
13241324
// `*` will include any number of period `.` characters to the
13251325
// left of its position.
13261326
// * A wildcard by itself matches all hosts.
13271327
//
1328-
// An origin value that includes _only_ the `*` character
1329-
// indicates requests from all `Origin`s are allowed.
1328+
// An origin value that includes _only_ the `*` character indicates requests
1329+
// from all `Origin`s are allowed.
13301330
//
1331-
// When the `AllowOrigins` field is configured with multiple
1332-
// origins, it means the server supports clients from multiple
1333-
// origins. If the request `Origin` matches the configured
1334-
// allowed origins, the gateway must return the given `Origin`
1335-
// and sets value of the header `Access-Control-Allow-Origin`
1336-
// same as the `Origin` header provided by the client.
1331+
// When the `AllowOrigins` field is configured with multiple origins, it
1332+
// means the server supports clients from multiple origins. If the request
1333+
// `Origin` matches the configured allowed origins, the gateway must return
1334+
// the given `Origin` and sets value of the header
1335+
// `Access-Control-Allow-Origin` same as the `Origin` header provided by the
1336+
// client.
13371337
//
1338-
// The status code of a successful response to a "preflight"
1339-
// request is always an OK status (i.e., 204 or 200).
1340-
//
1341-
// Input:
1342-
// Origin: https://foo.example
1343-
//
1344-
// Config:
1345-
// allowOrigins: ["https://foo.example", "http://foo.example", "https://test.example", "http://test.example"]
1346-
//
1347-
// Output:
1348-
// Access-Control-Allow-Origin: https://foo.example
1338+
// The status code of a successful response to a "preflight" request is
1339+
// always an OK status (i.e., 204 or 200).
13491340
//
13501341
// If the request `Origin` does not match the configured allowed origins,
13511342
// the gateway returns 204/200 response but doesn't set the relevant
@@ -1354,76 +1345,38 @@ type HTTPCORSFilter struct {
13541345
// the CORS headers. The cross-origin request fails on the client side.
13551346
// Therefore, the client doesn't attempt the actual cross-origin request.
13561347
//
1357-
// Input:
1358-
// Origin: https://foo.example
1359-
//
1360-
// Config:
1361-
// allowOrigins: ["https://test.example", "http://test.example"]
1362-
//
1363-
// Output:
1364-
//
13651348
// The `Access-Control-Allow-Origin` response header can only use `*`
13661349
// wildcard as value when the `AllowCredentials` field is unspecified.
13671350
//
1368-
// Input:
1369-
// Origin: https://foo.example
1370-
//
1371-
// Config:
1372-
// allowOrigins: ["*"]
1373-
//
1374-
// Output:
1375-
// Access-Control-Allow-Origin: *
1376-
//
1377-
// When the `AllowCredentials` field is specified and `AllowOrigins`
1378-
// field specified with the `*` wildcard, the gateway must return a
1379-
// single origin in the value of the `Access-Control-Allow-Origin`
1380-
// response header, instead of specifying the `*` wildcard. The value
1381-
// of the header `Access-Control-Allow-Origin` is same as the `Origin`
1382-
// header provided by the client.
1383-
//
1384-
// Input:
1385-
// Origin: https://foo.example
1386-
//
1387-
// Config:
1388-
// allowOrigins: ["*"]
1389-
// allowCredentials: true
1390-
//
1391-
// Output:
1392-
// Access-Control-Allow-Origin: https://foo.example
1393-
// Access-Control-Allow-Credentials: true
1351+
// When the `AllowCredentials` field is specified and `AllowOrigins` field
1352+
// specified with the `*` wildcard, the gateway must return a single origin
1353+
// in the value of the `Access-Control-Allow-Origin` response header,
1354+
// instead of specifying the `*` wildcard. The value of the header
1355+
// `Access-Control-Allow-Origin` is same as the `Origin` header provided by
1356+
// the client.
13941357
//
13951358
// Support: Extended
13961359
// +listType=set
13971360
// +kubebuilder:validation:MaxItems=64
13981361
AllowOrigins []AbsoluteURI `json:"allowOrigins,omitempty"`
13991362

1400-
// AllowCredentials indicates whether the actual cross-origin request
1401-
// allows to include credentials.
1363+
// AllowCredentials indicates whether the actual cross-origin request allows
1364+
// to include credentials.
14021365
//
1403-
// The only valid value for the `Access-Control-Allow-Credentials`
1404-
// response header is true (case-sensitive).
1366+
// The only valid value for the `Access-Control-Allow-Credentials` response
1367+
// header is true (case-sensitive).
14051368
//
1406-
// Input:
1407-
// Origin: https://foo.example
1408-
//
1409-
// Config:
1410-
// allowCredentials: true
1411-
//
1412-
// Output:
1413-
// Access-Control-Allow-Origin: https://foo.example
1414-
// Access-Control-Allow-Credentials: true
1415-
//
1416-
// If the credentials are not allowed in cross-origin requests,
1417-
// the gateway will omit the header `Access-Control-Allow-Credentials`
1418-
// entirely rather than setting its value to false.
1369+
// If the credentials are not allowed in cross-origin requests, the gateway
1370+
// will omit the header `Access-Control-Allow-Credentials` entirely rather
1371+
// than setting its value to false.
14191372
//
14201373
// Support: Extended
14211374
//
14221375
// +optional
14231376
AllowCredentials *LowercaseTrue `json:"allowCredentials,omitempty"`
14241377

1425-
// AllowMethods indicates which HTTP methods are supported
1426-
// for accessing the requested resource.
1378+
// AllowMethods indicates which HTTP methods are supported for accessing the
1379+
// requested resource.
14271380
//
14281381
// Valid values are any method defined by RFC9110, along with the special
14291382
// value `*`, which represents all HTTP methods are allowed.
@@ -1435,130 +1388,72 @@ type HTTPCORSFilter struct {
14351388
// response header are separated by a comma (",").
14361389
//
14371390
// A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`.
1438-
// (See https://fetch.spec.whatwg.org/#cors-safelisted-method)
1439-
// The CORS-safelisted methods are always allowed, regardless of whether
1440-
// they are specified in the `AllowMethods` field.
1391+
// (See https://fetch.spec.whatwg.org/#cors-safelisted-method) The
1392+
// CORS-safelisted methods are always allowed, regardless of whether they
1393+
// are specified in the `AllowMethods` field.
14411394
//
1442-
// When the `AllowMethods` field is configured with one or more methods,
1443-
// the gateway must return the `Access-Control-Allow-Methods` response
1444-
// header which value is present in the `AllowMethods` field.
1395+
// When the `AllowMethods` field is configured with one or more methods, the
1396+
// gateway must return the `Access-Control-Allow-Methods` response header
1397+
// which value is present in the `AllowMethods` field.
14451398
//
14461399
// If the HTTP method of the `Access-Control-Request-Method` request header
14471400
// is not included in the list of methods specified by the response header
14481401
// `Access-Control-Allow-Methods`, it will present an error on the client
14491402
// side.
14501403
//
1451-
// Input:
1452-
// Access-Control-Request-Method: PUT
1453-
//
1454-
// Config:
1455-
// allowMethods: ["GET", "POST", "DELETE", "PATCH", "OPTIONS"]
1456-
//
1457-
// Output:
1458-
// Access-Control-Allow-Methods: GET, POST, DELETE, PATCH, OPTIONS
1459-
//
14601404
// The `Access-Control-Allow-Methods` response header can only use `*`
14611405
// wildcard as value when the `AllowCredentials` field is unspecified.
14621406
//
1463-
// Input:
1464-
// Access-Control-Request-Method: PUT
1465-
//
1466-
// Config:
1467-
// allowMethods: ["*"]
1468-
//
1469-
// Output:
1470-
// Access-Control-Allow-Methods: *
1471-
//
1472-
// When the `AllowCredentials` field is specified and `AllowMethods`
1473-
// field specified with the `*` wildcard, the gateway must specify one
1474-
// HTTP method in the value of the Access-Control-Allow-Methods response
1475-
// header. The value of the header `Access-Control-Allow-Methods` is same
1476-
// as the `Access-Control-Request-Method` header provided by the client.
1477-
// If the header `Access-Control-Request-Method` is not included in the
1478-
// request, the gateway will omit the `Access-Control-Allow-Methods`
1479-
// response header, instead of specifying the `*` wildcard. A Gateway
1480-
// implementation may choose to add implementation-specific default
1481-
// methods.
1482-
//
1483-
// Input:
1484-
// Access-Control-Request-Method: PUT
1485-
//
1486-
// Config:
1487-
// allowMethods: ["*"]
1488-
// allowCredentials: true
1489-
//
1490-
// Output:
1491-
// Access-Control-Allow-Methods: PUT
1492-
// Access-Control-Allow-Credentials: true
1407+
// When the `AllowCredentials` field is specified and `AllowMethods` field
1408+
// specified with the `*` wildcard, the gateway must specify one HTTP method
1409+
// in the value of the Access-Control-Allow-Methods response header. The
1410+
// value of the header `Access-Control-Allow-Methods` is same as the
1411+
// `Access-Control-Request-Method` header provided by the client. If the
1412+
// header `Access-Control-Request-Method` is not included in the request,
1413+
// the gateway will omit the `Access-Control-Allow-Methods` response header,
1414+
// instead of specifying the `*` wildcard. A Gateway implementation may
1415+
// choose to add implementation-specific default methods.
14931416
//
14941417
// Support: Extended
14951418
//
14961419
// +listType=set
14971420
// +kubebuilder:validation:MaxItems=9
1498-
// +kubebuilder:validation:UniqueItems=true
14991421
AllowMethods []HTTPMethodWithWildcard `json:"allowMethods,omitempty"`
15001422

1501-
// AllowHeaders indicates which HTTP request headers are supported
1502-
// for accessing the requested resource.
1423+
// AllowHeaders indicates which HTTP request headers are supported for
1424+
// accessing the requested resource.
15031425
//
15041426
// Header names are not case sensitive.
15051427
//
15061428
// Multiple header names in the value of the `Access-Control-Allow-Headers`
15071429
// response header are separated by a comma (",").
15081430
//
1509-
// When the `AllowHeaders` field is configured with one or more headers,
1510-
// the gateway must return the `Access-Control-Allow-Headers` response
1511-
// header which value is present in the `AllowHeaders` field.
1431+
// When the `AllowHeaders` field is configured with one or more headers, the
1432+
// gateway must return the `Access-Control-Allow-Headers` response header
1433+
// which value is present in the `AllowHeaders` field.
15121434
//
15131435
// If any header name in the `Access-Control-Request-Headers` request header
1514-
// is not included in the list of header names specified by the response header
1515-
// `Access-Control-Allow-Headers`, it will present an error on the client side.
1436+
// is not included in the list of header names specified by the response
1437+
// header `Access-Control-Allow-Headers`, it will present an error on the
1438+
// client side.
15161439
//
1517-
// If any header name in the `Access-Control-Allow-Headers` response header does
1518-
// not recognize by the client, it will also occur an error on the client side.
1519-
//
1520-
// Input:
1521-
// Access-Control-Request-Headers: Cache-Control, Content-Type
1522-
//
1523-
// Config:
1524-
// allowHeaders: ["DNT", "Keep-Alive", "User-Agent", "X-Requested-With", "If-Modified-Since", "Cache-Control", "Content-Type", "Range", "Authorization"]
1525-
//
1526-
// Output:
1527-
// Access-Control-Allow-Headers: DNT, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization
1440+
// If any header name in the `Access-Control-Allow-Headers` response header
1441+
// does not recognize by the client, it will also occur an error on the
1442+
// client side.
15281443
//
15291444
// A wildcard indicates that the requests with all HTTP headers are allowed.
1530-
// The `Access-Control-Allow-Headers` response header can only use `*` wildcard
1531-
// as value when the `AllowCredentials` field is unspecified.
1532-
//
1533-
// Input:
1534-
// Access-Control-Request-Headers: Content-Type, Cache-Control
1535-
//
1536-
// Config:
1537-
// allowHeaders: ["*"]
1538-
//
1539-
// Output:
1540-
// Access-Control-Allow-Headers: *
1445+
// The `Access-Control-Allow-Headers` response header can only use `*`
1446+
// wildcard as value when the `AllowCredentials` field is unspecified.
15411447
//
15421448
// When the `AllowCredentials` field is specified and `AllowHeaders` field
15431449
// specified with the `*` wildcard, the gateway must specify one or more
15441450
// HTTP headers in the value of the `Access-Control-Allow-Headers` response
15451451
// header. The value of the header `Access-Control-Allow-Headers` is same as
15461452
// the `Access-Control-Request-Headers` header provided by the client. If
1547-
// the header `Access-Control-Request-Headers` is not included in the request,
1548-
// the gateway will omit the `Access-Control-Allow-Headers` response header,
1549-
// instead of specifying the `*` wildcard. A Gateway implementation may choose
1550-
// to add implementation-specific default headers.
1551-
//
1552-
// Input:
1553-
// Access-Control-Request-Headers: Content-Type, Cache-Control
1554-
//
1555-
// Config:
1556-
// allowHeaders: ["*"]
1557-
// allowCredentials: true
1558-
//
1559-
// Output:
1560-
// Access-Control-Allow-Headers: Content-Type, Cache-Control
1561-
// Access-Control-Allow-Credentials: true
1453+
// the header `Access-Control-Request-Headers` is not included in the
1454+
// request, the gateway will omit the `Access-Control-Allow-Headers`
1455+
// response header, instead of specifying the `*` wildcard. A Gateway
1456+
// implementation may choose to add implementation-specific default headers.
15621457
//
15631458
// Support: Extended
15641459
//
@@ -1582,29 +1477,19 @@ type HTTPCORSFilter struct {
15821477
// (See https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name)
15831478
// The CORS-safelisted response headers are exposed to client by default.
15841479
//
1585-
// When an HTTP header name is specified using the `ExposeHeaders` field, this
1586-
// additional header will be exposed as part of the response to the client.
1480+
// When an HTTP header name is specified using the `ExposeHeaders` field,
1481+
// this additional header will be exposed as part of the response to the
1482+
// client.
15871483
//
15881484
// Header names are not case sensitive.
15891485
//
15901486
// Multiple header names in the value of the `Access-Control-Expose-Headers`
15911487
// response header are separated by a comma (",").
15921488
//
1593-
// Config:
1594-
// exposeHeaders: ["Content-Security-Policy", "Content-Encoding"]
1595-
//
1596-
// Output:
1597-
// Access-Control-Expose-Headers: Content-Security-Policy, Content-Encoding
1598-
//
15991489
// A wildcard indicates that the responses with all HTTP headers are exposed
1600-
// to clients. The `Access-Control-Expose-Headers` response header can only use
1601-
// `*` wildcard as value when the `AllowCredentials` field is unspecified.
1602-
//
1603-
// Config:
1604-
// exposeHeaders: ["*"]
1605-
//
1606-
// Output:
1607-
// Access-Control-Expose-Headers: *
1490+
// to clients. The `Access-Control-Expose-Headers` response header can only
1491+
// use `*` wildcard as value when the `AllowCredentials` field is
1492+
// unspecified.
16081493
//
16091494
// Support: Extended
16101495
//
@@ -1613,26 +1498,15 @@ type HTTPCORSFilter struct {
16131498
// +kubebuilder:validation:MaxItems=64
16141499
ExposeHeaders []HTTPHeaderName `json:"exposeHeaders,omitempty"`
16151500

1616-
// MaxAge indicates the duration (in seconds) for the client to cache
1617-
// the results of a "preflight" request.
1501+
// MaxAge indicates the duration (in seconds) for the client to cache the
1502+
// results of a "preflight" request.
16181503
//
16191504
// The information provided by the `Access-Control-Allow-Methods` and
16201505
// `Access-Control-Allow-Headers` response headers can be cached by the
16211506
// client until the time specified by `Access-Control-Max-Age` elapses.
16221507
//
1623-
// The default value of `Access-Control-Max-Age` response header is
1624-
// 5 (seconds).
1625-
//
1626-
// When the `MaxAge` field is unspecified, the gateway sets the response
1627-
// header "Access-Control-Max-Age: 5" by default.
1628-
//
1629-
// Config:
1630-
// maxAge: 1728000
1631-
//
1632-
// Output:
1633-
// Access-Control-Max-Age: 1728000
1634-
//
1635-
// Support: Extended
1508+
// The default value of `Access-Control-Max-Age` response header is 5
1509+
// (seconds).
16361510
//
16371511
// +optional
16381512
// +kubebuilder:default=5

0 commit comments

Comments
 (0)