Skip to content

Conversation

@aThorp96
Copy link
Member

@aThorp96 aThorp96 commented Jul 31, 2025

Changes

The header specified for the git resolver's http auth contained a typo
leading to authentication tokens not being properly sent to the remote.
This change fixes the typo in the header and also ensures the auth
setting is present for all git operations instead of just clone, since other
operations such as fetch may require remote authentication.

Additionally, this change fixes the outdated token-authenticated git
resolver example and adds an e2e regression test for authenticated git
cloning.

Resolves: #8940
Resolves: https://issues.redhat.com/browse/SRVKP-8260

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Bug fix: Before this change, there was a regression in which the git resolver was not authenticating with the provided `gitToken` and `gitTokenKey`, breaking the git resolver's http token-based auth. After this change, all git operations performed by the git resolver use the provided `gitToken` for remote authentication.

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 31, 2025
token := base64.URLEncoding.EncodeToString([]byte(repo.username + ":" + repo.password))
env = append(
env,
"GIT_AUTH_HEADER=Authorization: Basic "+token,
Copy link
Member Author

Choose a reason for hiding this comment

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

Authorization: Basic .... vs Authorization=Basic ... appears to have been the issue @vdemeester

}
}

func TestGitResolver_HTTPAuth(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

WIP regression test here

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@waveywaves
Copy link
Member

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 31, 2025
@aThorp96 aThorp96 force-pushed the git-resolver-http-auth-fix branch from acb78f0 to 7deb329 Compare August 1, 2025 16:27
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@aThorp96 aThorp96 force-pushed the git-resolver-http-auth-fix branch from 7deb329 to 41fdbc9 Compare August 1, 2025 18:40
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@aThorp96 aThorp96 force-pushed the git-resolver-http-auth-fix branch from 41fdbc9 to 217779c Compare August 1, 2025 19:11
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@aThorp96 aThorp96 force-pushed the git-resolver-http-auth-fix branch from cb051af to 63472b1 Compare August 2, 2025 17:14
The header specified for the git resolver's http auth contained a typo
leading to authentication tokens not being properly sent to the remote.

Additionally, this change fixes the outdated token-authenticated git
resolver example and adds an e2e regression test for authenticated git
cloning.

Resolves: tektoncd#8940
Resolves: https://issues.redhat.com/browse/SRVKP-8260
@aThorp96 aThorp96 force-pushed the git-resolver-http-auth-fix branch from 63472b1 to e25050f Compare August 2, 2025 17:18
@aThorp96 aThorp96 changed the title Fix http authentication for git resolver fix(#8940): token-authentication header typo in git resolver Aug 2, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/git/repository.go 84.9% 84.6% -0.3

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesnt merit a release note. labels Aug 2, 2025
@aThorp96 aThorp96 marked this pull request as ready for review August 2, 2025 17:26
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 2, 2025
Comment on lines -702 to +755
scmTokenSecretKey: []byte(base64.StdEncoding.Strict().EncodeToString([]byte(token))),
scmTokenSecretKey: []byte(token),
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why this was base64 encoded on the application side. When I made the gitea repo private, API auth also broke until I removed this base64 encoding. I think it was mistakenly though to be required, however the base64 encoding looks to be happening server-side after the secret is created.

@aThorp96
Copy link
Member Author

aThorp96 commented Aug 2, 2025

/cc @waveywaves

@tekton-robot tekton-robot requested a review from waveywaves August 2, 2025 17:38
@mbpavan
Copy link

mbpavan commented Aug 4, 2025

/retest

1 similar comment
@waveywaves
Copy link
Member

/retest

@chmouel
Copy link
Member

chmouel commented Aug 4, 2025

/lgtm

but consider the renaming issue

@tekton-robot
Copy link
Collaborator

@chmouel: changing LGTM is restricted to collaborators

In response to this:

/lgtm

but consider the renaming issue

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.


_, _, err = giteaClient.CreateOrgRepo(scmRemoteOrg, gitea.CreateRepoOption{
Name: scmRemoteRepo,
Private: true,
Copy link
Member

Choose a reason for hiding this comment

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

👍

@waveywaves
Copy link
Member

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2025
@waveywaves
Copy link
Member

@vdemeester, will wait for the last lgtm from you. Once this is in, we will make sure to cherry-pick it to 1.0.x.

/cherry-pick release-v1.0.x

@tekton-robot
Copy link
Collaborator

@waveywaves: once the present PR merges, I will cherry-pick it on top of release-v1.0.x in a new PR and assign it to you.

In response to this:

@vdemeester, will wait for the last lgtm from you. Once this is in, we will make sure to cherry-pick it to 1.0.x.

/cherry-pick release-v1.0.x

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2025
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester, waveywaves

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [vdemeester,waveywaves]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot merged commit cbc6c14 into tektoncd:main Aug 4, 2025
48 of 50 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Tekton Community Roadmap Aug 4, 2025
@tekton-robot
Copy link
Collaborator

@waveywaves: new pull request created: #8941

In response to this:

@vdemeester, will wait for the last lgtm from you. Once this is in, we will make sure to cherry-pick it to 1.0.x.

/cherry-pick release-v1.0.x

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@chmouel
Copy link
Member

chmouel commented Aug 4, 2025

I don't think my comment about renaming field without a migration plan was addressed before merging...

(and it doesn't encourage to do any reviews on tektoncd/pipeline tbh)

@waveywaves
Copy link
Member

@chmouel yes, I didn't see it addressed as well. I will see it addressed and also have the necessary change cherry picked as well as required. Guess the comment got glossed over in the interest of getting this fix through.

@aThorp96
Copy link
Member Author

aThorp96 commented Aug 4, 2025

I don't think my comment about renaming field without a migration plan was addressed before merging...

@chmouel Sorry for not addressing your comment properly. There is no user action or migration necessary and no fields have changed in this PR. The example's field was corrected, since it was using the api auth fields with a non-api git resolution request, but the way the git resolver is used remains the same in this change.

@waveywaves
Copy link
Member

@aThorp96 we need to backport this to versions of tekton where this fix is needed. I have already created a cherry pick for 1.0.x, creating more for 1.1.x and 1.2.x and this is already in 1.3.x. Let me know if you could look into the cherry picks and see if it would be possible for you to review them. Would appreciate it. I can take a look at them later.

@waveywaves
Copy link
Member

/cherry-pick release-v1.1.x

@waveywaves
Copy link
Member

/cherry-pick release-v1.2.x

@tekton-robot
Copy link
Collaborator

@waveywaves: new pull request created: #8946

In response to this:

/cherry-pick release-v1.1.x

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot
Copy link
Collaborator

@waveywaves: #8937 failed to apply on top of branch "release-v1.2.x":

Patch is empty.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-v1.2.x

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Regression: gitToken and gitTokenKey not working with git resolver

6 participants