mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Add integration tests for auth on HTTP external dictionaries
This commit is contained in:
parent
53b10d5b60
commit
7c93ef1706
@ -331,6 +331,16 @@ class SourceHTTPBase(ExternalSource):
|
||||
<http>
|
||||
<url>{url}</url>
|
||||
<format>TabSeparated</format>
|
||||
<credentials>
|
||||
<user>foo</user>
|
||||
<password>bar</password>
|
||||
</credentials>
|
||||
<headers>
|
||||
<header>
|
||||
<name>api-key</name>
|
||||
<value>secret</value>
|
||||
</header>
|
||||
</headers>
|
||||
</http>
|
||||
'''.format(url=url)
|
||||
|
||||
|
@ -6,12 +6,26 @@ import ssl
|
||||
import csv
|
||||
|
||||
|
||||
# Decorator used to see if authentification works for external dictionary who use a HTTP source.
|
||||
def check_auth(fn):
|
||||
def wrapper(req):
|
||||
auth_header = self.headers.get('Authorization', None)
|
||||
api_key = self.headers.get('api-key', None)
|
||||
if not auth_header or auth_header != 'Zm9vOmJhcg==' or not api_key or api_key != 'secret':
|
||||
req.send_response(401)
|
||||
else:
|
||||
fn(req)
|
||||
return wrapper
|
||||
|
||||
|
||||
def start_server(server_address, data_path, schema, cert_path, address_family):
|
||||
class TSVHTTPHandler(BaseHTTPRequestHandler):
|
||||
@check_auth
|
||||
def do_GET(self):
|
||||
self.__send_headers()
|
||||
self.__send_data()
|
||||
|
||||
@check_auth
|
||||
def do_POST(self):
|
||||
ids = self.__read_and_decode_post_ids()
|
||||
print "ids=", ids
|
||||
|
Loading…
Reference in New Issue
Block a user