Merge pull request #604 from weaveworks/cors-allow-origins

Add allow origins field to CORS spec
This commit is contained in:
Stefan Prodan 2020-06-01 15:22:31 +03:00 committed by GitHub
commit 33076941b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -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"`

View File

@ -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))