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

Add create secret git with bearer token #3536

Closed
darkowlzz opened this issue Jan 30, 2023 · 8 comments · Fixed by #3617
Closed

Add create secret git with bearer token #3536

darkowlzz opened this issue Jan 30, 2023 · 8 comments · Fixed by #3617
Labels
good first issue Good for newcomers

Comments

@darkowlzz
Copy link
Contributor

Support for using bearer token for git authentication was added in fluxcd/pkg#442.
flux create secret git command supports creating Secret for basic auth and ssh authentication. Add support for creating a Secret with bearer token.
Refer GitRepository docs for an example of the Secret to be created.

@darkowlzz darkowlzz added the good first issue Good for newcomers label Jan 30, 2023
@darkowlzz darkowlzz changed the title Add create secret git with bearer token Add create secret git with bearer token Jan 30, 2023
@patel-aum
Copy link

I can try this

@patel-aum
Copy link

hey can you explain what exactly is to be done I am confused.

@aryan9600
Copy link
Member

hey, we need to modify the flux create secret git command to accept bearer tokens when using http/https and create a secret out of it. the relevant code is in the file cmd/flux/create_secret_git.go. feel free to ask more questions if you need to :)

@Santosh1176
Copy link
Contributor

Santosh1176 commented Feb 14, 2023

Hey @aryan9600, I was looking at this and wanted to confirm, after the implementation the correct command for creating a git secret with a token while bearerToken option is enabled would be:

flux create secret git bearer-token-auth \
--url=https://github.com/stefanprodan/podinfo \
--bearerToken=<BASE64 Token> \
--namespace=my-namespace \
--export

@darkowlzz
Copy link
Contributor Author

@Santosh1176 that seems right.

@patel-aum are you still working on it? Do you need any help?
@Santosh1176 seems to also be interested in this. It'd be good to avoid multiple PRs for the same issue.

@Santosh1176
Copy link
Contributor

Thank you @darkowlzz. I've made some changes to create_secret_git.go and verifying the results in the tests file.
Currently, I am struck here:

=== RUN   TestCreateGitSecret/ssh_key_with_password
=== RUN   TestCreateGitSecret/https_with_bearer_token
    main_test.go:352: Mismatch from golden file 'testdata/create_secret/git/git-token-secret.yaml': Mismatch from expected value (-want +got):
          (
                """
                ... // 4 identical lines
                  name: podinfo-auth
                  namespace: frontend-api
        -       data:
        -         bearerToken: ghp_vaB2qnFE0O41WlucePL3udt2N9vVZK4R0hSN

I think the error is for not able to generate the data.bearerToken field. Any guidance on this would be helpful.

@patel-aum patel-aum removed their assignment Feb 15, 2023
@patel-aum
Copy link

patel-aum commented Feb 15, 2023

@Santosh1176 that seems right.

@patel-aum are you still working on it? Do you need any help? @Santosh1176 seems to also be interested in this. It'd be good to avoid multiple PRs for the same issue.

I have unassign myself as @Santosh1176 has demonstrated a clear understanding of the problem, while I am still in the process of figuring it out.

@darkowlzz
Copy link
Contributor Author

@patel-aum thanks.

@Santosh1176 It may be that the content of the golden file you created doesn't match with the actual output, maybe due to some white spaces or tabs. It'd be easier if you could share the code in a pull request and we can have a look.

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

Successfully merging a pull request may close this issue.

4 participants