proxy: disable control-plane robots.txt for public unauthenticated routes (#1361)

This commit is contained in:
Caleb Doxsey 2020-09-02 07:56:15 -06:00 committed by GitHub
parent f6b622c7dc
commit a269441c34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 176 additions and 198 deletions

View file

@ -6,7 +6,6 @@ import (
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strings"
"github.com/golang/protobuf/ptypes"
@ -243,34 +242,9 @@ func (a *Authorize) getMatchingPolicy(requestURL *url.URL) *config.Policy {
options := a.currentOptions.Load()
for _, p := range options.Policies {
if p.Source == nil {
continue
if p.Matches(requestURL) {
return &p
}
if p.Source.Host != requestURL.Host {
continue
}
if p.Prefix != "" {
if !strings.HasPrefix(requestURL.Path, p.Prefix) {
continue
}
}
if p.Path != "" {
if requestURL.Path != p.Path {
continue
}
}
if p.Regex != "" {
re, err := regexp.Compile(p.Regex)
if err == nil && !re.MatchString(requestURL.String()) {
continue
}
}
return &p
}
return nil