Преглед изворни кода

fix(oauth2): check HTTP status from Google userinfo endpoint

Frédéric Guillot пре 1 недеља
родитељ
комит
1d4ca6a6bc
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      internal/oauth2/google.go

+ 4 - 0
internal/oauth2/google.go

@@ -59,6 +59,10 @@ func (g *googleProvider) GetProfile(ctx context.Context, code, codeVerifier stri
 	}
 	defer resp.Body.Close()
 
+	if resp.StatusCode != 200 {
+		return nil, fmt.Errorf("google: unexpected status code %d from userinfo endpoint", resp.StatusCode)
+	}
+
 	var user googleProfile
 	decoder := json.NewDecoder(resp.Body)
 	if err := decoder.Decode(&user); err != nil {