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

未关闭 适合新手
#429 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
github, gitlab, go

调研方向

从 pkg/engine/config.go 中构建远程配置请求并设置 Authorization 和 Accept 头(值来自 gitAuth.envSecret)的代码开始。在将认证方案切换为 Bearer 之前,确认 GitLab 不需要 GitHub 专用的 Accept: application/vnd.github.v3+json 头,并检查同一个包中与远程配置下载相关的现有测试。完成意味着报告中的 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 小时
30 天内合并 PR
2

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

containers/fetchit 的其他 Issue

查看 containers/fetchit 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。