google / google/go-github

WithAuthToken authorizes requests outside configured hosts

Đang mở
#4,366 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
11.3k
Fork
2.5k
Merge trung bình
1 ngày 20 giờ
Pull request đã merge (30 ngày)
52

Mô tả

## Summary

`WithAuthToken` installs a transport wrapper that adds `Authorization: Bearer ` to outgoing requests. When callers build a request with an absolute URL outside the client's configured API or upload origins, that wrapper still adds the bearer token before sending the request.

## Expected behavior

The token configured through `WithAuthToken` should only be attached to requests targeting the client's configured API or upload origins. Requests to other origins should be sent without this transport-managed authorization header.

## Reproduction

This can be reproduced with `httptest` servers by configuring a client with trusted API/upload URLs, then issuing requests using absolute URLs for another server and checking whether that server receives an `Authorization` header.

## Proposed fix

PR #4363 limits token injection to the configured API and upload origins, and includes regression coverage for trusted API/upload requests and cross-host absolute URL requests.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với wrapper transport WithAuthToken và đường dẫn request mà nó sử dụng cho các URL tuyệt đối. Tái hiện hành vi bằng các máy chủ httptest được cấu hình cho các origin API/upload đáng tin cậy và một origin riêng biệt, sau đó xác minh rằng các request đáng tin cậy vẫn giữ authorization trong khi các request qua host khác không giữ authorization. PR #4363 và phần kiểm thử hồi quy tương ứng mô tả công việc đã được đề xuất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
api, security
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.