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

Token Authentication -- Manipulate Header #5107

Closed
npaschos opened this issue Jan 17, 2019 · 3 comments · Fixed by #8512
Closed

Token Authentication -- Manipulate Header #5107

npaschos opened this issue Jan 17, 2019 · 3 comments · Fixed by #8512

Comments

@npaschos
Copy link

Proposal

I am using django-rest framework along with django-prometheus in order to export metrics from my app. I have exposed an endopoint and created a Token in order to authenticate the prometheus server. The token works as expected when using Postman or curl, but the issue occurs when I try to include it in the prometheus.yaml config. The header that django-rest requires in order to authenticate with a token is of the following format:

Authorization: 'Token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

but the one created by Prometheus is:

Authorization: 'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

Note that the former has the Token keyword included, whereas the latter one the Bearer keyword.

As expected, the authentication fails. I tried changing the header but I could not find any way in the documentation, so I assume that it is not possible.

Am I missing a config parameter? If not, I propose that this change is implemented.


Note: this is my first issue/proposal, I tried following the guidelines. Let me know if anything else is required.

@brian-brazil
Copy link
Contributor

We only support standard authentication mechanisms, which your system is not. I'd suggest switching your authentication to use Bearer tokens.

@roidelapluie
Copy link
Member

From the Django Rest Framework docs: https://www.django-rest-framework.org/api-guide/authentication/

Note: If you want to use a different keyword in the header, such as Bearer, simply subclass TokenAuthentication and set the keyword class variable.

It looks like you could work at the DRF level instead.

@roidelapluie
Copy link
Member

This has been implemented in #8512.

authorization:
  credentials: mysecrettoken
  type: Token

@prometheus prometheus locked as resolved and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants