Skip to content

Added support for token auth #89

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

Closed
wants to merge 13 commits into from

Conversation

sunng87
Copy link
Contributor

@sunng87 sunng87 commented Mar 13, 2021

Description

This patch adds support for token auth to make it easier to use backward compatibility API of influxdb 2.0

Checklist

  • Formatted code using cargo fmt --all
  • Linted code using clippy cargo clippy --all-targets --all-features -- -D warnings
  • Updated README.md using cargo readme -r influxdb -t ../README.tpl > README.md
  • Reviewed the diff. Did you leave any print statements or unnecessary comments?
  • Any unfinished work that warrants a separate issue captured in an issue with a TODO code comment

TODO items

  • improve github workflow and integration tests to test on influxdb 1.8 and 2.0 individually
  • add doc for influxdb 2.0 authorization usage. For now, the username/password auth is not compatible with 1.x so you can only use token auth on 2.0.

@sunng87 sunng87 force-pushed the feature/header-auth branch from f3b54f5 to f804efe Compare March 13, 2021 16:04
@Empty2k12
Copy link
Collaborator

@sunng87 Thanks for this contribution! 🚀 What's your plan to get this merged? Is there anything I can help you with?

@moisesdelacruz
Copy link

moisesdelacruz commented Mar 22, 2021

Hello,

I just did tests with InfluxQL in cURL in terminal and it works very fast (milliseconds), now the same query takes up to 19 seconds in influxdb-rust.

Any idea what the problem may be?

@Empty2k12
Copy link
Collaborator

@moisesdelacruz Could you open a separate issue with the curl command you're using and the code snippet which is taking so long? Thanks!

@moisesdelacruz
Copy link

@Empty2k12 Thanks for answering, comment here, because the test was done with Influxdb v2 and the branch of this PR.

But I will open the new Issue.

@Empty2k12
Copy link
Collaborator

@moisesdelacruz Sorry for misunderstanding, thought you were having an issue with the released library. If it's caused by this PR, here's the right place.

@moisesdelacruz
Copy link

In this case it is bringing a month of data, where in every second there is at least one record.

  • Rust Version: rustc 1.50.0 (cb75ad5db 2021-02-10)
  • Runtime version (e.g. Tokio): 0.2.22
  • OS Version: MacOS 10.14.6

Steps to Reproduce:

#[tokio::main]
async fn main() {
    // Connect to db `test` on `http://localhost:8086`
    let client = Client::new("https://influxdb-host", "example_db")
        .with_token("jwt");

    // Let's see if the data we wrote is there
    let read_query = Query::raw_read_query("SELECT * FROM example_db.example_rp.history WHERE tag='example'");

    let start = Time::now();
    let result = client
        .query(&read_query)
        .await;
    let end = Time::now();

    println!("{}", result.unwrap());
    println!("{:?}", end - start); // Duration { seconds: 16, nanoseconds: 823561000 }
}

VS

curl --get https://influxdb-host/query?db=example_db \
  --header "Authorization: Token jwt" \
  --data-urlencode "q=SELECT * FROM example_db.example_rp.history WHERE tag='example'"

# took miliseconds

@sunng87
Copy link
Contributor Author

sunng87 commented Mar 23, 2021

@Empty2k12 Sorry for late response. I have been pretty busy these days. Most work should have been done. I'm going to setup CI to verify the lib on both InfluxDB 1.x and 2.0

@moisesdelacruz
Copy link

Hello @Empty2k12 and @sunng87, I have already checked this PR on several occasions, and I think that the performance problem comes from before and not from this feature, unfortunately, all my data is in Influxdb v2 and I cannot test with the published version of this module.

This PR looks good, I think we should look for the problem in another issue.

Issue: #91

@sunng87 sunng87 force-pushed the feature/header-auth branch from 6472f84 to 8ab0cbf Compare March 27, 2021 13:33
@msrd0
Copy link
Collaborator

msrd0 commented Oct 28, 2021

What's the status on this PR?

@sunng87
Copy link
Contributor Author

sunng87 commented Oct 28, 2021

@msrd0 I was not able to test this on influxdb 2.0 over the CI. Its setup process is a little bit confusing. Help is welcomed.

@isarrider
Copy link

is there an update here?

@fredrik-jansson-se
Copy link

Any update? I was hoping to use the rust client in a project, seems like I'm blocked atm.

@msrd0
Copy link
Collaborator

msrd0 commented Jan 27, 2023

@fredrik-jansson-se If there were any updates, they would be posted here.

Someone needs to rebase these changes onto the main branch and setup CI to test with influxdb v2.0.

@msrd0
Copy link
Collaborator

msrd0 commented Mar 4, 2023

This change has been merged as part of #118

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

Successfully merging this pull request may close these issues.

6 participants