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

Don't set auth if no user/pass #7

Merged
merged 1 commit into from
Dec 1, 2020
Merged

Don't set auth if no user/pass #7

merged 1 commit into from
Dec 1, 2020

Conversation

meringu
Copy link
Contributor

@meringu meringu commented Nov 30, 2020

I'm using cookie based auth to connect to a prometheus endpoint. Not setting a auth means the request gets sent with a Authorization: Basic Og== header. This results in a 401 from my Prometheus endpoint.

This is because axios adds the auth header based on the presense of the auth object, not if it has username or password in it. https://github.com/axios/axios/blob/c7329fefc890050edd51e40e469a154d0117fc55/lib/adapters/http.js#L32.

This PR adds a similar check as what is in place for the proxy config.

Cheers

@samber
Copy link
Owner

samber commented Dec 1, 2020

Looks good.
I'm going to publish a new release.

@haghsheno
Copy link

@samber I'm using authorization header but yet it shows me authorization: TOKEN ,Basic Og== in request header even if i don't use auth option or set auth: null.

prometheus: {
   endpoint: url,
   auth: null,
   headers: {
      authorization: token,
    },
}

If i set auth: {username: null, password: null}, the decoded result is [object Object]:[object Object].

I expect this in request header:
authorization: TOKEN

@meringu meringu deleted the patch-1 branch February 28, 2021 11:43
@samber
Copy link
Owner

samber commented Feb 28, 2021

Hi @haghsheno and thanks for the bug report.

I cannot reproduce this error.

What version of the library are you using?

@samber
Copy link
Owner

samber commented Feb 28, 2021

Oh! I see.
Are you using chartjs-plugin-datasource-prometheus?

This plugin is using an old version of prometheus-query-js.
An update is pending. I gonna merge it today.

You can upgrade to chartjs-plugin-datasource-prometheus@1.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants