Skip to content

Commit 14c0cab

Browse files
committed
DEV-15100: Check if is CLI or SDK before validating email
1 parent 01c2d72 commit 14c0cab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

oauthproxy.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ func (p *OAuthProxy) isValidAPIToken(req *http.Request) bool {
561561
for _, route := range p.tokenRoutes {
562562
if (route.method == "" || req.Method == route.method) && route.pathRegex.MatchString(req.URL.Path) {
563563
authHeader := req.Header.Get("Authorization")
564+
userAgent := req.Header.Get("User-Agent")
565+
564566
if len(authHeader) < 10 {
565567
return false
566568
}
@@ -591,7 +593,8 @@ func (p *OAuthProxy) isValidAPIToken(req *http.Request) bool {
591593

592594
capiPayload := strings.Split(string(plaintext), ":")
593595
capiEmail := capiPayload[0]
594-
if capiEmail != "" {
596+
isCliOrSdk := strings.HasPrefix(userAgent, "CnvrgCLI") || strings.HasPrefix(userAgent, "cnvrg")
597+
if capiEmail != "" && isCliOrSdk {
595598
data, err := ioutil.ReadAll(req.Body)
596599
if err != nil {
597600
return false

0 commit comments

Comments
 (0)