mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 01:47:33 +02:00
grpc: send client traffic through envoy (#2469)
* wip * wip * handle wildcards in override name * remove wait for ready, add comment about sync, force initial sync complete in test * address comments
This commit is contained in:
parent
87c3c675d2
commit
bbec2cae9f
26 changed files with 391 additions and 480 deletions
52
config/envoyconfig/tls.go
Normal file
52
config/envoyconfig/tls.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package envoyconfig
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
envoy_type_matcher_v3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3"
|
||||
)
|
||||
|
||||
func (b *Builder) buildSubjectAlternativeNameMatcher(
|
||||
dst *url.URL,
|
||||
overrideName string,
|
||||
) *envoy_type_matcher_v3.StringMatcher {
|
||||
sni := dst.Hostname()
|
||||
if overrideName != "" {
|
||||
sni = overrideName
|
||||
}
|
||||
|
||||
if strings.Contains(sni, "*") {
|
||||
pattern := regexp.QuoteMeta(sni)
|
||||
pattern = strings.Replace(pattern, "\\*", ".*", -1)
|
||||
return &envoy_type_matcher_v3.StringMatcher{
|
||||
MatchPattern: &envoy_type_matcher_v3.StringMatcher_SafeRegex{
|
||||
SafeRegex: &envoy_type_matcher_v3.RegexMatcher{
|
||||
EngineType: &envoy_type_matcher_v3.RegexMatcher_GoogleRe2{
|
||||
GoogleRe2: &envoy_type_matcher_v3.RegexMatcher_GoogleRE2{},
|
||||
},
|
||||
Regex: pattern,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return &envoy_type_matcher_v3.StringMatcher{
|
||||
MatchPattern: &envoy_type_matcher_v3.StringMatcher_Exact{
|
||||
Exact: sni,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Builder) buildSubjectNameIndication(
|
||||
dst *url.URL,
|
||||
overrideName string,
|
||||
) string {
|
||||
sni := dst.Hostname()
|
||||
if overrideName != "" {
|
||||
sni = overrideName
|
||||
}
|
||||
sni = strings.Replace(sni, "*", "example", -1)
|
||||
return sni
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue