Adding the ability to use incomplete host names (non-FQDN) in 'auth-url' annotation.
This commit is contained in:
parent
935a5ef2c8
commit
8f3eae699d
1 changed files with 13 additions and 0 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package authreq
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -135,6 +136,18 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
return nil, ing_errors.NewLocationDenied("invalid url host")
|
||||
}
|
||||
|
||||
// The hostname can be partial, retrieving FQDN.
|
||||
fqdn, err := net.LookupCNAME(authUrl.Hostname())
|
||||
if err == nil {
|
||||
fqdn = strings.TrimRight(fqdn, ".")
|
||||
if port := authUrl.Port(); port != "" {
|
||||
authUrl.Host = net.JoinHostPort(fqdn, port)
|
||||
} else {
|
||||
authUrl.Host = fqdn
|
||||
}
|
||||
urlString = authUrl.String()
|
||||
}
|
||||
|
||||
authMethod, _ := parser.GetStringAnnotation("auth-method", ing)
|
||||
if len(authMethod) != 0 && !validMethod(authMethod) {
|
||||
return nil, ing_errors.NewLocationDenied("invalid HTTP method")
|
||||
|
|
Loading…
Reference in a new issue