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: Added TLS options for git sources with self-signed certificates #2443

Merged
merged 5 commits into from
Nov 27, 2023
Merged

feat: Added TLS options for git sources with self-signed certificates #2443

merged 5 commits into from
Nov 27, 2023

Conversation

mattiaforc
Copy link
Contributor

@mattiaforc mattiaforc commented Nov 25, 2023

Introduces storage.git.insecure_skip_tls, storage.git.ca_cert_path and storage.git.ca_cert_bytes config for allowing users to use git sources with self-signed certificates, either via disabling TLS (not recommended in production) or via CA bundles - that can be a path to a x.509 file or the whole certificate bytes.

Refs: issue #2423

@mattiaforc mattiaforc requested a review from a team as a code owner November 25, 2023 15:05
Copy link

codecov bot commented Nov 25, 2023

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (3e8ab3f) 70.76% compared to head (54636aa) 70.72%.

Files Patch % Lines
internal/cmd/grpc.go 0.00% 11 Missing ⚠️
internal/config/storage.go 33.33% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2443      +/-   ##
==========================================
- Coverage   70.76%   70.72%   -0.05%     
==========================================
  Files          81       81              
  Lines        8110     8139      +29     
==========================================
+ Hits         5739     5756      +17     
- Misses       2025     2036      +11     
- Partials      346      347       +1     

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

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

Looking great! Thanks for taking this on @mattiaforc !! Also really appreciate you updating the JSON and Cue schemas!

Couple minor suggestions, but will defer to @GeorgeMac for the ✅

internal/config/storage.go Show resolved Hide resolved
}

// CaBundleFromFile tries to load an x.509 CA certificate from a path
func CaBundleFromFile(caPath string) ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesnt look like theres any thing CA specific for this func as its really just wrapping os.ReadFile, we could probably just remove this and call os.ReadFile directly in grpc.go:

https://github.com/flipt-io/flipt/pull/2443/files#diff-b3edacef8342d287b8d908a586f22acedfa5f180d94b7a84e665e7f7a2cc973cR166

Copy link
Member

@GeorgeMac GeorgeMac left a comment

Choose a reason for hiding this comment

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

This change is great. +1 to both of Marks suggestions and then just a couple more CUE suggestions from me. Otherwise, this is awesome. Thank you!

Comment on lines 148 to 149
ca_cert_path: string
ca_cert_bytes: string
Copy link
Member

Choose a reason for hiding this comment

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

Could you make these two optional (CUE fields are required by default):

Suggested change
ca_cert_path: string
ca_cert_bytes: string
ca_cert_path?: string
ca_cert_bytes?: string

poll_interval?: =~#duration | *"30s"
ca_cert_path: string
ca_cert_bytes: string
insecure_skip_tls?: bool | false
Copy link
Member

Choose a reason for hiding this comment

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

If you add a * here then CUE will default to false (when not supplied). Otherwise, this is just a type assertion and the | false bit is redundent.

Suggested change
insecure_skip_tls?: bool | false
insecure_skip_tls?: bool | *false

Introduces storage.git.insecure_skip_tls, storage.git.ca_cert_path and storage.git.ca_cert_bytes config
for allowing users to use git sources with self-signed certificates, either via disabling TLS (not recommended in production)
or via CA bundles - that can be a path to a x.509 file or the whole certificate bytes.

Refs: issue #2423
…cert_path. Added new validation error when both ca_cert_bytes and ca_cert_path are specified and small refactor
@mattiaforc
Copy link
Contributor Author

Hi @markphelps @GeorgeMac, thanks for the suggestions, I just pushed the changes, let me know if it's all good!

@markphelps markphelps added the needs docs Requires documentation updates label Nov 26, 2023
Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

lgtm! thanks @mattiaforc !!!

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

ah actually looks like there may be an issue with the unit tests

@markphelps
Copy link
Collaborator

ah actually looks like there may be an issue with the unit tests

ignore this, doesn't look like its related to your changes. digging in now

@markphelps
Copy link
Collaborator

@all-contributors please add @mattiaforc for code

Copy link
Contributor

@markphelps

I've put up a pull request to add @mattiaforc! 🎉

@markphelps
Copy link
Collaborator

Thanks again @mattiaforc !! Looks great 🎉

@mattiaforc
Copy link
Contributor Author

It was a pleasure!

@markphelps markphelps merged commit 5aef5a1 into flipt-io:main Nov 27, 2023
27 of 29 checks passed
@markphelps
Copy link
Collaborator

Will create a release later today with this in it

erka added a commit to erka/flipt that referenced this pull request Nov 30, 2023
erka added a commit to erka/flipt that referenced this pull request Nov 30, 2023
@markphelps markphelps removed the needs docs Requires documentation updates label Dec 20, 2023
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.

3 participants