- Notifications
You must be signed in to change notification settings - Fork 85
Add Authentication #7
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
Conversation
Empty2k12 left a comment
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.
Thank you very much for this PR!! 💚
I really like how you implemented the feature. I do have some comments which I would love to discuss:
- We can remove the
urldependency since you switchedreqwest::Url🎉 - possibly creating a second
new_with_authmethod, that takes an auth parameter, in addition tonewwhich is unauthed - Doctests should be fixed
- It would be nice to test authed and unauthed connections in CI
What do you think about these suggestions? I can also help with these suggestions if you do not want to implement them 💪
| I thought about getting rid of the I am not sure about having a new and something else. Looking at other crates we could rename new to For CI we would need to spin up a authed influxdb instance. Should we provide a config in the repo or copy and edit the config in place for the authed instance? |
I thought about making it a builder pattern, this would be the best solution!
Not sure about the best solution, would be fine with either. If you want, we could also switch to Github Actions as the CI, but that might warrant a different PR. |
By adding a Builder for the client or by making |
| I thought about the client so you can do both |
| That is the same thing I came up with currently. |
| After fighting with futures here is an improved version including tests and changes to CI. |
| It seems my sed command does not change the bind-address or something else is preventing the second instance from starting. Do we need to set different data dirs? |
| I found out you can easily use docker for running your influxdb instances. This seems clean to me for now. No need to change to actions. |
| That's a great solution with the Docker in Travis 👌! Should I do a last round of code review to get this merged? |
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.
Great work, I really like where this is going! Thank you very much for the effort!
Some comments - also we should try to bump that coverage up again, I left some comments on where I think that is possible.
Generally, I like to keep coverage equal or bump it in a PR
src/client/mod.rs Outdated
| }; | ||
| | ||
| let any_value = q as &dyn Any; | ||
| let basic_parameters: Vec<(String, String)> = (self.clone()).into(); |
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.
Is there a better option than cloning?
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.
We could change the into impl to
impl<'a> Into<Vec<(String, String)>> for &'a InfluxDbClient { fn into(self) -> Vec<(String, String)> { let mut vec: Vec<(String, String)> = Vec::new(); vec.push(("db".to_string(), self.database.to_owned())); if let Some(auth) = &self.auth { vec.push(("u".to_string(), auth.username.to_owned())); vec.push(("p".to_string(), auth.password.to_owned())); } vec } }Then we would not need the cloning
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 added this one as a second impl so that &InfluxDbClient and InfluxDbClient can be used.
| Not sure how to increase the coverage more. Tests for |
| Let's see what it comes out to. I think it's fine 👍 |
| Just some warning and lints: https://travis-ci.org/Empty2k12/influxdb-rust/jobs/572918173 Other than that it looks ready to merge! |
Open up for discussion, a PR for adding Authentication.
Currently the URL generation has a lot of repeated code. My solution to add the auth parameters only when needed feels a little bit hacky currently. Setting db and auth parameters can be done before the if-statement.
Are there arguments against this auth method (Params in URL)? Should we support all of the three possibilities (Basic auth, Query parameters in the URL and in the body )
Testing needs to be added as well.
Closes #9