Commit Graph

94 Commits

Author SHA1 Message Date
Vitaly Baranov
aee67a6693
Merge pull request #31484 from eungenue/Implement-SSL-X509-certificate-authentication
Implement ssl x509 certificate authentication
2022-02-21 11:30:52 +03:00
Vitaly Baranov
cb66a63aa4 Rename header and config setting for consistency. 2022-02-21 07:41:06 +03:00
Vitaly Baranov
765d136d2a A few improvements in the implementation of SSL certificate authentication. 2022-02-21 07:41:02 +03:00
Azat Khuzhin
bedf208cbd Use fmt::runtime() for LOG_* for non constexpr
Here is oneliner:

    $ gg 'LOG_\(DEBUG\|TRACE\|INFO\|TEST\|WARNING\|ERROR\|FATAL\)([^,]*, [a-zA-Z]' -- :*.cpp :*.h | cut -d: -f1 | sort -u | xargs -r sed -E -i 's#(LOG_[A-Z]*)\(([^,]*), ([A-Za-z][^,)]*)#\1(\2, fmt::runtime(\3)#'

Note, that I tried to do this with coccinelle (tool for semantic
patchin), but it cannot parse C++:

    $ cat fmt.cocci
    @@
    expression log;
    expression var;
    @@

    -LOG_DEBUG(log, var)
    +LOG_DEBUG(log, fmt::runtime(var))

I've also tried to use some macros/templates magic to do this implicitly
in logger_useful.h, but I failed to do so, and apparently it is not
possible for now.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>

