49
49
// Method must contain valid methods list (PUT, GET, POST, BLA)
50
50
// May contain or not spaces between each verb
51
51
corsMethodsRegex = regexp .MustCompile (`^([A-Za-z]+,?\s?)+$` )
52
- // Expose Headers must contain valid values only (*, X-HEADER12, X-ABC)
52
+ // CORS Headers must contain valid values only (*, X-HEADER12, X-ABC)
53
53
// May contain or not spaces between each Header
54
- corsExposeHeadersRegex = regexp .MustCompile (`^(([A-Za-z0-9\-\_]+|\*),?\s?)+$` )
54
+ corsHeadersRegex = regexp .MustCompile (`^(([A-Za-z0-9\-\_]+|\*),?\s?)+$` )
55
55
)
56
56
57
57
const (
@@ -82,11 +82,11 @@ var corsAnnotation = parser.Annotation{
82
82
It also supports single level wildcard subdomains and follows this format: http(s)://*.foo.bar, http(s)://*.bar.foo:8080 or http(s)://*.abc.bar.foo:9000` ,
83
83
},
84
84
corsAllowHeadersAnnotation : {
85
- Validator : parser .ValidateRegex (parser . HeadersVariable , true ),
85
+ Validator : parser .ValidateRegex (corsHeadersRegex , true ),
86
86
Scope : parser .AnnotationScopeIngress ,
87
87
Risk : parser .AnnotationRiskMedium ,
88
88
Documentation : `This annotation controls which headers are accepted.
89
- This is a multi-valued field, separated by ',' and accepts letters, numbers, _ and - ` ,
89
+ This is a multi-valued field, separated by ',' and accepts letters, numbers, _, - and *. ` ,
90
90
},
91
91
corsAllowMethodsAnnotation : {
92
92
Validator : parser .ValidateRegex (corsMethodsRegex , true ),
@@ -102,7 +102,7 @@ var corsAnnotation = parser.Annotation{
102
102
Documentation : `This annotation controls if credentials can be passed during CORS operations.` ,
103
103
},
104
104
corsExposeHeadersAnnotation : {
105
- Validator : parser .ValidateRegex (corsExposeHeadersRegex , true ),
105
+ Validator : parser .ValidateRegex (corsHeadersRegex , true ),
106
106
Scope : parser .AnnotationScopeIngress ,
107
107
Risk : parser .AnnotationRiskMedium ,
108
108
Documentation : `This annotation controls which headers are exposed to response.
@@ -225,7 +225,7 @@ func (c cors) Parse(ing *networking.Ingress) (interface{}, error) {
225
225
}
226
226
227
227
config .CorsAllowHeaders , err = parser .GetStringAnnotation (corsAllowHeadersAnnotation , ing , c .annotationConfig .Annotations )
228
- if err != nil || ! parser . HeadersVariable .MatchString (config .CorsAllowHeaders ) {
228
+ if err != nil || ! corsHeadersRegex .MatchString (config .CorsAllowHeaders ) {
229
229
config .CorsAllowHeaders = defaultCorsHeaders
230
230
}
231
231
@@ -245,7 +245,7 @@ func (c cors) Parse(ing *networking.Ingress) (interface{}, error) {
245
245
}
246
246
247
247
config .CorsExposeHeaders , err = parser .GetStringAnnotation (corsExposeHeadersAnnotation , ing , c .annotationConfig .Annotations )
248
- if err != nil || ! corsExposeHeadersRegex .MatchString (config .CorsExposeHeaders ) {
248
+ if err != nil || ! corsHeadersRegex .MatchString (config .CorsExposeHeaders ) {
249
249
config .CorsExposeHeaders = ""
250
250
}
251
251
0 commit comments