-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
basic access authentication for http/https #31648
Conversation
src/Storages/StorageURL.cpp
Outdated
@@ -136,6 +148,7 @@ namespace | |||
timeouts, | |||
credentials, | |||
context->getSettingsRef().max_http_get_redirects, | |||
userInfo.length() == 0 ? Poco::Net::HTTPBasicCredentials{} : Poco::Net::HTTPBasicCredentials(ostr.str()), |
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.
A little strange, this is now not consistent with ReadWriteBufferFromHTTP constructor, I think build check will fail now.
Probably merged with master incorrectly?
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.
OK, I will chang to if...else...patten.
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.
No this is what I meant, credentials arguments is passed 2 lines above. See
ClickHouse/src/IO/ReadWriteBufferFromHTTP.h
Lines 466 to 473 in 341f705
explicit ReadWriteBufferFromHTTP( | |
Poco::URI uri_, | |
const std::string & method_, | |
OutStreamCallback out_stream_callback_, | |
const ConnectionTimeouts & timeouts, | |
const Poco::Net::HTTPBasicCredentials & credentials_, | |
const UInt64 max_redirects = 0, | |
size_t buffer_size_ = DBMS_DEFAULT_BUFFER_SIZE, |
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.
Got it! It was a mistake of merge codes. I will push again.
@@ -0,0 +1 @@ | |||
select * FROM url('https://guest:guest@jigsaw.w3.org/HTTP/Basic/','RawBLOB', 'a String'); |
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.
Also I believe this test will not work in ci from docker.
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.
Why? Can the docker evironment access outside internet such as www.jigsaw.w3.org?
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.
Even if it will be ok, this is not good.
Can you please try to use http server in python in stateless tests like here https://github.com/ClickHouse/ClickHouse/blob/master/tests/queries/0_stateless/00646_url_engine.python?
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.
OK, I will write a python script to run this test later.
/ClickHouse/src/Storages/StorageURL.cpp:135: if(n != std::string::npos) |
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.
/ClickHouse/src/Storages/StorageURL.cpp:135: if(n != std::string::npos)
This check fails, can you tell me why, pls?
When you run this locally, did you try to print user_info
string and see how it looks?
src/Storages/StorageURL.cpp
Outdated
@@ -128,6 +128,17 @@ namespace | |||
|
|||
try | |||
{ | |||
std::string userInfo = request_uri.getUserInfo(); |
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.
std::string userInfo = request_uri.getUserInfo(); | |
std::string user_info = request_uri.getUserInfo(); |
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.
Yes, I do. userInfo string is "guest:guest" when input "https://guest:guest@localhost:someport/".
By the way, FunctionalStatelessTestAsan fails(01622_defaults_for_url_engine.sh). I think that's none business with my commit.
2021-11-29 01:11:23 /usr/share/clickhouse-test/queries/0_stateless/01622_defaults_for_url_engine.sh: line 38: 67794 Killed timeout $TIMEOUT bash -c "thread1 $PORT" > /dev/null 2>&1
2021-11-29 01:11:23
2021-11-29 01:11:23 stdout:
2021-11-29 01:11:23 Ok
2021-11-29 01:11:23
2021-11-29 01:11:23
2021-11-29 01:11:23 Database: test_momh37
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.
Actually looks like it must work, are you sure that the problem is in if(n != std::string::npos)
?
I think that's none business with my commit.
yes, it is not related.
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.
userInfo string stores "username:password" string. Now the condition judge( if(n != std::string::npos)) passed the test in the file src/Storages/StorageURL.cpp. I think the other fails are none business with my commit.
try
{
std::string userInfo = request_uri.getUserInfo();
if (!userInfo.empty())
{
std::size_t n = userInfo.find(":");
if(n != std::string::npos)
{
credentials.setUsername(userInfo.substr(0, n));
credentials.setPassword(userInfo.substr(n+1));
}
}
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.
/ClickHouse/src/Storages/StorageURL.cpp:135: if(n != std::string::npos)
This is style check, I did not get about what check were you talking about, and thought you solution fails on this if statement check...
You are just missing a space between if
and (
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.
Also build check is related:
src/CMakeFiles/dbms.dir/Storages/StorageURL.cpp.o.d -o src/CMakeFiles/dbms.dir/Storages/StorageURL.cpp.o -c ../src/Storages/StorageURL.cpp
2021-11-29 07:13:08 /build/obj-x86_64-linux-gnu/../src/Storages/StorageURL.cpp:131:37: error: invalid case style for local variable 'userInfo' [readability-identifier-naming,-warnings-as-errors]
2021-11-29 07:13:08 std::string userInfo = request_uri.getUserInfo();
2021-11-29 07:13:08 ^~~~~~~~
2021-11-29 07:13:08 user_info
2021-11-29 07:13:08 /build/obj-x86_64-linux-gnu/../src/Storages/StorageURL.cpp:134:59: error: 'find' called with a string literal consisting of a single character; consider using the more effective overload accepting a character [performance-faster-string-find,-warnings-as-errors]
2021-11-29 07:13:08 std::size_t n = userInfo.find(":");
2021-11-29 07:13:08 ^~~
2021-11-29 07:13:08 ':'
2021-11-29 07:13:08 91053 warnings generated.
Other checks are not related.
Can you please fix build check, it is still broken
|
Sorry, finished a few minutes ago! |
ClickHouse Functional Stateless Tests fail (02098_date32_comparison | FAIL). I think this fail is none business with my commit. And ClickHouse Stress Test(Hung check failed/FLAKY). Can you give me more info pls? |
|
Changelog category:
Changelog entry:
Detailed description / Documentation draft:
issue here: Basic Auth for http/url functions not supported
Basic auth for http/https is not supported before 21.11. You can see this error such like:
Now we can access a format avro schema registry url like this:
Basic auth for http/https is supported now.
HTTP Authentication: Basic and Digest Access Authentication