From f2210f07be10a02f0b396c1cdca6dd8efaa717f3 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Mon, 15 Apr 2024 16:36:40 -0400 Subject: [PATCH] Fixup no custom claims --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b486547..8d3d8c7 100644 --- a/main.go +++ b/main.go @@ -57,9 +57,9 @@ func Rollout(w http.ResponseWriter, r *http.Request) { return } - if claims, ok := token.Claims.(jwt.MapClaims); ok { - ccStr := os.Getenv("CUSTOM_CLAIMS") - log.Println(ccStr) + ccStr := os.Getenv("CUSTOM_CLAIMS") + claims, ok := token.Claims.(jwt.MapClaims) + if ok && ccStr != "" { var cc map[string]string err = json.Unmarshal([]byte(ccStr), &cc) if err != nil { @@ -74,7 +74,7 @@ func Rollout(w http.ResponseWriter, r *http.Request) { return } } - } else { + } else if !ok { log.Println("Unable to read token claims for", realIp, ",", lastIP) http.Error(w, "Invalid token", http.StatusUnauthorized) return