Skip to content

feat: add bearer token support for http sync.go#435

Open
husira wants to merge 4 commits intocarvel-dev:developfrom
husira:develop
Open

feat: add bearer token support for http sync.go#435
husira wants to merge 4 commits intocarvel-dev:developfrom
husira:develop

Conversation

@husira
Copy link
Copy Markdown

@husira husira commented Dec 26, 2025

This PR adds Bearer token authentication support to vendir sync (http) command:

In addition to existing HTTP Basic Auth (username / password), users can now authenticate using a Bearer token provided via secretRef.

Exactly one authentication method is allowed per secret:
• username + password → HTTP Basic Auth
• token → Authorization: Bearer

Mixed or incomplete credentials are rejected with clear validation errors.

We are using vendir to sync files from JFrog Artifactory. Our organization enforces authentication via access tokens instead of username/password. The authentication with JFrog Artifactory is implemented using Bearer tokens.

# use of username / password
apiVersion: v1
kind: Secret
metadata:
  name: secret-ref
data:
  username: dXNlcm5hbWU=
  password: cGFzc3dvcmQ=
---
apiVersion: vendir.k14s.io/v1alpha1
kind: Config
directories:
  - path: <path>
    contents:
    - path: "."
      http:
        url: https://<url>
        secretRef:
          name: secret-ref
# use of token
apiVersion: v1
kind: Secret
metadata:
  name: secret-ref
data:
  token: dG9rZW4=
---
apiVersion: vendir.k14s.io/v1alpha1
kind: Config
directories:
  - path: <path>
    contents:
    - path: "."
      http:
        url: https://<url>
        secretRef:
          name: secret-ref

I could successfully test the implementation with our registry (JFrog Artifactory) using username/password or a Bearer token.

Signed-off-by: Raphael Husistein <raphael.husistein@hotmail.com>
@husira husira changed the title feat: add bearer token support for sync.go feat: add bearer token support for http sync.go Dec 26, 2025
Copy link
Copy Markdown
Member

@joaopapereira joaopapereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Sorry for the very very late reply but this PR felt out of my radar :(
Thanks for creating this PR.

I have some comments that would like for you to address in order to move forward with this PR
Thanks

Comment thread pkg/vendir/fetch/http/sync.go Outdated
Comment thread pkg/vendir/fetch/http/sync.go Outdated
Comment thread pkg/vendir/fetch/http/sync_test.go Outdated
Comment thread pkg/vendir/fetch/http/sync_test.go Outdated
@github-project-automation github-project-automation bot moved this to In Progress in Carvel Feb 3, 2026
@husira
Copy link
Copy Markdown
Author

husira commented Feb 16, 2026

Hey @joaopapereira

Thank you for the updates!

I am currently traveling until mid-April. Therefore, I am unable to continue working on it at this time.

@patrickmx, Do you find time to take a look at this?

Copilot AI review requested due to automatic review settings April 14, 2026 14:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Bearer-token authentication support for vendir sync HTTP fetches via secretRef, alongside existing HTTP Basic Auth, with validation to reject mixed/incomplete credentials.

Changes:

  • Accept token in HTTP auth secrets and set Authorization: Bearer <token>.
  • Add stricter validation for basic-auth pairing (username/password) and disallow mixing with token auth.
  • Introduce HTTP auth-focused unit tests (basic, bearer, and invalid combinations).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/vendir/fetch/http/sync.go Adds bearer token support and credential validation in addAuth.
pkg/vendir/fetch/http/sync_test.go Adds unit tests covering basic auth, bearer token, and invalid credential combinations.
pkg/vendir/config/data.go Defines the token secret key constant used by HTTP auth.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vendir/fetch/http/sync.go
Comment thread pkg/vendir/fetch/http/sync.go
Comment thread pkg/vendir/fetch/http/sync_test.go Outdated
Comment thread pkg/vendir/fetch/http/sync_test.go Outdated
husira added 2 commits April 14, 2026 17:52
….go to keep the tests consistent through the project

Signed-off-by: Raphael Husistein <raphael.husistein@hotmail.com>
Signed-off-by: Raphael Husistein <raphael.husistein@hotmail.com>
Copilot AI review requested due to automatic review settings April 14, 2026 16:24
@husira
Copy link
Copy Markdown
Author

husira commented Apr 14, 2026

Hey @joaopapereira

I'm back after a longer vacation :) Thank you again for the review!

I have implemented the changes you suggested and tried to make the sync_test.go file consistent with other test files from the project.

Could you please review my changes again?

Thank you very much and I hope the PR can be merged soon.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vendir/fetch/http/sync.go
Comment thread pkg/vendir/fetch/http/sync_test.go
Comment thread pkg/vendir/fetch/http/sync_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants