2016-06-01 18:47:37 +00:00
|
|
|
/*
|
2016-09-08 11:02:39 +00:00
|
|
|
Copyright 2016 The Kubernetes Authors.
|
2016-06-01 18:47:37 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package secureupstream
|
|
|
|
|
|
|
|
import (
|
2019-06-09 22:49:59 +00:00
|
|
|
networking "k8s.io/api/networking/v1beta1"
|
2020-08-08 23:31:02 +00:00
|
|
|
"k8s.io/klog/v2"
|
2016-11-16 18:24:26 +00:00
|
|
|
|
2017-11-07 22:02:12 +00:00
|
|
|
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
|
|
|
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
2016-06-01 18:47:37 +00:00
|
|
|
)
|
|
|
|
|
2017-11-07 16:36:51 +00:00
|
|
|
// Config describes SSL backend configuration
|
|
|
|
type Config struct {
|
2017-06-14 23:40:25 +00:00
|
|
|
CACert resolver.AuthSSLCert `json:"caCert"`
|
2017-05-14 22:14:27 +00:00
|
|
|
}
|
|
|
|
|
2016-12-29 20:02:06 +00:00
|
|
|
type su struct {
|
2017-11-08 20:58:57 +00:00
|
|
|
r resolver.Resolver
|
2016-12-29 20:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewParser creates a new secure upstream annotation parser
|
2017-11-08 20:58:57 +00:00
|
|
|
func NewParser(r resolver.Resolver) parser.IngressAnnotation {
|
|
|
|
return su{r}
|
2016-12-29 20:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parse parses the annotations contained in the ingress
|
2016-06-01 18:47:37 +00:00
|
|
|
// rule used to indicate if the upstream servers should use SSL
|
2019-10-18 09:36:00 +00:00
|
|
|
func (a su) Parse(ing *networking.Ingress) (secure interface{}, err error) {
|
|
|
|
if ca, _ := parser.GetStringAnnotation("secure-verify-ca-secret", ing); ca != "" {
|
2020-09-27 20:32:40 +00:00
|
|
|
klog.Warningf("NOTE! secure-verify-ca-secret is not suppored anymore. Please use proxy-ssl-secret instead")
|
2017-05-14 22:14:27 +00:00
|
|
|
}
|
2019-10-18 09:36:00 +00:00
|
|
|
return
|
2016-06-01 18:47:37 +00:00
|
|
|
}
|