Skip to content

Commit f8f0663

Browse files
author
yzamir
committed
add loggig
1 parent 0d70da6 commit f8f0663

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ kubectl get secrets -n kube-gateway -o json | jq '[.items[] | select(.metadata.n
145145
path=/apis/subresources.kubevirt.io/v1/namespaces/kube-gateway/virtualmachineinstances/testvm/vnc
146146

147147
# Create a token payload for accessing the API path for 1 hour, starting now
148-
data='{"URLs":["${path}"],"duration":"1h"}'
148+
data="{\"URLs\":[\"${path}\"],\"duration\":\"1h\"}"
149149
token=$(cat token) # Use a k8s token that can access the private key for signing the JWT
150150
proxyurl=https://192.168.39.134:30345 # Use the url of the gateway proxy
151151

pkg/token/validatetoken.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,15 @@ func ValidateToken(tokenStr string, publicKey *rsa.PublicKey, apiPath string, ht
5757
func validateRequest(httpMethod string, httpPath string, apiPAth string, verbs map[string]bool, patterns []string) error {
5858
// validate method
5959
if len(verbs) == 0 || len(patterns) == 0 {
60+
glog.Info("missing validation verbs or patterns")
61+
6062
return fmt.Errorf("missing validation verbs or patterns")
6163
}
6264

6365
// check for matching verb
6466
if _, ok := verbs[strings.ToLower(httpMethod)]; !ok {
67+
glog.Infof("%s method not allowedd", httpMethod)
68+
6569
return fmt.Errorf("%s method not allowedd", httpMethod)
6670
}
6771

@@ -86,6 +90,8 @@ func validateRequest(httpMethod string, httpPath string, apiPAth string, verbs m
8690
}
8791

8892
if !matchURL {
93+
glog.Infof("%s path not allowed", httpPath)
94+
8995
return fmt.Errorf("%s path not allowed", httpPath)
9096
}
9197

0 commit comments

Comments
 (0)