Remote configuration download fails with GitLab due to hardcoded propietary PAT authentication scheme

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

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

Đánh giá

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

Hướng nghiên cứu

Bắt đầu trong pkg/engine/config.go tại đoạn mã dựng yêu cầu cấu hình từ xa và đặt các header Authorization và Accept từ gitAuth.envSecret. Xác nhận rằng header dành riêng cho GitHub Accept: application/vnd.github.v3+json không bắt buộc với GitLab trước khi chuyển cơ chế sang Bearer, và kiểm tra các test hiện có liên quan đến tải cấu hình từ xa trong cùng package. Hoàn thành nghĩa là URL GitLab từ báo cáo trả về 200 với PAT và đường dẫn GitHub hiện có vẫn hoạt động.

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

Mô tả

FetchIt fails to download remote configuration files hosted in private GitLab repositories when using PAT authentication through gitAuth.envSecret.

The current implementation in pkg/engine/config.go uses a GitHub-specific authorization scheme:

req.Header.Add("Authorization", "token "+pat)
req.Header.Add("Accept", "application/vnd.github.v3+json")

GitLab supports Authorization: Bearer and PRIVATE-TOKEN headers for access token authentication through its REST API.

Steps to reproduce
  1. Create a private GitLab repository containing a FetchIt configuration file.
  2. Generate an access token with read_repository permissions.
  3. Expose the token to FetchIt using a Podman secret:
Secret=gitlab_token,type=env,target=GITLAB_TOKEN
  1. Configure FetchIt to reload its configuration using the GitLab repository files API:
gitAuth:
  envSecret: GITLAB_TOKEN

configReload:
  schedule: "*/1 * * * *"
  configUrl: "https://gitlab.example.com/api/v4/projects/123/repository/files/config%2Ffetchit.yaml/raw?ref=main"
Actual behavior

The remote configuration download fails.

The issue can be reproduced independently of FetchIt using curl against the same URL with the same access token.

Authentication header HTTP response
Authorization: token <PAT> 404
Authorization: Bearer <PAT> 200
PRIVATE-TOKEN: <PAT> 200

Both successful requests return the expected YAML configuration.

The HTTP 404 response appears to be caused by GitLab concealing the existence of an inaccessible private resource rather than by an incorrect URL.

Expected behavior

FetchIt should support authenticated remote configuration downloads from Git providers other than GitHub, including GitLab.

Suggested solution

Replace the GitHub-specific token authentication scheme
with the standardized Bearer authentication scheme:

- req.Header.Add("Authorization", "token "+pat)
+ req.Header.Add("Authorization", "Bearer "+pat)

Bearer authentication is defined in RFC 6750 and is
supported by both GitHub and GitLab.

GitHub's official REST API documentation explicitly supports
both Bearer and token authentication schemes.

This change would improve interoperability without introducing
additional configuration options or provider-specific logic..

References
Scope

This issue concerns HTTP authentication for remote configuration downloads, not Git repository clone or fetch operations.

Ngôn ngữ chính
Go
Star
178
Fork
25
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
2

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

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 containers/fetchit

Tất cả issue của containers/fetchit

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.