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

allow client to set X-Scope-OrgID #36

Closed
till opened this issue Apr 26, 2024 · 3 comments
Closed

allow client to set X-Scope-OrgID #36

till opened this issue Apr 26, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@till
Copy link
Collaborator

till commented Apr 26, 2024

This is really close to what I'd like.

We run cortex-tenant on k8s to split metrics by a label (the label is X-Scope-OrgID). Then cortex-tenant makes a request to our own in-house thing which uses basic authentication to authenticate the request, keeping the X-Scope-OrgID label that cortex-tenant added.

From reading the code, it seems like, auth-gateway sets it based on user/pass combo:
https://github.com/cortexproject/auth-gateway/blob/main/gateway/middleware.go#L56-L63

I would add a value like __ALL__ to allow the client to set it instead. Would you be open to adding this when I write the code?

@friedrichg friedrichg added the enhancement New feature or request label Apr 26, 2024
@till
Copy link
Collaborator Author

till commented Apr 26, 2024

Maybe instead of __ALL__, I could also make id optional.

@friedrichg
Copy link
Member

You could just add "pass-through" as authentication in

// add other authentication methods if necessary

And let all headers pass without removing authentication headers. I can see that as useful for other people


Personally I don't see why would you use cortex-tenant to just add a label. You can do that per tenant in cortex with

# List of metric relabel configurations. Note that in most situations, it is
# more effective to use metrics relabeling directly in the Prometheus server,
# e.g. remote_write.write_relabel_configs.
[metric_relabel_configs: <relabel_config...> | default = []]

https://cortexmetrics.io/docs/configuration/configuration-file/#limits_config

till added a commit to hostwithquantum/auth-gateway that referenced this issue Apr 26, 2024
till added a commit to hostwithquantum/auth-gateway that referenced this issue Apr 26, 2024
For: cortexproject#36
Signed-off-by: till <till@php.net>
@till
Copy link
Collaborator Author

till commented Apr 26, 2024

@friedrichg I think way simpler, than another handler. I made a PR, but let me know.

As for your other question, maybe we started using this before cortex supported it. Or we were thrown off by the comment (to better do it elsewhere). I have to admit that after all these years re-labeling in prometheus is still a bit of a blackbox to me — too easy to get it wrong.

friedrichg added a commit that referenced this issue Jun 10, 2024
* Fix(auth): use crypto/subtle to compare strings

Related: #37
Signed-off-by: till <till@php.net>

* Update(gateway): support passthrough

For: #36
Signed-off-by: till <till@php.net>

* Update gateway/middleware.go

---------

Signed-off-by: till <till@php.net>
Co-authored-by: Friedrich Gonzalez <1517449+friedrichg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants