-
Notifications
You must be signed in to change notification settings - Fork 144
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 backend authentication for targetRefs on vmusers by secret #714
Add backend authentication for targetRefs on vmusers by secret #714
Conversation
Hello, we are trying to unify the auth config with operator/api/v1beta1/additional.go Lines 211 to 223 in f2b8cf7
|
Sure. |
I'll fix this. |
I faced some issues about using HttpAuth in VMuser definition.
And the logic behind this transformation in something like vmalert is much simpler and straightforward: vmalert crd implements HTTPAuth in remoteWrite section and as we can see theres options(https://docs.victoriametrics.com/vmalert.html ) like my recommendation is to first implement HttpAuth features in vmauth component (as I have created issue for basicAuth) and support them in configuration formats then update operator. What do you think? @Haleygo @f41gh7 And also what is your opinion on passwordFiles? inline basicAuth on CRDS in something like vmalert.notifier.basicAuth.password will finally transform to |
@mohammadkhavari Thank you for all the work! Sorry I didn't look too deep when I propose that. |
Thank you, Please inform me if any refactoring, code completion, or other modifications, such as adding tests or fixing code, are required. |
@Haleygo Are there any updates on the feature? |
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.
Sorry for the long silence!
Please see comment.
api/v1beta1/vmuser_types.go
Outdated
@@ -78,6 +78,9 @@ type TargetRef struct { | |||
// https://docs.victoriametrics.com/vmauth.html#ip-filters | |||
// +optional | |||
IPFilters VMUserIPFilters `json:"ip_filters,omitempty"` | |||
// BasicAuth allow an endpoint to authenticate over basic authentication | |||
// +optional | |||
BasicAuth *BasicAuth `json:"basicAuth,omitempty"` |
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 think we don't need to reuse BasicAuth
here, the only field missing in vmuser now is Username v1.SecretKeySelector
and we can add it directly to VMUserSpec
.
Password v1.SecretKeySelector
in BasicAuth should already be covered by PasswordRef *v1.SecretKeySelector
operator/api/v1beta1/vmuser_types.go
Lines 26 to 27 in 0628def
// +optional | |
PasswordRef *v1.SecretKeySelector `json:"passwordRef,omitempty"` |
And
PasswordFile
field is not used.
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.
There seems to be a bit of confusion regarding the nature of this feature. As far as my usage experience goes, a vmuser can encompass multiple path routes, and each of these paths includes various hosts as backends (though typically, we utilize only one host per targetRef entry). Our objective is to implement basic authentication for these backends. The challenge lies in setting distinct basic authentication credentials for each endpoint, but how we can set basic auth on these endpoints with some field that has appeared on top level field like vmuser's spec itself?
While I've built a custom operator to address our requirements, it has served our needs effectively for quite some time. However, we want to align it with the latest version of VictoriaMetrics and utilize the officially released version to ensure ongoing 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.
Oh, sorry, you're right!
But I still think we can add Username v1.SecretKeySelector
and Password v1.SecretKeySelector
directly instead of reuse BasicAuth
since PasswordFile
is not used.
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.
so should we add it under vmuserSpec.TargetRef ?
It will be a little confusing and not straightforward to know they are for basicAuth? and also it does not seem to be a good solution to provide other methods of http authentication as you've mentioned you're working on.
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.
It will be a little confusing and not straightforward to know they are for basicAuth?
I think with description, it's ok.
I'm more against introducing invalid field, which looks like a bug.
What do you think @f41gh7
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 agree, it's better to use username and password directly. Or wrap it into new struct TargetRefAuth
.
It must have username
and password
for basic Authorization.
E.g.
type TargetRefAuth struct{
Username v1.SecretKeySelector
Password v1.SecretKeySelector
}
I think, it less confusing.
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 think It's good enough to proceed.
I'll go ahead and update the code with the suggested interface.
Do you Agree?
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.
@mohammadkhavari yes, please go ahead!
679961e
to
d50ce0e
Compare
d50ce0e
to
42085cb
Compare
…vmauth config generation backend basic authentication support on vmuser to add them as header on vmauth configuration it will satisfy the basicauth authorization for bellow issue VictoriaMetrics#669 * add docs * add test
42085cb
to
c8f5957
Compare
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.
LGTM
Thanks for contribution! |
@f41gh7 According to the failed pipeline, Ive noticed that I missed the refactor structure commit, I have fixed implementations and adopt new interfaces by a new separated commit. should I make another pull req? |
No worries, I ll make follow-up commit with fix for it. |
This pull request will add backend basic authentication support on vmuser to add them as header on vmauth configuration.
if this approach is accepted I'll add other authentication formats (like bearer) if needed.
#669