From 6db5b5c4175467c3ccef53f8622236f2099dd2b1 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Mon, 1 Jun 2020 14:58:08 +0300 Subject: [PATCH] Add allow origins field to CORS spec --- pkg/apis/istio/v1alpha3/virtual_service.go | 6 ++++++ pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/apis/istio/v1alpha3/virtual_service.go b/pkg/apis/istio/v1alpha3/virtual_service.go index 7718ab074..4831ceae6 100644 --- a/pkg/apis/istio/v1alpha3/virtual_service.go +++ b/pkg/apis/istio/v1alpha3/virtual_service.go @@ -705,6 +705,12 @@ type CorsPolicy struct { // header. Wildcard * will allow all origins. AllowOrigin []string `json:"allowOrigin,omitempty"` + // String patterns that match allowed origins. An origin is allowed if + // any of the string matchers match. If a match is found, then the + // outgoing Access-Control-Allow-Origin would be set to the origin as + // provided by the client. + AllowOrigins []*v1alpha1.StringMatch `json:"allowOrigins,omitempty"` + // List of HTTP methods allowed to access the resource. The content will // be serialized into the Access-Control-Allow-Methods header. AllowMethods []string `json:"allowMethods,omitempty"` diff --git a/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go index a187f4163..f3e928f14 100644 --- a/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go +++ b/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go @@ -80,6 +80,17 @@ func (in *CorsPolicy) DeepCopyInto(out *CorsPolicy) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.AllowOrigins != nil { + in, out := &in.AllowOrigins, &out.AllowOrigins + *out = make([]*v1alpha1.StringMatch, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(v1alpha1.StringMatch) + **out = **in + } + } + } if in.AllowMethods != nil { in, out := &in.AllowMethods, &out.AllowMethods *out = make([]string, len(*in))