Add support for new policy conditions (#7024)

This PR implements following condition types

- StringEqualsIgnoreCase and StringNotEqualsIgnoreCase
- BinaryEquals
This commit is contained in:
Harshavardhana
2018-12-26 17:39:30 -08:00
committed by GitHub
parent 2db22deb93
commit 4e4f855b30
14 changed files with 1593 additions and 62 deletions

View File

@@ -20,6 +20,7 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"
"path"
"strings"
@@ -183,7 +184,12 @@ func NewPolicySys() *PolicySys {
}
func getConditionValues(request *http.Request, locationConstraint string) map[string][]string {
args := make(map[string][]string)
args := map[string][]string{
"SourceIp": {handlers.GetSourceIP(request)},
"SecureTransport": {fmt.Sprintf("%t", request.TLS != nil)},
"UserAgent": {request.UserAgent()},
"Referer": {request.Referer()},
}
for key, values := range request.Header {
if existingValues, found := args[key]; found {
@@ -201,8 +207,6 @@ func getConditionValues(request *http.Request, locationConstraint string) map[st
}
}
args["SourceIp"] = []string{handlers.GetSourceIP(request)}
if locationConstraint != "" {
args["LocationConstraint"] = []string{locationConstraint}
}