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: allow connecting to HTTP Git repositories #1504

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

hiddeco
Copy link
Contributor

@hiddeco hiddeco commented Feb 21, 2024

Fixes: #872

This adds support for connecting to Git repositories over an (insecure) HTTP wire as described in #872 (comment), while taking into account the effect it would have on HTTP Helm repositories as observed in #872 (comment).

Effectively, this means that connecting to any HTTP endpoint is now allowed as long as this does not require authentication. This includes "classic" Helm repositories served over HTTP, where basic authentication used to be supported in the past.

In preparation of allowing insecure (non-TLS) HTTP endpoints for
Git URLs. Which we do want to allow to connect to  e.g. local
(development) servers, but without ever passing credentials to them.

To not introduce breaking changes for HTTP Helm repositories which
at present appear to allow passing basic auth credentials over
an insecure wire, we specifically check for the type to equal Git
before bailing. If we decide this is actually undesired behavior,
it can easily be removed.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Copy link

netlify bot commented Feb 21, 2024

Deploy Preview for docs-kargo-akuity-io ready!

Name Link
🔨 Latest commit 4f5d397
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-akuity-io/deploys/65d639717fc43300086a76b9
😎 Deploy Preview https://deploy-preview-1504.kargo.akuity.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

This widens the refusal to an HTTP endpoint for _any_ type, which
at present includes "classic" Helm repository HTTP endpoints.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
@krancour krancour added this to the v0.5.0 milestone Feb 21, 2024
Copy link
Member

@krancour krancour left a comment

Choose a reason for hiding this comment

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

🔥

@hiddeco hiddeco added this pull request to the merge queue Feb 21, 2024
Merged via the queue into akuity:main with commit a56a8d4 Feb 21, 2024
15 checks passed
@hiddeco hiddeco deleted the insecure-git-http branch February 21, 2024 18:17
@geowalrus4gh
Copy link

waiting for v0.5.0 🤞

@krancour
Copy link
Member

@geowalrus4gh we build nightlies. Feel free to use the latest.

@geowalrus4gh
Copy link

tried the latest [0.4.1-unstable-20240223] but getting the below error
spec.promotionMechanisms.gitRepoUpdates[0].repoURL in body should match '^https://(\w+([\.-]\w+)*@)?\w+([\.-]\w+)*(:[\d]+)?(/.*)?$',

@hiddeco
Copy link
Contributor Author

hiddeco commented Feb 23, 2024

Did you also update the CustomResourceDefinitions on the cluster to match the changed regular expression?

@geowalrus4gh
Copy link

geowalrus4gh commented Feb 23, 2024

Yes, I installed a fresh Kargo helm installation after deleting old CRDs. Here is the extract from the new Warehouse CRD installed.
repoURL: description: URL is the repository's URL. This is a required field. minLength: 1 pattern: ^https?://(\w+([\.-]\w+)*@)?\w+([\.-]\w+)*(:[\d]+)?(/.*)?$
Used helm chart is kargo-charts-unstable version 0.4.1-unstable-20240223

@krancour
Copy link
Member

@geowalrus4gh what is the command you used to apply? Did you use kubectl or kargo CLI?

@geowalrus4gh
Copy link

geowalrus4gh commented Feb 24, 2024

i used helm command to install.
helm upgrade --install kargo --create-namespace -n kargo oci://<harbor-url>/ghcr/akuity/kargo-charts-unstable/kargo --version 0.4.1-unstable-20240223 -f values.yaml --wait

I copied the crds from the github and applied, then it worked.

But now am getting an authentication failed error.
Also, there is a warning shown like this

time="2024-02-24T10:14:06Z" level=warning msg="refused to get credentials for insecure HTTP endpoint" freight=a508d8e8281d5b453cb4719f2e9f1b47c6f2afd9 namespace=sample-kargo promotion=dev.01hqd9q685kx5fmnw1t42jdcgf.a508d8e repoURL="http://bitbucket.company.com/scm/samp/sample-env.git" stage=dev

Does that mean, the repo secret for the http URL is not being read by kargo?

@krancour
Copy link
Member

That is correct. It was a compromise we arrived at in order to support unsecured connections -- we won't pass credentials over them.

@tal-hason
Copy link
Contributor

@krancour, How are you doing?

I didn't fully understand what that meant?!

if I want to use a HTTP git repo the Kargo Controller will not use the creds stored in the secret.
so how will it do a push to the remote!?

@krancour
Copy link
Member

Hey @tal-hason, good to hear from you!

if I want to use a HTTP git repo the Kargo Controller will not use the creds stored in the secret.

Making sure you spotted the missing "S". (Easy to overlook.) This is strictly for HTTP and not HTTPS. Kargo is refusing to pass credentials over an unsecure connection.

Practically speaking, this shouldn't be much of a limitation. The only time I can think of where you would conceivably access a repo over an unsecure connection would be during local development, in which case you can just skip the creds entirely and configure the repo to allow pushes without authenticating.

@tal-hason
Copy link
Contributor

Hi @krancour ,

Everything is awesome 😎.

Hope you are good to.

Soooo, I didn't miss the "S" in the HTTP.

I have a customer that we are trying to implement Kargo.

They have their own local disconnected bitbucket git, they are running it unsecured, but you must authenticate before pushing any changes to the repo.

So to not use the defined cerds, is a bit miss.

Also, you don't have to pass the creds in the HTTP url.

Store it in the .gitconfig and in the .git-credentails and the git will use it.

Also it is possible to add an use unsecure connection, with a note that this is not recommended. And let the customer decided what best for him.

But to disable it totally, it over controlling, don't be apple 😜

@krancour
Copy link
Member

krancour commented Jun 24, 2024

Also, you don't have to pass the creds in the HTTP url.

Store it in the .gitconfig and in the .git-credentails and the git will use it.

Well, both of these are technically true. The credentials are passed as a header. And on an insecure connection the header is perfectly accessible to anyone or anything reading the request. This is exactly why the decision was made in the first place to disallow the use of creds over an unsecure connection. After even a single use, you have to assume the credentials could have been compromised.

At the time we made that decision, there was some precedent for it (or so we thought?), as we could recall kubectl disallowing the use of credentials over an unsecure connection. Just now, I've been searching for any reference to that and keep coming up empty-handed, perhaps partly because as far back as v1.22.0, unsecure connections to the API server aren't even possible. So if our recollection was correct, it was in the distant past and since then, if anything, Kubernetes has moved in a more dogmatically secure-by-default direction.

Anyway -- that's all background.

We discussed at our team meeting this morning and all agreed that we will consider adding this as some kind of highly discouraged option in the future if we hear of more users / use cases that require this. Even as an opt-in, we don't want to relax security if this use case is an extreme outlier.

Please feel free to open a new issue. If the issue attracts a lot of attention, it will strengthen the case for this option to exist and may also accelerate the timeframe for getting it done.

@tal-hason
Copy link
Contributor

@krancour ,thanks as always on the detailed answer 😃.

I can tell you the I going at least 3-4 customers that have the potential to work with Kargo that have unsecured git server, do to that their network is disconnected.

I understand the secure by design concept and constraints, but security at the end is the customer risk to take.

I will Open an issue and see what is what.

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

Successfully merging this pull request may close these issues.

Support git repos with http/non-ssl URL
4 participants