mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 19:45:11 +00:00
Merge pull request #70997 from Romeo58rus/master
Add support for reloading client-side certificates
This commit is contained in:
commit
ae29572119
@ -590,6 +590,7 @@ try
|
||||
|
||||
#if USE_SSL
|
||||
CertificateReloader::instance().tryLoad(*config);
|
||||
CertificateReloader::instance().tryLoadClient(*config);
|
||||
#endif
|
||||
});
|
||||
|
||||
|
@ -2340,6 +2340,7 @@ try
|
||||
|
||||
#if USE_SSL
|
||||
CertificateReloader::instance().tryLoad(config());
|
||||
CertificateReloader::instance().tryLoadClient(config());
|
||||
#endif
|
||||
|
||||
/// Must be done after initialization of `servers`, because async_metrics will access `servers` variable from its thread.
|
||||
|
@ -91,6 +91,12 @@ void CertificateReloader::tryLoad(const Poco::Util::AbstractConfiguration & conf
|
||||
}
|
||||
|
||||
|
||||
void CertificateReloader::tryLoadClient(const Poco::Util::AbstractConfiguration & config)
|
||||
{
|
||||
tryLoad(config, nullptr, Poco::Net::SSLManager::CFG_CLIENT_PREFIX);
|
||||
}
|
||||
|
||||
|
||||
void CertificateReloader::tryLoad(const Poco::Util::AbstractConfiguration & config, SSL_CTX * ctx, const std::string & prefix)
|
||||
{
|
||||
std::lock_guard lock{data_mutex};
|
||||
@ -107,7 +113,12 @@ std::list<CertificateReloader::MultiData>::iterator CertificateReloader::findOrI
|
||||
else
|
||||
{
|
||||
if (!ctx)
|
||||
ctx = Poco::Net::SSLManager::instance().defaultServerContext()->sslContext();
|
||||
{
|
||||
if (prefix == Poco::Net::SSLManager::CFG_CLIENT_PREFIX)
|
||||
ctx = Poco::Net::SSLManager::instance().defaultClientContext()->sslContext();
|
||||
else
|
||||
ctx = Poco::Net::SSLManager::instance().defaultServerContext()->sslContext();
|
||||
}
|
||||
data.push_back(MultiData(ctx));
|
||||
--it;
|
||||
data_index[prefix] = it;
|
||||
|
@ -77,6 +77,9 @@ public:
|
||||
/// Handle configuration reload for default path
|
||||
void tryLoad(const Poco::Util::AbstractConfiguration & config);
|
||||
|
||||
/// Handle configuration reload client for default path
|
||||
void tryLoadClient(const Poco::Util::AbstractConfiguration & config);
|
||||
|
||||
/// Handle configuration reload
|
||||
void tryLoad(const Poco::Util::AbstractConfiguration & config, SSL_CTX * ctx, const std::string & prefix);
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
<clickhouse>
|
||||
<remote_servers>
|
||||
<test_cluster>
|
||||
<shard>
|
||||
<replica>
|
||||
<host>node1</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
|
||||
<replica>
|
||||
<host>node2</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
|
||||
<replica>
|
||||
<host>node3</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
|
||||
</shard>
|
||||
</test_cluster>
|
||||
</remote_servers>
|
||||
</clickhouse>
|
@ -0,0 +1,20 @@
|
||||
<clickhouse>
|
||||
<zookeeper>
|
||||
<node index="1">
|
||||
<host>zoo1</host>
|
||||
<port>2281</port>
|
||||
<secure>1</secure>
|
||||
</node>
|
||||
<node index="2">
|
||||
<host>zoo2</host>
|
||||
<port>2281</port>
|
||||
<secure>1</secure>
|
||||
</node>
|
||||
<node index="3">
|
||||
<host>zoo3</host>
|
||||
<port>2281</port>
|
||||
<secure>1</secure>
|
||||
</node>
|
||||
<session_timeout_ms>3000</session_timeout_ms>
|
||||
</zookeeper>
|
||||
</clickhouse>
|
@ -0,0 +1,17 @@
|
||||
<clickhouse>
|
||||
<remote_servers>
|
||||
<test_cluster>
|
||||
<shard>
|
||||
<replica>
|
||||
<host>node1</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
|
||||
<replica>
|
||||
<host>node2</host>
|
||||
<port>9000</port>
|
||||
</replica>
|
||||
</shard>
|
||||
</test_cluster>
|
||||
</remote_servers>
|
||||
</clickhouse>
|
@ -0,0 +1,16 @@
|
||||
<clickhouse>
|
||||
<openSSL>
|
||||
<client>
|
||||
<certificateFile>/etc/clickhouse-server/config.d/first_client.crt</certificateFile>
|
||||
<privateKeyFile>/etc/clickhouse-server/config.d/first_client.key</privateKeyFile>
|
||||
<loadDefaultCAFile>true</loadDefaultCAFile>
|
||||
<cacheSessions>true</cacheSessions>
|
||||
<disableProtocols>sslv2,sslv3</disableProtocols>
|
||||
<preferServerCiphers>true</preferServerCiphers>
|
||||
<verificationMode>none</verificationMode>
|
||||
<invalidCertificateHandler>
|
||||
<name>RejectCertificateHandler</name>
|
||||
</invalidCertificateHandler>
|
||||
</client>
|
||||
</openSSL>
|
||||
</clickhouse>
|
@ -0,0 +1,19 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC/TCCAeWgAwIBAgIJANjx1QSR77HBMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV
|
||||
BAMMCWxvY2FsaG9zdDAgFw0xODA3MzAxODE2MDhaGA8yMjkyMDUxNDE4MTYwOFow
|
||||
FDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
||||
CgKCAQEAs9uSo6lJG8o8pw0fbVGVu0tPOljSWcVSXH9uiJBwlZLQnhN4SFSFohfI
|
||||
4K8U1tBDTnxPLUo/V1K9yzoLiRDGMkwVj6+4+hE2udS2ePTQv5oaMeJ9wrs+5c9T
|
||||
4pOtlq3pLAdm04ZMB1nbrEysceVudHRkQbGHzHp6VG29Fw7Ga6YpqyHQihRmEkTU
|
||||
7UCYNA+Vk7aDPdMS/khweyTpXYZimaK9f0ECU3/VOeG3fH6Sp2X6FN4tUj/aFXEj
|
||||
sRmU5G2TlYiSIUMF2JPdhSihfk1hJVALrHPTU38SOL+GyyBRWdNcrIwVwbpvsvPg
|
||||
pryMSNxnpr0AK0dFhjwnupIv5hJIOQIDAQABo1AwTjAdBgNVHQ4EFgQUjPLb3uYC
|
||||
kcamyZHK4/EV8jAP0wQwHwYDVR0jBBgwFoAUjPLb3uYCkcamyZHK4/EV8jAP0wQw
|
||||
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAM/ocuDvfPus/KpMVD51j
|
||||
4IdlU8R0vmnYLQ+ygzOAo7+hUWP5j0yvq4ILWNmQX6HNvUggCgFv9bjwDFhb/5Vr
|
||||
85ieWfTd9+LTjrOzTw4avdGwpX9G+6jJJSSq15tw5ElOIFb/qNA9O4dBiu8vn03C
|
||||
L/zRSXrARhSqTW5w/tZkUcSTT+M5h28+Lgn9ysx4Ff5vi44LJ1NnrbJbEAIYsAAD
|
||||
+UA+4MBFKx1r6hHINULev8+lCfkpwIaeS8RL+op4fr6kQPxnULw8wT8gkuc8I4+L
|
||||
P9gg/xDHB44T3ADGZ5Ib6O0DJaNiToO6rnoaaxs0KkotbvDWvRoxEytSbXKoYjYp
|
||||
0g==
|
||||
-----END CERTIFICATE-----
|
@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCz25KjqUkbyjyn
|
||||
DR9tUZW7S086WNJZxVJcf26IkHCVktCeE3hIVIWiF8jgrxTW0ENOfE8tSj9XUr3L
|
||||
OguJEMYyTBWPr7j6ETa51LZ49NC/mhox4n3Cuz7lz1Pik62WreksB2bThkwHWdus
|
||||
TKxx5W50dGRBsYfMenpUbb0XDsZrpimrIdCKFGYSRNTtQJg0D5WTtoM90xL+SHB7
|
||||
JOldhmKZor1/QQJTf9U54bd8fpKnZfoU3i1SP9oVcSOxGZTkbZOViJIhQwXYk92F
|
||||
KKF+TWElUAusc9NTfxI4v4bLIFFZ01ysjBXBum+y8+CmvIxI3GemvQArR0WGPCe6
|
||||
ki/mEkg5AgMBAAECggEATrbIBIxwDJOD2/BoUqWkDCY3dGevF8697vFuZKIiQ7PP
|
||||
TX9j4vPq0DfsmDjHvAPFkTHiTQXzlroFik3LAp+uvhCCVzImmHq0IrwvZ9xtB43f
|
||||
7Pkc5P6h1l3Ybo8HJ6zRIY3TuLtLxuPSuiOMTQSGRL0zq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R3J7A5RmpQNKm
|
||||
2RCqfO49Pg6U8kx+bDBKNjdCGWowt31cZTlJNXk7NPewtWaGYhuskbvH8gJDtbMd
|
||||
d9fOepIbzl3u+us8JHFVglBRgjy9sYjUYUT9mnTzfbpebmkdtiicJZNP1j08VZFR
|
||||
lXoHiESasyzlP8DLI/PQcpL6Lh8KnIifKGEkvXVaryPT2wlEo6Kti2cY8AIJKQgl
|
||||
0U1jwiNcCwjYoKIXjunOO8T8mKg=
|
||||
-----END CERTIFICATE-----
|
@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCz25KjqUkbyjyn
|
||||
DR9tUZW7S086WNJZxVJcf26IkHCVktCeE3hIVIWiF8jgrxTW0ENOfE8tSj9XUr3L
|
||||
OguJEMYyTBWPr7j6ETa51LZ49NC/mhox4n3Cuz7lz1Pik62WreksB2bThkwHWdus
|
||||
TKxx5W50dGRBsYfMenpUbb0XDsZrpimrIdCKFGYSRNTtQJg0D5WTtoM90xL+SHB7
|
||||
JOldhmKZor1/QQJTf9U54bd8fpKnZfoU3i1SP9oVcSOxGZTkbZOViJIhQwXYk92F
|
||||
KKF+TWElUAusc9NTfxI4v4bLIFFZ01ysjBXBum+y8+CmvIxI3GemvQArR0WGPCe6
|
||||
ki/mEkg5AgMBAAECggEATrbIBIxwDJOD2/BoUqWkDCY3dGevF8697vFuZKIiQ7PP
|
||||
TX9j4vPq0DfsmDjHvAPFkTHiTQXzlroFik3LAp+uvhCCVzImmHq0IrwvZ9xtB43f
|
||||
7Pkc5P6h1l3Ybo8HJ6zRIY3TuLtLxuPSuiOMTQSGRL0zq3SQ5DKuGwkz+kVjHXUN
|
||||
MR2TECFwMHKQ5VLrC+7PMpsJYyOMlDAWhRfUalxC55xOXTpaN8TxNnwQ8K2ISVY5
|
||||
212Jz/a4hn4LdwxSz3Tiu95PN072K87HLWx3EdT6vW4Ge5P/A3y+sm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irraodxjWkYX63zDeqteXU8JtNdJE43qFK4BVh3QTj7PhD3PFEAKcPbnJLbdTYC
|
||||
ZU36rm75uOSdLXNB
|
||||
-----END CERTIFICATE-----
|
@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCz25KjqUkbyjyn
|
||||
DR9tUZW7S086WNJZxVJcf26IkHCVktCeE3hIVIWiF8jgrxTW0ENOfE8tSj9XUr3L
|
||||
OguJEMYyTBWPr7j6ETa51LZ49NC/mhox4n3Cuz7lz1Pik62WreksB2bThkwHWdus
|
||||
TKxx5W50dGRBsYfMenpUbb0XDsZrpimrIdCKFGYSRNTtQJg0D5WTtoM90xL+SHB7
|
||||
JOldhmKZor1/QQJTf9U54bd8fpKnZfoU3i1SP9oVcSOxGZTkbZOViJIhQwXYk92F
|
||||
KKF+TWElUAusc9NTfxI4v4bLIFFZ01ysjBXBum+y8+CmvIxI3GemvQArR0WGPCe6
|
||||
ki/mEkg5AgMBAAECggEATrbIBIxwDJOD2/BoUqWkDCY3dGevF8697vFuZKIiQ7PP
|
||||
TX9j4vPq0DfsmDjHvAPFkTHiTQXzlroFik3LAp+uvhCCVzImmHq0IrwvZ9xtB43f
|
||||
7Pkc5P6h1l3Ybo8HJ6zRIY3TuLtLxuPSuiOMTQSGRL0zq3SQ5DKuGwkz+kVjHXUN
|
||||
MR2TECFwMHKQ5VLrC+7PMpsJYyOMlDAWhRfUalxC55xOXTpaN8TxNnwQ8K2ISVY5
|
||||
212Jz/a4hn4LdwxSz3Tiu95PN072K87HLWx3EdT6vW4Ge5P/A3y+smIuNAlanMnu
|
||||
plHBRtpATLiTxZt/n6npyrfQVbYjSH7KWhB8hBHtaQKBgQDh9Cq1c/KtqDtE0Ccr
|
||||
/r9tZNTUwBE6VP+3OJeKdEdtsfuxjOCkS1oAjgBJiSDOiWPh1DdoDeVZjPKq6pIu
|
||||
Mq12OE3Doa8znfCXGbkSzEKOb2unKZMJxzrz99kXt40W5DtrqKPNb24CNqTiY8Aa
|
||||
CjtcX+3weat82VRXvph6U8ltMwKBgQDLxjiQQzNoY7qvg7CwJCjf9qq8jmLK766g
|
||||
1FHXopqS+dTxDLM8eJSRrpmxGWJvNeNc1uPhsKsKgotqAMdBUQTf7rSTbt4MyoH5
|
||||
bUcRLtr+0QTK9hDWMOOvleqNXha68vATkohWYfCueNsC60qD44o8RZAS6UNy3ENq
|
||||
cM1cxqe84wKBgQDKkHutWnooJtajlTxY27O/nZKT/HA1bDgniMuKaz4R4Gr1PIez
|
||||
on3YW3V0d0P7BP6PWRIm7bY79vkiMtLEKdiKUGWeyZdo3eHvhDb/3DCawtau8L2K
|
||||
GZsHVp2//mS1Lfz7Qh8/L/NedqCQ+L4iWiPnZ3THjjwn3CoZ05ucpvrAMwKBgB54
|
||||
nay039MUVq44Owub3KDg+dcIU62U+cAC/9oG7qZbxYPmKkc4oL7IJSNecGHA5SbU
|
||||
2268RFdl/gLz6tfRjbEOuOHzCjFPdvAdbysanpTMHLNc6FefJ+zxtgk9sJh0C4Jh
|
||||
vxFrw9nTKKzfEl12gQ1SOaEaUIO0fEBGbe8ZpauRAoGAMAlGV+2/K4ebvAJKOVTa
|
||||
dKAzQ+TD2SJmeR1HZmKDYddNqwtZlzg3v4ZhCk4eaUmGeC1Bdh8MDuB3QQvXz4Dr
|
||||
vOIP4UVaOr+uM+7TgAgVnP4/K6IeJGzUDhX93pmpWhODfdu/oojEKVcpCojmEmS1
|
||||
KCBtmIrQLqzMpnBpLNuSY+Q=
|
||||
-----END PRIVATE KEY-----
|
197
tests/integration/test_reload_client_certificate/test.py
Normal file
197
tests/integration/test_reload_client_certificate/test.py
Normal file
@ -0,0 +1,197 @@
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
TEST_DIR = os.path.dirname(__file__)
|
||||
|
||||
cluster = ClickHouseCluster(
|
||||
__file__,
|
||||
zookeeper_certfile=os.path.join(TEST_DIR, "configs_secure", "first_client.crt"),
|
||||
zookeeper_keyfile=os.path.join(TEST_DIR, "configs_secure", "first_client.key"),
|
||||
)
|
||||
|
||||
node1 = cluster.add_instance(
|
||||
"node1",
|
||||
main_configs=[
|
||||
"configs_secure/first_client.crt",
|
||||
"configs_secure/first_client.key",
|
||||
"configs_secure/second_client.crt",
|
||||
"configs_secure/second_client.key",
|
||||
"configs_secure/third_client.crt",
|
||||
"configs_secure/third_client.key",
|
||||
"configs_secure/conf.d/remote_servers.xml",
|
||||
"configs_secure/conf.d/ssl_conf.xml",
|
||||
"configs/zookeeper_config_with_ssl.xml",
|
||||
],
|
||||
with_zookeeper_secure=True,
|
||||
)
|
||||
|
||||
node2 = cluster.add_instance(
|
||||
"node2",
|
||||
main_configs=[
|
||||
"configs_secure/first_client.crt",
|
||||
"configs_secure/first_client.key",
|
||||
"configs_secure/second_client.crt",
|
||||
"configs_secure/second_client.key",
|
||||
"configs_secure/third_client.crt",
|
||||
"configs_secure/third_client.key",
|
||||
"configs_secure/conf.d/remote_servers.xml",
|
||||
"configs_secure/conf.d/ssl_conf.xml",
|
||||
"configs/zookeeper_config_with_ssl.xml",
|
||||
],
|
||||
with_zookeeper_secure=True,
|
||||
)
|
||||
|
||||
nodes = [node1, node2]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
yield cluster
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def secure_connection_test(started_cluster):
|
||||
# No asserts, connection works
|
||||
|
||||
node1.query("SELECT count() FROM system.zookeeper WHERE path = '/'")
|
||||
node2.query("SELECT count() FROM system.zookeeper WHERE path = '/'")
|
||||
|
||||
threads_number = 4
|
||||
iterations = 4
|
||||
threads = []
|
||||
|
||||
# Just checking for race conditions
|
||||
|
||||
for _ in range(threads_number):
|
||||
threads.append(
|
||||
threading.Thread(
|
||||
target=lambda: [
|
||||
node1.query("SELECT count() FROM system.zookeeper WHERE path = '/'")
|
||||
for _ in range(iterations)
|
||||
]
|
||||
)
|
||||
)
|
||||
for thread in threads:
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
|
||||
def change_config_to_key(name):
|
||||
"""
|
||||
Generate config with certificate/key name from args.
|
||||
Reload config.
|
||||
"""
|
||||
for node in nodes:
|
||||
node.exec_in_container(
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
"""cat > /etc/clickhouse-server/config.d/ssl_conf.xml << EOF
|
||||
<clickhouse>
|
||||
<openSSL>
|
||||
<client>
|
||||
<certificateFile>/etc/clickhouse-server/config.d/{cur_name}_client.crt</certificateFile>
|
||||
<privateKeyFile>/etc/clickhouse-server/config.d/{cur_name}_client.key</privateKeyFile>
|
||||
<loadDefaultCAFile>true</loadDefaultCAFile>
|
||||
<cacheSessions>true</cacheSessions>
|
||||
<disableProtocols>sslv2,sslv3</disableProtocols>
|
||||
<preferServerCiphers>true</preferServerCiphers>
|
||||
<verificationMode>none</verificationMode>
|
||||
<invalidCertificateHandler>
|
||||
<name>RejectCertificateHandler</name>
|
||||
</invalidCertificateHandler>
|
||||
</client>
|
||||
</openSSL>
|
||||
</clickhouse>
|
||||
EOF""".format(
|
||||
cur_name=name
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
node.exec_in_container(
|
||||
["bash", "-c", "touch /etc/clickhouse-server/config.d/ssl_conf.xml"],
|
||||
)
|
||||
|
||||
|
||||
def check_reload_successful(node, cert_name):
|
||||
return node.grep_in_log(
|
||||
f"Reloaded certificate (/etc/clickhouse-server/config.d/{cert_name}_client.crt)"
|
||||
)
|
||||
|
||||
|
||||
def check_error_handshake(node):
|
||||
return node.count_in_log("Code: 210.")
|
||||
|
||||
|
||||
def clean_logs():
|
||||
for node in nodes:
|
||||
node.exec_in_container(
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
"echo -n > /var/log/clickhouse-server/clickhouse-server.log",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def check_certificate_switch(first, second):
|
||||
# Set first certificate
|
||||
|
||||
change_config_to_key(first)
|
||||
|
||||
# Restart zookeeper to reload the session
|
||||
|
||||
cluster.stop_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
cluster.start_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
cluster.wait_zookeeper_nodes_to_start(["zoo1", "zoo2", "zoo3"])
|
||||
clean_logs()
|
||||
|
||||
# Change certificate
|
||||
|
||||
change_config_to_key(second)
|
||||
|
||||
# Time to log
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
# Check information about client certificates reloading in log Clickhouse
|
||||
|
||||
reload_successful = any(check_reload_successful(node, second) for node in nodes)
|
||||
|
||||
# Restart zookeeper to reload the session and clean logs for new check
|
||||
|
||||
cluster.stop_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
cluster.start_zookeeper_nodes(["zoo1", "zoo2", "zoo3"])
|
||||
clean_logs()
|
||||
cluster.wait_zookeeper_nodes_to_start(["zoo1", "zoo2", "zoo3"])
|
||||
|
||||
if second == "second":
|
||||
try:
|
||||
secure_connection_test(started_cluster)
|
||||
assert False
|
||||
except:
|
||||
assert True
|
||||
else:
|
||||
secure_connection_test(started_cluster)
|
||||
error_handshake = any(check_error_handshake(node) == "0\n" for node in nodes)
|
||||
assert reload_successful and error_handshake
|
||||
|
||||
|
||||
def test_wrong_cn_cert():
|
||||
"""Checking the certificate reload with an incorrect CN, the expected behavior is Code: 210."""
|
||||
check_certificate_switch("first", "second")
|
||||
|
||||
|
||||
def test_correct_cn_cert():
|
||||
"""Replacement with a valid certificate, the expected behavior is to restore the connection with Zookeeper."""
|
||||
check_certificate_switch("second", "third")
|
Loading…
Reference in New Issue
Block a user