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

Let the choice to write credential for HTTP source on external dictionaries #7092

Merged
merged 11 commits into from Sep 30, 2019

Conversation

YiuRULE
Copy link
Contributor

@YiuRULE YiuRULE commented Sep 25, 2019

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

For changelog. Remove if this is non-significant change.

Category (leave one):

  • New Feature

Short description (up to few sentences):

Set two configuration options for a dictionary based on an HTTP source. credentials and http-headers.

Detailed description (optional):

Two options has been made, mostly for improve security when we use a private dataset using an HTTP dictionary.

The first one is credentials, used when a server use a basic http auth. With an user and a password.

The second is http-headers for set some datas on the HTTP request header. The motivation of it is for service who can possibly get an API key from an header, to be able let ClickHouse get the datas.


if (config.has(credentials_prefix))
{
this->credentials.setUsername(config.getString(credentials_prefix + ".user", ""));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this-> qualification looks unneeded.

@@ -86,6 +86,10 @@ namespace detail
template <typename UpdatableSessionPtr>
class ReadWriteBufferFromHTTPBase : public ReadBuffer
{
public:
using HttpHeaderEntry = std::tuple<std::string, std::string>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer HTTP, not Http.

@@ -84,6 +84,16 @@ Example of settings:
<http>
<url>http://[::1]/os.tsv</url>
<format>TabSeparated</format>
<credentials>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to mention that it's optional.

<user>user</user>
<password>password</password>
</credentials>
<http-headers>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can omit http- here because it's http source.

Copy link
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Only a few style issues remain.

@@ -84,6 +84,16 @@ Example of settings:
<http>
<url>http://[::1]/os.tsv</url>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we cannot include credentials in URL:
http://user:password@[::1]/os.tsv

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect a bit the code who handle authentication to not handle it if we set the auth on the URI, I tried to do some test locally with an HTTP server, the server returned a 401 error if we put the auth on the URL.

https://github.com/ClickHouse/ClickHouse/blob/master/dbms/src/IO/ReadWriteBufferFromHTTP.h#L112-L113

@YiuRULE
Copy link
Contributor Author

YiuRULE commented Sep 26, 2019

Ok done :)

@alexey-milovidov
Copy link
Member

Ok. Now it's almost ready!
We also need to update integration test to ensure that this feature continue to work.

Look at tests/integration//test_redirect_url_storage

or

tests/queries/0_stateless/00646_url_engine.python

@YiuRULE
Copy link
Contributor Author

YiuRULE commented Sep 27, 2019

Done ! :)

I modified one integration test where the http server do a simili-authentication system

@alexey-milovidov alexey-milovidov merged commit 42c9ea9 into ClickHouse:master Sep 30, 2019
@stavrolia stavrolia added the pr-feature Pull request with new product feature label Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature Pull request with new product feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants