Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bearer token auth #21462

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

reggie-k
Copy link
Member

@reggie-k reggie-k commented Jan 12, 2025

Closes #9667

The PR is adding a new param, BearerToken, it can be used when the Bearer Auth is needed instead of Basic Auth, like for example for BitBucket Project token, which requires Bearer Auth.

The relevant docs, CLI and UI changes are also present, along with unit tests.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@reggie-k reggie-k requested review from a team as code owners January 12, 2025 15:56
Copy link

bunnyshell bot commented Jan 12, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@reggie-k
Copy link
Member Author

reggie-k commented Jan 12, 2025

Attaching screenshot with the new parameter visible in the UI:

Screenshot 2025-01-12 at 17 58 32

Copy link

codecov bot commented Jan 12, 2025

Codecov Report

Attention: Patch coverage is 52.54237% with 28 lines in your changes missing coverage. Please review.

Project coverage is 55.30%. Comparing base (c3600d2) to head (a08b018).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
cmd/argocd/commands/repocreds.go 23.07% 9 Missing and 1 partial ⚠️
cmd/argocd/commands/admin/repo.go 18.18% 8 Missing and 1 partial ⚠️
cmd/argocd/commands/repo.go 22.22% 6 Missing and 1 partial ⚠️
cmd/util/repo.go 0.00% 1 Missing ⚠️
server/repository/repository.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21462      +/-   ##
==========================================
+ Coverage   55.21%   55.30%   +0.08%     
==========================================
  Files         337      337              
  Lines       56840    56903      +63     
==========================================
+ Hits        31387    31470      +83     
+ Misses      22757    22751       -6     
+ Partials     2696     2682      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@reggie-k
Copy link
Member Author

reggie-k commented Jan 16, 2025

Following he discussion in the contributors meeting, bearer token auth is only relevant for Git repos at this point, so I will add CLI changes that display a not supported message if used with Helm repo, and a UI change that would not display this field for Helm repo.

@reggie-k reggie-k marked this pull request as draft January 17, 2025 22:14
@reggie-k reggie-k closed this Jan 17, 2025
Signed-off-by: reggie-k <[email protected]>
@reggie-k reggie-k reopened this Jan 17, 2025
Copy link

bunnyshell bot commented Jan 17, 2025

✅ Preview Environment deployed on Bunnyshell

Component Endpoints
argocd https://argocd-a62fws.bunnyenv.com/
argocd-ttyd https://argocd-web-cli-a62fws.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@reggie-k reggie-k marked this pull request as ready for review January 17, 2025 23:37
@reggie-k
Copy link
Member Author

reggie-k commented Jan 17, 2025

CLI and UI are now enforcing that the bearer token can be passed only for Git repositories (on the backend side, there is one struct with all the possible params so impossible to separate). The field is not displayed for HTTPS Helm repos, only for Git ones.

Signed-off-by: reggie-k <[email protected]>
cmd/util/common.go Outdated Show resolved Hide resolved
@@ -34,6 +34,7 @@ func AddRepoFlags(command *cobra.Command, opts *RepoOptions) {
command.Flags().StringVar(&opts.Repo.Project, "project", "", "project of the repository")
command.Flags().StringVar(&opts.Repo.Username, "username", "", "username to the repository")
command.Flags().StringVar(&opts.Repo.Password, "password", "", "password to the repository")
command.Flags().StringVar(&opts.Repo.BearerToken, "bearer-token", "", "bearer token to the Git repository")
Copy link
Member

Choose a reason for hiding this comment

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

should we change it to bearer token to the repository, so it will be consistent with username and password?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is on purpose, since It is only relevant for Git, at least at the moment. When support for Helm would be added, this would be a good time to make it consistent.

@pasha-codefresh
Copy link
Member

Left few small comments, also will do manual QA and will let you know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bearer Authentication for Git Repos (enabled Bitbucket repository HTTP access tokens)
2 participants