add support for auth-snippet annotation

add test for new auth-snippet annotation

document auth-snippet annotation

add e2e test for auth-snippet annotation

add log warning and update documentation
This commit is contained in:
Adnan Baruni 2018-10-29 16:34:44 -05:00
parent 38f5df26cb
commit b511333130
5 changed files with 80 additions and 11 deletions

View file

@ -21,6 +21,8 @@ import (
"regexp"
"strings"
"github.com/golang/glog"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
@ -37,6 +39,7 @@ type Config struct {
Method string `json:"method"`
ResponseHeaders []string `json:"responseHeaders,omitempty"`
RequestRedirect string `json:"requestRedirect"`
AuthSnippet string `json:"authSnippet"`
}
// Equal tests for equality between two Config types
@ -74,6 +77,9 @@ func (e1 *Config) Equal(e2 *Config) bool {
if e1.RequestRedirect != e2.RequestRedirect {
return false
}
if e1.AuthSnippet != e2.AuthSnippet {
return false
}
return true
}
@ -141,7 +147,15 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
}
// Optional Parameters
signIn, _ := parser.GetStringAnnotation("auth-signin", ing)
signIn, err := parser.GetStringAnnotation("auth-signin", ing)
if err != nil {
glog.Warning("auth-signin annotation is undefined and will not be set")
}
authSnippet, err := parser.GetStringAnnotation("auth-snippet", ing)
if err != nil {
glog.Warning("auth-snippet annotation is undefined and will not be set")
}
responseHeaders := []string{}
hstr, _ := parser.GetStringAnnotation("auth-response-headers", ing)
@ -167,5 +181,6 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
Method: authMethod,
ResponseHeaders: responseHeaders,
RequestRedirect: requestRedirect,
AuthSnippet: authSnippet,
}, nil
}