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

Doesn't work with the phpClickHouse client #27

Open
ghgugle opened this issue Apr 9, 2020 · 1 comment
Open

Doesn't work with the phpClickHouse client #27

ghgugle opened this issue Apr 9, 2020 · 1 comment

Comments

@ghgugle
Copy link

ghgugle commented Apr 9, 2020

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:

  1. Using HTTP Basic Authentication. Example:
    $ echo 'SELECT 1' | curl 'http://user:password@localhost:8123/' -d @-
  2. In the ‘user’ and ‘password’ URL parameters. Example:
    $ echo 'SELECT 1' | curl 'http://localhost:8123/?user=user&password=password' -d @-
  3. Using ‘X-ClickHouse-User’ and ‘X-ClickHouse-Key’ headers. Example:
    $ 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/

@a110ut
Copy link

a110ut commented May 21, 2021

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' => '...',
];

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

No branches or pull requests

2 participants