From 6b662293e8714df4f858f5086bfd893a8f2d2aa4 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Tue, 5 May 2020 13:23:26 -0700 Subject: [PATCH] Revert "Rebased on upstream/master" This reverts commit 63eb55097a5b913311f7f1f2130094ff3d91798b. --- handlers/auth.go | 15 ++------------- pkg/cfg/cfg.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/handlers/auth.go b/handlers/auth.go index 7446fc24..3da5a751 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -1,8 +1,8 @@ /* Copyright 2020 The Vouch Proxy Authors. -Use of this source code is governed by The MIT License (MIT) that -can be found in the LICENSE file. Software distributed under The +Use of this source code is governed by The MIT License (MIT) that +can be found in the LICENSE file. Software distributed under The MIT License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -117,17 +117,6 @@ func verifyUser(u interface{}) (bool, error) { } return false, fmt.Errorf("verifyUser: user.Username not found in WhiteList: %s", user.Username) - // regexWhiteList - case len(cfg.CompiledRegexWhiteList) != 0: - for _, wl := range cfg.CompiledRegexWhiteList { - log.Debugf("Checking claim: '%v' against regex: '%v'", user.Username, wl) - if wl.MatchString(user.Username) { - log.Debugf("VerifyUser: Success! found user.Username in regexWhiteList: %s", user.Username) - return true, nil - } - } - return false, fmt.Errorf("VerifyUser: user.Username not found in regexWhiteList: %s", user.Username) - // TeamWhiteList case len(cfg.Cfg.TeamWhiteList) != 0: for _, team := range user.TeamMemberships { diff --git a/pkg/cfg/cfg.go b/pkg/cfg/cfg.go index 25a846fd..307685dc 100644 --- a/pkg/cfg/cfg.go +++ b/pkg/cfg/cfg.go @@ -1,8 +1,8 @@ /* Copyright 2020 The Vouch Proxy Authors. -Use of this source code is governed by The MIT License (MIT) that -can be found in the LICENSE file. Software distributed under The +Use of this source code is governed by The MIT License (MIT) that +can be found in the LICENSE file. Software distributed under The MIT License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -164,8 +164,8 @@ var ( Cfg = &Config{} // IsHealthCheck see main.go IsHealthCheck = false - // CompiledRegexWhiteList see auth.go - CompiledRegexWhiteList []*regexp.Regexp + // CompiledRegex see handlers.go + CompiledRegex []*regexp.Regexp ) type cmdLineFlags struct { @@ -395,18 +395,18 @@ func basicTest() error { if Cfg.Cookie.MaxAge > Cfg.JWT.MaxAge { return fmt.Errorf("configuration error: Cookie maxAge (%d) cannot be larger than the JWT maxAge (%d)", Cfg.Cookie.MaxAge, Cfg.JWT.MaxAge) } - // if using regexWhiteList, compile regex statements, and store them in cfg.CompiledRegexWhiteList + // if using regexWhiteList, compile regex statements, and store them in cfg.CompiledRegex if len(Cfg.RegexWhiteList) != 0 { for i, wl := range Cfg.RegexWhiteList { //generate regex array reWhiteList, reWhiteListErr := regexp.Compile(wl) if reWhiteListErr != nil { - return fmt.Fatalf("Uncompilable regex parameter: '%v'", wl) + return fmt.Errorf("Uncompilable regex parameter: '%v'", wl) } - CompiledRegexWhiteList = append(CompiledRegexWhiteList, reWhiteList) - log.Debugf("Compiled regex parameter '%v'", CompiledRegexWhiteList[i]) + CompiledRegex = append(CompiledRegex, reWhiteList) + log.Debugf("Compiled regex parameter '%v'", CompiledRegex[i]) } - log.Debugf("compiled regex array %v", CompiledRegexWhiteList) + log.Debugf("compiled regex array %v", CompiledRegex) } return nil }