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

オープン 初心者向け
#429 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, gitlab, go

調査の方向性

pkg/engine/config.go の、リモート設定リクエストを構築し、Authorization と Accept ヘッダーを gitAuth.envSecret から設定するコードから始めてください。スキームを Bearer に切り替える前に、GitHub 固有の Accept: application/vnd.github.v3+json ヘッダーが GitLab で必須ではないことを確認し、同じパッケージ内のリモート設定ダウンロードに関する既存のテストを確認してください。完了とは、レポートの GitLab URL が PAT で 200 を返し、既存の GitHub パスが引き続き動作することを意味します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
178
フォーク
25
平均マージ
1日 2時間
マージ済み PR(30日)
2

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

containers/fetchit のほかの issue

containers/fetchit の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。