Skip to content

Commit 07541bb

Browse files
authored
Merge pull request #1130 from rumpl/fix-no-www-auth
Return an error if www-auth resource retuns unexpected status code
2 parents 5bc9724 + c3583e9 commit 07541bb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/tools/mcp/oauth.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ func (t *oauthTransport) handleManagedOAuthFlow(ctx context.Context, authServer,
243243
defer resp.Body.Close()
244244

245245
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNotFound {
246-
return err
246+
_, _ = io.ReadAll(resp.Body)
247+
return errors.New("failed to fetch protected resource metadata")
247248
}
248249
var resourceMetadata protectedResourceMetadata
249250
if resp.StatusCode == http.StatusOK {
@@ -390,7 +391,8 @@ func (t *oauthTransport) handleUnmanagedOAuthFlow(ctx context.Context, authServe
390391
defer resp.Body.Close()
391392

392393
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNotFound {
393-
return err
394+
_, _ = io.ReadAll(resp.Body)
395+
return errors.New("failed to fetch protected resource metadata")
394396
}
395397
var resourceMetadata protectedResourceMetadata
396398
if resp.StatusCode == http.StatusOK {

0 commit comments

Comments
 (0)