-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conditionally Enable filters.WithAuthenticationAndAuthorization
Only When secureMetrics
is True
#4020
Comments
Thank you for raise this one. |
I think I would prefer only setting a FilterProvider if But I think both works today with controller-runtime. I would generally expect that if a FilterProvider is set it either returns an error or it returns a FilterProvider, not |
@sbueringer: Looks like the example code is setting the |
Ups sorry. You're right! |
Hi @sbueringer and @alex-kattathra-johnson The example code is only to show where/what we need to do. Metrics: metricsserver.Options {
BindAddress: metricsAddr,
SecureServing: secureMetrics,
TLSOpts: tlsOpts,
if secureMetrics {
FilterProvider: func() metricsserver.FilterProvider {
return filters.WithAuthenticationAndAuthorization
}
},
}, I would either prefer something simple like above 👍 |
All good, I was just misreading the anonymous func :) |
What do you want to happen?
In the default scaffold of
main.go
, theFilterProvider: filters.WithAuthenticationAndAuthorization
is always enabled. However, this can lead to security issues as it requires a ServiceAccount token to always be provided, which should never be sent via HTTP.Problem Statement:
By always enabling
filters.WithAuthenticationAndAuthorization
, users are forced to provide a ServiceAccount token, even in cases wheresecureMetrics
is not set to true. This can lead to tokens being sent over insecure connections, which is not advisable.Proposal:
The
filters.WithAuthenticationAndAuthorization
should only be enabled whensecureMetrics
is set to true. This will ensure that ServiceAccount tokens are only required and used when secure communication is enabled.Update the implementation in the default scaffold of
main.go
to conditionally enablefilters.WithAuthenticationAndAuthorization
based on the value ofsecureMetrics
.References:
Expected Behavior:
The
filters.WithAuthenticationAndAuthorization
should be conditional and only enabled whensecureMetrics
is true. This ensures that ServiceAccount tokens are only needed in a secure environment, preventing them from being sent over HTTP.Proposed Solution:
Example Code Change:
Extra Labels
No response
The text was updated successfully, but these errors were encountered: