-
Notifications
You must be signed in to change notification settings - Fork 225
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
backend(oidc): Add support for custom CA and skipping TLS verification #2880
base: main
Are you sure you want to change the base?
Conversation
247dfa7
to
dc9f4e9
Compare
this patch adds support for custom CA and skipping TLS verification for OIDC provider verification. This improves flexibility for users working with self-signed OIDC providers. Signed-off-by: yolossn <[email protected]>
dc9f4e9
to
df018e2
Compare
Backend Code coverage changed from 65.0% to 64.4%. Change: -.6% 😞. Coverage report
|
I’ve added support for both skipping TLS verification ( Although TLS skip verification was introduced in #130, it applies to all clusters, not just in-cluster. This update ensures that TLS settings are applied specifically for in-cluster OIDC configuration. https://github.com/headlamp-k8s/headlamp/blob/main/backend/cmd/headlamp.go#L520-L530 @illume, should we deprecate the existing |
We definitely need to keep it for backwards compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this.
I left some notes inline.
- Can you please add tests and a description of how to test manually in the PR?
- Probably the related issue(s) should be in the PR description.
- There will need to be support added to the helm chart.
- docs in oidc.md ?
} | ||
// check if the file is a valid PEM file | ||
caCertPool := x509.NewCertPool() | ||
if !caCertPool.AppendCertsFromPEM(caFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rename the caFile to caFileContents? Currently it shares the same convention as the config.OidcCAFile... which lead me to believe from just reading this part that it was a filename.
It might also be worth renaming config.OidcCAFile to config.OidcCAFilePath to be more explicit.
IdpIssuerURL string | ||
Scopes []string | ||
SkipTLSVerify bool | ||
CACert string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please document this field?
|
||
if oidcAuthConfig.SkipTLSVerify { | ||
tr := &http.Transport{ | ||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a justification in a comment for why gosec was disabled here?
|
||
secureTLSClient := &http.Client{ | ||
Transport: &http.Transport{ | ||
TLSClientConfig: &tls.Config{RootCAs: caCertPool}, //nolint:gosec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a justification in a comment for why gosec was disabled here?
os.Exit(1) | ||
} | ||
|
||
headlampConfig.oidcCACert = string(caFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -243,11 +245,25 @@ func (c *Context) OidcConfig() (*OidcConfig, error) { | |||
return nil, errors.New("authProvider is nil") | |||
} | |||
|
|||
var caCert string | |||
|
|||
caFilePath, ok := c.AuthInfo.AuthProvider.Config["idp-certificate-authority"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain what this is in a comment?
|
||
caFilePath, ok := c.AuthInfo.AuthProvider.Config["idp-certificate-authority"] | ||
if ok { | ||
caFile, err := os.ReadFile(caFilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder where caFilePath comes from and if the path needs to be validated?
this patch adds support for custom CA and skipping TLS verification for OIDC provider verification. This improves flexibility for users working with self-signed OIDC providers.