v2: manual fixes
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-02-01 14:30:03 +03:00
Nikita Mikhaylov
e3de3889e3
Revert "Revert "Ignore parse failure of opentelemetry header (#32116)" (#33594)" (#33595) 2022-01-19 20:53:39 +03:00
Eugene Galkin
30a741a19f fix header authentication check condition 2022-01-17 15:47:25 +03:00
Eugene Galkin
f46dca4793 support x509 ssl certificate authentication 2022-01-17 15:01:38 +03:00
Alexey Milovidov
4ab7dfc741 Fix #8340 2022-01-16 08:12:55 +03:00
Nikita Mikhaylov
340ec0fd20
Revert "Ignore parse failure of opentelemetry header (#32116)" (#33594)
This reverts commit 4e5f9c8ff7.
2022-01-13 16:29:18 +04:00
Frank Chen
4e5f9c8ff7
Ignore parse failure of opentelemetry header (#32116) 2022-01-13 16:16:10 +04:00
Azat Khuzhin
a9f80dd705 Fix Context leak in case of cancel_http_readonly_queries_on_client_close
To handle cancel_http_readonly_queries_on_client_close=true context
attaches progress callback with holding a copy of the current context,
and this creates recursive context reference and so shared_ptr will be
never released, [1] contains simplest example.

One example of a memory leak, external tables passed with HTTP query
(s_structure + file upload), since they are stored in the context, and
can occupate enough memory to make it visible to user.

Note, that the lifetime of the Context should be fine, since callback
can be called only when query is executed.

  [1]: Example of recursive reference

       ```c
       #include <memory>
       #include <functional>
       #include <cassert>

       bool released = true;

       class Context : public std::enable_shared_from_this<Context>
       {
           using Func = std::function<void()>;
           Func func;

       public:
           Context()  { released = false; }
           ~Context() { released = true; }
           Context(const Context & context) = delete;

           void addCallback(Func func_)
           {
               func = func_;
           }
       };

       int main()
       {
           {
               auto context = std::make_shared<Context>();
               context->addCallback([context]() {});
           }
           assert(released == true);
       }
       ```
2021-12-20 21:05:38 +03:00
Azat Khuzhin
dd8c64e380 Set QueryScope earlier for HTTP queries 2021-12-20 21:05:38 +03:00
Kruglov Pavel
690b460c3d
Fix style 2021-11-24 22:36:36 +03:00
Kruglov Pavel
b20f4439df
Make better 2021-11-24 22:25:03 +03:00
avogar
7c84d95908 Fix possible Logical error: Cannot write to finalized buffer 2021-11-24 18:32:41 +03:00
Alexey Milovidov
8b4a6a2416 Remove cruft 2021-10-28 02:10:39 +03:00
Artur
a853cd57ca refactoring 2021-10-09 12:56:00 +00:00
Artur
12f59f2dca refactor 2021-10-09 12:52:20 +00:00
Artur
473f7bee3a refactor 2021-10-09 12:16:37 +00:00
Artur Filatenkov
9b1a39fdb9 refactor after move common to base 2021-10-05 17:43:33 +03:00
Filatenkov Artur
82e6ac8fa2
Update HTTPHandler.cpp 2021-10-05 13:39:18 +03:00
Filatenkov Artur
8df228e6b8
Merge branch 'master' into add_CORS 2021-10-04 10:55:09 +03:00
Alexey Milovidov
fe6b7c77c7 Rename "common" to "base" 2021-10-02 10:13:14 +03:00
Filatenkov Artur
8959b348a1
Merge branch 'ClickHouse:master' into add_CORS 2021-10-01 14:42:46 +03:00
Filatenkov Artur
7bbd08cb5d
Update HTTPHandler.cpp 2021-09-24 15:40:27 +03:00
Artur
e5c49c2e86 Merge branch 'add_CORS' of https://github.com/FArthur-cmd/ClickHouse into add_CORS 2021-09-22 17:15:54 +00:00
Artur
ce4193fe95 small refactoring 2021-09-22 17:10:15 +00:00
Filatenkov Artur
1fe4555dec
Merge branch 'ClickHouse:master' into add_CORS 2021-09-22 19:55:15 +03:00
Artur
2ad7641e7f activate add_http_cors_header by default. 2021-09-22 16:54:36 +00:00
Artur
2cffa98a60 add test and comments in config 2021-09-22 12:22:21 +00:00
Artur
c8892ec7a7 add options support 2021-09-22 10:34:48 +00:00
Artur
82a849ba8e add options method 2021-09-18 09:36:02 +00:00
Azat Khuzhin
60013cff1a Do not call finalize() for HTTP buffer multiple times
Before only non-compressed was flushed, and so after compressed will
write to non-compressed and this will trigger multiple finalize() for
raw buffer, fix this, but adding Output::finalize() that take care of
all buffers.

This should fix CI failure [1] and also not only CI failures but also an
assert() that had been added in the previous commit.

    2021-09-05 15:08:43 00429_long_http_bufferization:                                          [ FAIL ] 6.68 sec. - return code 1
    2021-09-05 15:08:43 cmp: EOF on /tmp/clickhouse-test/0_stateless/test_e4xs61/res3 after byte 1048576, in line 4127
    2021-09-05 15:08:43 , result:

    The problem was with the following query:

        curl -q -sS 'http://localhost:8123/?database=default&log_comment=/src/ch/clickhouse/tests/queries/0_stateless/00429_long_http_bufferization.sh&max_block_size=500000&compress=1&buffer_size=1048576&wait_end_of_query=1' -d 'SELECT greatest(toUInt8(1), toUInt8(intHash64(number))) FROM system.numbers LIMIT 1500000 FORMAT RowBinary' | clickhouse-compressor --decompress | less

    It returns less rows.

  [1]: https://clickhouse-test-reports.s3.yandex.net/28604/1f34fd9a9eaff19fde0199f78b45656ab74f0590/functional_stateless_tests_(release).html#fail1
2021-09-16 22:36:09 +03:00
Azat Khuzhin
230f29ac4e Always flush buffer while handling HTTP queries
This will avoid possible std::terminate, like in [1]:

  [1]: https://github.com/ClickHouse/ClickHouse/pull/24023#issuecomment-842979875
2021-09-16 22:35:50 +03:00
Azat Khuzhin
47ad10061b Reduce scope for HTTPHandler::trySendExceptionToClient() 2021-09-16 22:35:50 +03:00
Anton Popov
6d3274c22c Merge remote-tracking branch 'upstream/master' into HEAD 2021-08-26 03:31:46 +03:00
Vitaly Baranov
fabd7193bd Code cleanups and improvements. 2021-08-18 14:24:52 +03:00
Vasily Nemkov
51ffc33457 Introduce sessions.
This is required to add system.session_log table.
2021-08-18 14:24:52 +03:00
hermano
14e251f158 Fixes style 2021-08-16 18:54:40 -03:00
hermano
5b520fbe0f Preloads query parameters 2021-08-16 07:58:52 -03:00
hermano
3366fc7c7e Enables query parameters in request body 2021-08-15 15:46:31 -03:00
Anton Popov
3a0d4807a5 Merge branch 'async-insert' of git://github.com/abyss7/ClickHouse into merging-20557 2021-08-06 16:20:02 +03:00
Alexey Milovidov
261a220227 Remove some code 2021-07-17 21:06:46 +03:00
Ivan Lezhankin
37365589ed Merge branch 'master' into async-insert 2021-06-17 16:57:45 +03:00
alexey-milovidov
04be5437d9
Merge pull request #25296 from abyss7/http-issues
Add settings for HTTP header limitations
2021-06-17 01:50:48 +03:00
Maksim Kita
67e9b85951 Merge ext into common 2021-06-16 23:28:41 +03:00
Ivan Lezhankin
ba08a580f8 Add test 2021-06-16 17:33:14 +03:00
Ivan Lezhankin
b182d87d9c Add settings for HTTP header limitations 2021-06-15 17:33:46 +03:00
Ivan Lezhankin
791cbcf0b1 Merge remote-tracking branch 'upstream/master' into async-insert 2021-06-02 18:50:37 +03:00
tavplubix
e9ff0b6d70
Merge pull request #23657 from kssenii/poco-file-to-std-fs
Poco::File to std::filesystem
2021-05-31 23:17:02 +03:00