authn: the insecure JWKS transport ignores proxy env vars and DefaultTransport's defaults

Đang mở Phù hợp với người mới
#153 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu bằng cách đọc authn/manager.go, đặc biệt là phần thiết lập transport của NewManager được hiển thị trong issue. Kiểm tra các bài kiểm thử của gói authn và bổ sung hoặc cập nhật độ bao phủ cho đường dẫn TLS không an toàn. Công việc được xem là hoàn tất khi đường dẫn đó giữ nguyên hành vi transport mặc định, bao gồm hỗ trợ các biến môi trường proxy, đồng thời áp dụng cài đặt TLS được yêu cầu.

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

Mô tả

Found while migrating nsw-agency from a forked copy of this package to core/authn v0.3.0 (OpenNSW/nsw-agency#213).

What

NewManager builds a bare http.Transport when InsecureSkipTLSVerify is set — authn/manager.go:

httpClient := &http.Client{Timeout: 10 * time.Second}
if authConfig.InsecureSkipTLSVerify {
    httpClient.Transport = &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }
}

A zero-valued http.Transport has Proxy == nil, so it ignores HTTP_PROXY/HTTPS_PROXY/NO_PROXY, and it also drops http.DefaultTransport's connection-pool and dial defaults (MaxIdleConns, IdleConnTimeout, TLSHandshakeTimeout, HTTP/2 via ForceAttemptHTTP2).

In a dev environment where the IdP is only reachable through a proxy, the JWKS fetch fails and every token is rejected, with nothing in the error to suggest the proxy was bypassed.

Suggested fix

Clone the default transport instead of replacing it, which is what the code this package replaced in nsw-agency did:

if authConfig.InsecureSkipTLSVerify {
    if tr, ok := http.DefaultTransport.(*http.Transport); ok {
        customTransport := tr.Clone()
        customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec
        httpClient.Transport = customTransport
    }
}

Scope

InsecureSkipTLSVerify is gated to development in nsw-agency (it refuses to start unless APP_ENV=development), so the secure path is unaffected — the default nil transport already resolves to http.DefaultTransport. This only bites the dev/self-signed path.

Ngôn ngữ chính
Go
Star
6
Fork
8
Merge trung bình
21 giờ 36 phút
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenNSW/core

Tất cả issue của OpenNSW/core

Issue tương tự

Thêm issue về Go

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.