Open ghgugle opened 4 years ago
Actually phpClickHouse provides several ways to authorize. See https://github.com/smi2/phpClickHouse/blob/1.4.1/README.md#auth-methods
With "HTTP Basic Authentication" your config should be like this:
$config = [
'host' => '127.0.0.1',
'port' => '8124',
'auth_method' => \ClickHouseDB\Transport\Http::AUTH_METHOD_BASIC_AUTH,
'username' => '...',
'password' => '...',
];
When doing request using the following lib https://github.com/smi2/phpClickHouse which is the best one at the moment. It seems like the clickhouse-bulk except auth config via query param, but the new version of the phpClickHouse lib is using authorization via headers.
Unfortunately the phpClickHouse doesn't provide a way to send custom query param so I can do a workaround to add username/password to query string too.
Is there any solution for this? Or could you update the lib to except the param via new way also.
The one of the official auth methods of Clickhouse is with headers: X-ClickHouse-Key, X-ClickHouse-User
Here all options:
$ echo 'SELECT 1' | curl 'http://user:password@localhost:8123/' -d @-
$ echo 'SELECT 1' | curl 'http://localhost:8123/?user=user&password=password' -d @-
$ echo 'SELECT 1' | curl -H 'X-ClickHouse-User: user' -H 'X-ClickHouse-Key: password' 'http://localhost:8123/' -d @-
https://clickhouse.tech/docs/en/interfaces/http/